chore: cleanup

This commit is contained in:
2025-07-12 02:02:03 +03:00
parent a526dbf6c6
commit 6e16c5831e
7 changed files with 19 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
using JOBot.TClient.Commands;
using JOBot.TClient.Commands.Buttons;
using JOBot.TClient.Commands.Commands;
using JOBot.TClient.Infrastructure.Attributes.Authorization;
using JOBot.TClient.Infrastructure.Extensions;
using JOBot.TClient.Services;
@@ -37,15 +38,15 @@ public sealed class BotBackgroundService(
["/start"] = scope.ServiceProvider.GetRequiredService<StartCommand>(),
["/menu"] = scope.ServiceProvider.GetRequiredService<MenuCommand>(),
["/info"] = scope.ServiceProvider.GetRequiredService<InfoCommand>(),
//Buttons
[ButtonResource.EULAAgrement] = scope.ServiceProvider.GetRequiredService<EulaAgreementButtonCommand>(),
};
if (update.Message?.Text is { } text && update.Message?.From != null)
if (update.Message is { Text: { } text, From: not null })
{
var user = await userService.GetUser(update, ct); //Check user for existance
var user = await userService.GetUser(update, ct); //Проверка существования пользователя
if (user == null)
{
await commands["/start"].ExecuteAsync(update, ct);
@@ -56,18 +57,23 @@ public sealed class BotBackgroundService(
{
if (command is IAuthorizedTelegramCommand authorizedTelegramCommand)
{
var attribute = Attribute.GetCustomAttribute(command.GetType(), typeof(AcceptNotPreparedAttribute));
var attribute = Attribute.GetCustomAttribute(
command.GetType(),
typeof(AcceptNotPreparedAttribute));
if (!user.IsPrepared() && attribute is not AcceptNotPreparedAttribute)
{
await commands["/start"].ExecuteAsync(update, ct); //заставляем пользователя завершить регистрацию
await commands["/start"].ExecuteAsync(update, ct);
//заставляем пользователя завершить регистрацию
return;
}
await authorizedTelegramCommand.ExecuteAsync(update, user, ct);
}
else await command.ExecuteAsync(update, ct);
return;
}
await bot.SendMessage(update.Message.From.Id, TextResource.CommandNotFound, cancellationToken: ct);
}
}