12345678910111213141516171819202122 |
- #nullable enable
- using System.Threading.Tasks;
- using Telegram.Bot.Types;
- using Telegram.Bot.Types.Enums;
- namespace MafiaTelegramBot.Models.Replies
- {
- public abstract class Reply : UpdateModel<string>
- {
- public static async Task<Message> Update(Update update)
- {
- var commands = Bot.Replies;
- var message = update.Message.ReplyToMessage.Text;
- var userId = update.Message.From.Id;
- var chatId = update.Message.Chat.Id;
- await Bot.Get().SendChatActionAsync(chatId, ChatAction.Typing);
- var command = FirstOrDefault(commands, message);
- if(command != null) return await ((Reply?) command.Clone(chatId, userId))!.Execute(update);
- return await Bot.SendWithMarkdown2(chatId, $"{strings.command_not_found} _*\\({message}\\)*_");
- }
- }
- }
|