12345678910111213141516171819202122232425262728293031 |
- using System.Linq;
- using System.Threading.Tasks;
- using Telegram.Bot;
- using Telegram.Bot.Types;
- namespace MafiaTelegramBot.Models.Inlines
- {
- public abstract class Query
- {
- protected abstract string Name { get; }
- protected abstract Task Execute(long chatId, TelegramBotClient client);
- private bool Contains(string command)
- {
- return command.Contains(Name);
- }
-
- public static Task Update(Update update)
- {
- var queries = Bot.Queries;
- var data = update.CallbackQuery.Data;
- var chatId = update.CallbackQuery.Message.Chat.Id;
- var client = Bot.Get();
- return (from query in queries
- where query.Contains(data)
- select query.Execute(chatId, client)).FirstOrDefault();
- }
- }
- }
|