Exemplo n.º 1
0
 public async override void Handle(MessageWrapper message, ITelegramBotClient client)
 {
     if (message.HasRegexIgnoreMention(BotWeatherRegex) || message.HasRegexIgnoreMention(BotWeatherSmallRegex))
     {
         var we = new WeatherWorker();
         var mm = BotWeatherRegex.Match(message.CurrentMessage);
         if (!mm.Success)
         {
             mm = BotWeatherRegex.Match(message.MessageInLayouts[1]);
         }
         if (!mm.Success)
         {
             mm = BotWeatherSmallRegex.Match(message.CurrentMessage);
         }
         if (!mm.Success)
         {
             mm = BotWeatherSmallRegex.Match(message.MessageInLayouts[1]);
         }
         var m = mm.Groups.Last();
         if (m.Value.Contains("киев", StringComparison.InvariantCultureIgnoreCase))
         {
             await client.SendTextMessageAsync(message.Chat.Id, we.GetWeather("kyiv"));
         }
         if (m.Value.Contains("днепр", StringComparison.InvariantCultureIgnoreCase))
         {
             await client.SendTextMessageAsync(message.Chat.Id, we.GetWeather("dnipro"));
         }
     }
     else
     {
         NextHandler?.Handle(message, client);
     }
 }
Exemplo n.º 2
0
 public override void Handle(MessageWrapper message, ITelegramBotClient client)
 {
     if (message.HasRegexIgnoreMention(NeededRegex))
     {
         ConcreteRegexHandler(message, client);
     }
     else
     {
         NextHandler?.Handle(message, client);
     }
 }