示例#1
0
        public async Task Execute <T1, T2>(Update update, TelegramBotClient client) where T2 : Command
        {
            try
            {
                Command command       = (T2)typeof(T2).GetConstructor(new Type[] { typeof(CommandService) }).Invoke(new object[1]);
                string  input         = GetTextInput(update);
                var     innerCommands = new List <string>();
                command.InnerCommands?.ForEach(c => innerCommands.Add(c.ToString()));

                if (command.Name == input)
                {
                    await client.SendTextMessageAsync(update.CallbackQuery.Message.Chat.Id, command.Message,
                                                      ParseMode.Markdown, false, false, 0,
                                                      _keyboardService.GetKeyboard(innerCommands));
                }
                else
                {
                    await SendActivityToChat(command, update, client);
                }
            }
            catch (Exception ex)
            {
                Debugger.Break(); Log.Error(ex, ex.Message);
            }
        }
示例#2
0
 public override async Task Execute <T>(Update update, TelegramBotClient client)
 {
     await client.SendTextMessageAsync(update.Message.Chat.Id, Message,
                                       parseMode : ParseMode.Markdown,
                                       false, false, 0,
                                       _keyboardService.GetKeyboard(new List <string>()
     {
         nameof(FilterEnum.Type),
         nameof(FilterEnum.Participants), nameof(FilterEnum.Price), nameof(FilterEnum.Accessibility)
     }));
 }