From 7885a6b629ee37997f775c8f03a65454505b1f45 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 12 Nov 2026 20:18:19 +0330 Subject: [PATCH] adding support of Bot Service Usage ... --- Controllers/XBotProviderController.cs | 186 ++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 Controllers/XBotProviderController.cs diff --git a/Controllers/XBotProviderController.cs b/Controllers/XBotProviderController.cs new file mode 100644 index 0000000..db001e6 --- /dev/null +++ b/Controllers/XBotProviderController.cs @@ -0,0 +1,186 @@ +using xIdentityHelper; +using System.Threading; +using xBotService.Models; +using xCommons.Providers; +using xCommons.Attributes; +using System.Threading.Tasks; +using xBotService.Interfaces; +using xBotService.Controllers; +using xCommons.Configurations; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; +using xIdentityService.Interfaces; +using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Authorization; + +namespace xServices.Controllers +{ + [Authorize] + [RequireXPowered] + public class XBotProviderController : XBotProviderControllerBase + { + public XBotProviderController( + IXBotProvider botProvider, + XAppConfiguration appConfiguration, + IXIdentityProvider identityProvider, + XValidationProvider validationProvider, + ILogger logger + ) : base( + botProvider, + logger, + appConfiguration, + identityProvider, + validationProvider + ) + { } + + // + #region Override ... + [HttpGet("Me")] + [Authorize(Policy = XPolicies.EnabledAdmin)] + public override async Task> GetMe( + CancellationToken cancellationToken = default + ) + { + // + var result = await base.GetMe( + cancellationToken: cancellationToken + ); + + // + return result; + } + + [HttpGet("Updates")] + [Authorize(Policy = XPolicies.EnabledAdmin)] + public override async Task>> GetUpdates( + [FromQuery] XBotUpdatesRequest request, + CancellationToken cancellationToken = default + ) + { + // + var result = await base.GetUpdates( + request: request, + cancellationToken: cancellationToken + ); + + // + return result; + } + + [HttpPost("Message")] + [Authorize(Policy = XPolicies.EnabledAdmin)] + public override async Task> SendMessage( + [FromBody] XBotSendMessageRequest request, + CancellationToken cancellationToken = default + ) + { + // + var result = await base.SendMessage( + request: request, + cancellationToken: cancellationToken + ); + + // + return result; + } + + // [HttpPost("{chatId}/ShowVerificationMenu")] + // [Authorize(Policy = XPolicies.EnabledAdmin)] + // public override async Task> ShowVerificationMenu( + // [FromRoute] long chatId, + // CancellationToken cancellationToken = default + // ) + // { + // // + // var result = await base.ShowVerificationMenu( + // chatId: chatId, + // cancellationToken: cancellationToken + // ); + + // // + // return result; + // } + + // [HttpPost("{chatId}/SendVerificationCode")] + // [Authorize(Policy = XPolicies.EnabledAdmin)] + // public override async Task> SendVerificationCode( + // [FromRoute] long chatId, + // [FromQuery] string code, + // [FromQuery] int ttlSeconds, + // CancellationToken cancellationToken = default + // ) + // { + // // + // var result = await base.SendVerificationCode( + // code: code, + // chatId: chatId, + // ttlSeconds: ttlSeconds, + // cancellationToken: cancellationToken + // ); + + // // + // return result; + // } + + // [HttpPost("{id}/AnswerCallback")] + // [Authorize(Policy = XPolicies.EnabledAdmin)] + // public override async Task> AnswerCallbackQuery( + // [FromRoute] string callbackQueryId, + // [FromQuery] string text = null, + // [FromQuery] bool showAlert = false, + // CancellationToken cancellationToken = default + // ) + // { + // // + // var result = await base.AnswerCallbackQuery( + // text: text, + // showAlert: showAlert, + // callbackQueryId: callbackQueryId, + // cancellationToken: cancellationToken + // ); + + // // + // return result; + // } + + // [HttpPost("{chatId}/RemoveInlineKeyboard")] + // [Authorize(Policy = XPolicies.EnabledAdmin)] + // public override async Task> RemoveInlineKeyboard( + // [FromRoute] long chatId, + // [FromQuery] long messageId, + // CancellationToken cancellationToken = default + // ) + // { + // // + // var result = await base.RemoveInlineKeyboard( + // chatId: chatId, + // messageId: messageId, + // cancellationToken: cancellationToken + // ); + + // // + // return result; + // } + + // [HttpPost("Webhook")] + // [Authorize(Policy = XPolicies.EnabledAdmin)] + // public override async Task> SetWebhook( + // [FromQuery] string webhookUrl, + // [FromQuery] string secretToken = null, + // CancellationToken cancellationToken = default + // ) + // { + // // + // var result = await base.SetWebhook( + // webhookUrl: webhookUrl, + // secretToken: secretToken, + // cancellationToken: cancellationToken + // ); + + // // + // return result; + // } + #endregion + } +} \ No newline at end of file