WIP: implemented registration and EULA accept, WIP on auth issue

This commit is contained in:
2025-07-12 01:24:39 +03:00
parent ac39117cf4
commit 67a3457f2d
17 changed files with 569 additions and 87 deletions

View 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);
}
}

View 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.");
}
}

View File

@@ -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);
}
}