adding support of Bot Service Usage ...

This commit is contained in:
2026-11-12 20:18:19 +03:30
parent 0a641f4117
commit 7885a6b629
+186
View File
@@ -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<XBotProviderController> logger
) : base(
botProvider,
logger,
appConfiguration,
identityProvider,
validationProvider
)
{ }
//
#region Override ...
[HttpGet("Me")]
[Authorize(Policy = XPolicies.EnabledAdmin)]
public override async Task<ActionResult<XBotResUser>> GetMe(
CancellationToken cancellationToken = default
)
{
//
var result = await base.GetMe(
cancellationToken: cancellationToken
);
//
return result;
}
[HttpGet("Updates")]
[Authorize(Policy = XPolicies.EnabledAdmin)]
public override async Task<ActionResult<IList<XBotUpdateResponse>>> 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<ActionResult<XBotMessage>> 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<ActionResult<XBotMessageResponse>> 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<ActionResult<XBotMessageResponse>> 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<ActionResult<XBotMessageResponse>> 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<ActionResult<XBotMessageResponse>> 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<ActionResult<bool>> 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
}
}