Beispiel #1
0
        public override void Execute(ITelegramBotClient client, Message message)
        {
            var           commands = ListCommands.GetAllCommands();
            StringBuilder sb       = new StringBuilder();

            sb.AppendLine("Я підтримую наступні команди:");
            foreach (var command in commands.Skip(1))
            {
                sb.AppendLine($"{command.TextCommand} {command.Des} \nПриклад: [{command.Example}]\n");
            }
            client.SendTextMessageAsync(message.Chat, sb.ToString());
        }
Beispiel #2
0
 private static void Client_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
 {
     Console.OutputEncoding = Encoding.UTF8;
     Console.WriteLine($"Name: {e.Message.From.FirstName}, Id: {e.Message.From.Id} [{e.Message.Text}]");
     if (e.Message.Type == MessageType.Text)
     {
         foreach (var item in ListCommands.GetAllCommands())
         {
             if (item.TextCommand.CheckCommand(e.Message.Text))
             {
                 e.Message.Text = e.Message.Text.ToLower();
                 item.Execute(client, e.Message);
                 return;
             }
         }
     }
     client.SendTextMessageAsync(e.Message.Chat, "Команда не вірна!");
 }