/
d.alekseev
/
SmartMenuBot
Обзор
Документация
Войти
/
d.alekseev
/
SmartMenuBot
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ConsoleBot/TelegramBot/Commands/Implementations/InfoCommand.cs
37 строк
2 KB
d.alekseev
feat: миграция на Telegram.Bot с reply-клавиатурами и меню команд
08 фев 2026, 17:00
08 фев 2026, 17:00
054ee94
Код
Авторство
О чём код?
using Telegram.Bot; using SmartMenuBot.Core.Services.Domain; using SmartMenuBot.Core.Services.Interfaces; using SmartMenuBot.TelegramBot.Commands.Interfaces; namespace SmartMenuBot.TelegramBot.Commands.Implementations { public class InfoCommand(ITelegramBotClient botClient, IUserService userService) : IBotCommand { public string CommandText => "/info"; public bool CanExecute(CommandContext context) { string? messageText = context.Update.Message?.Text; return messageText != null && messageText.StartsWith(CommandText, StringComparison.OrdinalIgnoreCase); } 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; } VersionInfoService.GetVersionInfo(out string version, out DateTime creationDate); await botClient.SendMessage(context.Update.Message.Chat.Id, $"System version: {version}, created on: {creationDate:dd.MM.yyyy}", cancellationToken: ct); } } }