1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using MafiaTelegramBot.Models.Commands;
- using MafiaTelegramBot.Models.Inlines;
- using MafiaTelegramBot.Models.Replies;
- using MafiaTelegramBot.Resources;
- using Telegram.Bot;
- using Telegram.Bot.Types;
- using Telegram.Bot.Types.Enums;
- using Telegram.Bot.Types.ReplyMarkups;
- namespace MafiaTelegramBot.Models
- {
- public static class Bot
- {
- private static TelegramBotClient _client;
- private static List<Command> _commandsList;
- private static List<Query> _queriesList;
- private static List<Reply> _repliesList;
-
- public static IReadOnlyList<Command> Commands => _commandsList.AsReadOnly();
- public static IReadOnlyList<Query> Queries => _queriesList.AsReadOnly();
- public static IReadOnlyList<Reply> Replies => _repliesList.AsReadOnly();
- public static readonly List<long> UsersThatChangesNickname = new();
- public static readonly Dictionary<long, string[]> UsersThatCreatesRoom = new();
- public static readonly List<long> UserThatEntersPrivateCode = new();
- public static TelegramBotClient Get()
- {
- if (_client != null) return _client;
- InitCommands();
- InitQueries();
- InitReplies();
- _client = new TelegramBotClient(AppSettings.Token);
- //var hook = string.Format(AppSettings.Url, "api/message/update");
- //await _client.SetWebhookAsync(hook);
- return _client;
- }
- private static void InitCommands()
- {
- //TODO fill commands array
- _commandsList = new List<Command>
- {
- new StartCommand(),
- new CreateGameCommand(),
- new ConnectGameCommand(),
- new ShowProfileCommand(),
- new RoomSettingsCommand(),
- new LeaveCommand(),
- new LookPlayersListCommand(),
- new KickPlayerCommand()
- };
- }
-
- private static void InitQueries()
- {
- //TODO fill inline keyboard array
- _queriesList = new List<Query>
- {
- new ShowMyRolesQuery(),
- new ShopMenuQuery(),
- new MakePrivateRoomQuery(),
- new MakePublicRoomQuery(),
- new MakeNormalGameQuery(),
- new MakeExtendedGameQuery(),
- new MakePublicRoomQuery(),
- new SettingsProfileQuery(),
- new ChangeNickNameQuery(),
- new SettingsRoomQuery(),
- new ConnectToPrivateRoomQuery(),
- new SetPlayersMaximumQuery(),
- new ConnectToPublicRoomQuery(),
- new ConnectToSelectedRoomQuery(),
- new KickSelectedPlayerQuery()
- };
- }
-
- private static void InitReplies()
- {
- //TODO fill inline keyboard array
- _repliesList = new List<Reply>
- {
-
- };
- }
-
- public static async Task<Message> SendWithMarkdown2(long chatId, string message, IReplyMarkup replyMarkup = null)
- {
- return await Get().SendTextMessageAsync(chatId, await Utilities.ToMarkdownString(message),
- ParseMode.MarkdownV2, replyMarkup: replyMarkup);
- }
- }
- }
|