feat: implemented registration stage of preparation on PrepareUserState
implemented auth, added auth tools AcceptNotPreparedAttribute.cs, IAuthorizedTelegramCommand.cs
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Infrastructure.Attributes.Authorization;
|
||||
using JOBot.TClient.Services;
|
||||
using JOBot.TClient.Statements;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace JOBot.TClient.Commands.Buttons;
|
||||
|
||||
public class EulaAgreementButtonCommand(PrepareUserService prepareUserService) : IAuthorizedTelegramCommand
|
||||
[AcceptNotPrepared]
|
||||
public class EulaAgreementButtonCommand(PrepareUserState prepareUserState) : IAuthorizedTelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct)
|
||||
{
|
||||
if (update.Type != UpdateType.Message || update.Message?.From == null)
|
||||
return;
|
||||
|
||||
await prepareUserService.AcceptEula(update, ct);
|
||||
await prepareUserState.AcceptEula(update, ct);
|
||||
}
|
||||
}
|
||||
14
JOBot.TClient/Commands/InfoCommand.cs
Normal file
14
JOBot.TClient/Commands/InfoCommand.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands;
|
||||
|
||||
public class InfoCommand(ITelegramBotClient bot) : ITelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update.Message?.From);
|
||||
|
||||
await bot.SendMessage(update.Message.From.Id, TextResource.Info, cancellationToken: ct);
|
||||
}
|
||||
}
|
||||
13
JOBot.TClient/Commands/MenuCommand.cs
Normal file
13
JOBot.TClient/Commands/MenuCommand.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Services;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands;
|
||||
|
||||
public class MenuCommand(MenuService menuService) : IAuthorizedTelegramCommand
|
||||
{
|
||||
public async Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct)
|
||||
{
|
||||
await menuService.RenderMenu(update, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user