18 lines
647 B
C#
18 lines
647 B
C#
using JOBot.TClient.Core.Services;
|
|
using Telegram.Bot;
|
|
using Telegram.Bot.Types;
|
|
|
|
namespace JOBot.TClient.Commands;
|
|
|
|
public class StartCommand(ITelegramBotClient bot, UserService userService) : ITelegramCommand
|
|
{
|
|
public async Task ExecuteAsync(Update update, CancellationToken ct)
|
|
{
|
|
var isRegistered = await userService.RegisterAsync(
|
|
update.Message?.Chat.Id ?? throw new Exception("Chat id is null"),
|
|
update.Message.Chat.Username);
|
|
|
|
await bot.SendMessage(chatId: update.Message.Chat.Id,
|
|
isRegistered ? "You registered" : "Not registered", cancellationToken: ct);
|
|
}
|
|
} |