Bot.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections.Generic;
  2. using MafiaTelegramBot.Models.Commands;
  3. using MafiaTelegramBot.Models.Queries;
  4. using MafiaTelegramBot.Resources;
  5. using Telegram.Bot;
  6. namespace MafiaTelegramBot.Models
  7. {
  8. public static class Bot
  9. {
  10. private static TelegramBotClient _client;
  11. private static List<Command> _commandsList;
  12. private static List<Query> _queriesList;
  13. public static IReadOnlyList<Command> Commands => _commandsList.AsReadOnly();
  14. public static IReadOnlyList<Query> Queries => _queriesList.AsReadOnly();
  15. public static TelegramBotClient Get()
  16. {
  17. if (_client != null) return _client;
  18. InitCommands();
  19. InitQueries();
  20. _client = new TelegramBotClient(AppSettings.Token);
  21. //var hook = string.Format(AppSettings.Url, "api/message/update");
  22. //await _client.SetWebhookAsync(hook);
  23. return _client;
  24. }
  25. private static void InitCommands()
  26. {
  27. //TODO fill commands array
  28. _commandsList = new List<Command>
  29. {
  30. new StartCommand(),
  31. new CreateGameCommand(),
  32. new ConnectGameCommand(),
  33. new ShowProfileCommand()
  34. };
  35. }
  36. private static void InitQueries()
  37. {
  38. //TODO fill inline keyboard array
  39. _queriesList = new List<Query>
  40. {
  41. new CreateGame(),
  42. new ConnectGame(),
  43. new ShowProfile()
  44. };
  45. }
  46. }
  47. }