/
d.alekseev
/
SmartMenuBot
Обзор
Документация
Войти
/
d.alekseev
/
SmartMenuBot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ConsoleBot/TelegramBot/Commands/Implementations/UnknownCommand.cs
31 строка
1 KB
d.alekseev
feat: миграция на Telegram.Bot с reply-клавиатурами и меню команд
08 фев 2026, 17:00
08 фев 2026, 17:00
054ee94
Код
Авторство
О чём код?
using Telegram.Bot; using SmartMenuBot.Core.Services.Interfaces; using SmartMenuBot.TelegramBot.Commands.Interfaces; namespace SmartMenuBot.TelegramBot.Commands.Implementations { public class UnknownCommand(ITelegramBotClient botClient, IUserService userService) : IBotCommand { public string CommandText => string.Empty; public bool CanExecute(CommandContext context) => false; public async Task ExecuteAsync(CommandContext context) { var ct = context.CancellationToken; var existingUser = await userService.GetUserAsync(context.Update.Message!.From!.Id, ct); if (existingUser == null) { await botClient.SendMessage( context.Update.Message.Chat.Id, "\nДля использования этой функции необходимо авторизоваться командой /start", replyMarkup: ReplyKeyboards.PreRegistration, cancellationToken: ct ); return; } await botClient.SendMessage(context.Update.Message.Chat.Id, $"\nНеизвестная команда", cancellationToken: ct); } } }