WIP: implemented registration and EULA accept, WIP on auth issue
This commit is contained in:
17
JOBot.TClient/Commands/Buttons/EulaAgreementButtonCommand.cs
Normal file
17
JOBot.TClient/Commands/Buttons/EulaAgreementButtonCommand.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using JOBot.Proto;
|
||||
using JOBot.TClient.Services;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace JOBot.TClient.Commands.Buttons;
|
||||
|
||||
public class EulaAgreementButtonCommand(PrepareUserService prepareUserService) : 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);
|
||||
}
|
||||
}
|
||||
15
JOBot.TClient/Commands/IAuthorizedTelegramCommand.cs
Normal file
15
JOBot.TClient/Commands/IAuthorizedTelegramCommand.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using JOBot.Proto;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace JOBot.TClient.Commands;
|
||||
|
||||
public interface IAuthorizedTelegramCommand : ITelegramCommand
|
||||
{
|
||||
public Task ExecuteAsync(Update update, GetUserResponse user, CancellationToken ct);
|
||||
|
||||
Task ITelegramCommand.ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
throw new UnauthorizedAccessException("You do not have permission to access this command.");
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,14 @@
|
||||
using JOBot.TClient.Core.Services;
|
||||
using Telegram.Bot;
|
||||
using JOBot.TClient.Commands.Buttons;
|
||||
using JOBot.TClient.Statements;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace JOBot.TClient.Commands;
|
||||
|
||||
public class StartCommand(ITelegramBotClient bot, UserService userService) : ITelegramCommand
|
||||
public class StartCommand(PrepareUserState prepareUserState) : ITelegramCommand
|
||||
{
|
||||
private const string ReturnMessage = "Привет! Я JOBot, помощник по поиску работы в IT.";
|
||||
public async Task ExecuteAsync(Update update, CancellationToken ct)
|
||||
{
|
||||
await userService.RegisterAsync(
|
||||
update.Message!.Chat.Id,
|
||||
update.Message.Chat.Username);
|
||||
|
||||
await bot.SendMessage(chatId: update.Message.Chat.Id,
|
||||
"Продолжая, вы принимаете политику конфиденциальности и правила сервиса" +
|
||||
"\nhttps://hh.ru/article/personal_data?backurl=%2F&role=applicant" +
|
||||
"\nhttps://hh.ru/account/agreement?backurl=%2Faccount%2Fsignup%3Fbackurl%3D%252F%26role%3Dapplicant&role=applicant",
|
||||
cancellationToken: ct);
|
||||
await prepareUserState.TryToPrepareUser(update, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user