Bot.cs 875 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Threading;
  3. using MafiaTelegramBot.Controllers;
  4. using MafiaTelegramBot.Resources;
  5. using Telegram.Bot;
  6. using Telegram.Bot.Extensions.Polling;
  7. namespace MafiaTelegramBot
  8. {
  9. public static class Bot
  10. {
  11. private static TelegramBotClient _client;
  12. public static TelegramBotClient Client
  13. {
  14. get
  15. {
  16. if (_client != null) return _client;
  17. _client = new TelegramBotClient(AppSettings.Token);
  18. return _client;
  19. }
  20. }
  21. public static void Main()
  22. {
  23. var cts = new CancellationTokenSource();
  24. Client.StartReceiving(new DefaultUpdateHandler(MessageController.HandleUpdateAsync, MessageController.HandleErrorAsync), cts.Token);
  25. Console.ReadLine();
  26. cts.Cancel();
  27. }
  28. }
  29. }