Exemplo n.º 1
0
        private void LoadUserGames()
        {
            var games = service.Games.GetAllGamesAsync();

            foreach (var game in games.Result)
            {
                CommandsCenter.Add(new InlineButton($"{game.Name}| {game.ActiveRoles} |{game.Players.Count() +"/" + game.MaxPlayers}",
                                                    game.Id.ToString(), EnterRoomCallback));
            }
        }
Exemplo n.º 2
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add("/help", ShowHelpCallback);
     CommandsCenter.Add(new ReplyMenu("HelpMenu", true, new KeyboardButton[][]
     {
         new KeyboardButton[]
         {
             CommandsCenter.Add(new ReplyButton("Быстрые команды", FastCommandsCallback)).Button
         }
     }));
 }
Exemplo n.º 3
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add("/exit", ExitGameCallback);
     CommandsCenter.Add(new ReplyMenu("ExitGameMenu", true,
                                      new KeyboardButton[][]
     {
         new KeyboardButton[]
         {
             CommandsCenter.Add(new ReplyButton("Выйти из игры", ExitGameCallback)).Button
         }
     }));
 }
Exemplo n.º 4
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add(new InlineMenu("AboutMenu",
                                       new InlineKeyboardButton[][]
     {
         new InlineKeyboardButton[]
         {
             new InlineKeyboardUrlButton("Правила игры", "https://ru.wikipedia.org/wiki/Мафия_(игра)")
         },
         new InlineKeyboardButton[]
         {
             new InlineKeyboardUrlButton("💬 Нашли баг или бот не работает?", "https://t.me/DedSec256")
         }
     }));
 }
Exemplo n.º 5
0
        public void AddInCommandCenter()
        {
            CommandsCenter.Add(new InlineButton($"❌ Комиссар {Roles.Comissar.GetRoleIcon()}",
                                                Roles.Comissar.ToString() + "Add", AddRoleCallback));
            CommandsCenter.Add(new InlineButton($"❌ Доктор {Roles.Doctor.GetRoleIcon()}",
                                                Roles.Doctor.ToString() + "Add", AddRoleCallback));
            CommandsCenter.Add(new InlineButton($"❌ Маньяк {Roles.Maniac.GetRoleIcon()}",
                                                Roles.Maniac.ToString() + "Add", AddRoleCallback));

            CommandsCenter.Add(new InlineButton($"✅ Комиссар {Roles.Comissar.GetRoleIcon()}",
                                                Roles.Comissar.ToString() + "Remove", AddRoleCallback));
            CommandsCenter.Add(new InlineButton($"✅ Доктор {Roles.Doctor.GetRoleIcon()}",
                                                Roles.Doctor.ToString() + "Remove", AddRoleCallback));
            CommandsCenter.Add(new InlineButton($"✅ Маньяк {Roles.Maniac.GetRoleIcon()}",
                                                Roles.Maniac.ToString() + "Remove", AddRoleCallback));

            CommandsCenter.Add(new InlineButton("🌘 Создать игру!", "createGame", CreateGameCallback));
        }
Exemplo n.º 6
0
        private void AddVote(Message message, TelegramBotClient bot)
        {
            string[] args = message.Text.Replace("/vote", "").Trim()
                            .Split(new[] { '!' }, StringSplitOptions.RemoveEmptyEntries);
            if (args.Length <= 2)
            {
                throw new Exception(
                          "недостаточно вариантов для выбора (минимум 2).");
            }

            args[0] = args[0].Trim();

            var keyb = VoteSystem.AddNewVote(args[0], args.Where((s, i) => i > 0).ToArray());

            CommandsCenter.Add(new ReplyButton(args[0], NewVoteButtonCallback));

            UserDatabase.Broadcast(user => true,
                                   user => "*Опрос пользователей:*\n\n" + args[0].Trim(), bot,
                                   (new ReplyMenu("", true, keyb)).Keyboard);
        }
Exemplo n.º 7
0
        public virtual void AddInCommandCenter()
        {
            CommandsCenter.Add(new ReplyMenu("StartMenu", true, new KeyboardButton[][]
            {
                new KeyboardButton[]
                {
                    CommandsCenter.Add(new ReplyButton("🌃 Создать игру", CreateGameCallback)).Button
                },
                new KeyboardButton[]
                {
                    CommandsCenter.Add(new ReplyButton("💣 Присоединиться к игре", JoinGameCallback)).Button
                },
                new KeyboardButton[]
                {
                    CommandsCenter.Add(new ReplyButton("👥 О боте", AboutCallback)).Button
                }
            }, "Подсказка: чтобы выйти из текущей игры, нажмите /exit"));

            CommandsCenter.Add("/start", RegisterUserCallback);
        }
Exemplo n.º 8
0
        private async void CreateGameCallback(Message message, TelegramBotClient Bot, object arg)
        {
            var user = UserDatabase.GetUser(message.Chat.Id);

            if (user.GameRoomCreation == null)
            {
                GameNotFound(message, Bot, user);
                return;
            }

            else
            {
                GameRoom game = null;
                try
                {
                    game = service.Games
                           .CreateGameAsync(GameRoom.CreateGameRoom(user.GameRoomCreation))
                           .Result.ToGameRoom();

                    CommandsCenter.Add(new InlineButton($"{game.Name}| {game.ActiveRoles} |{game.Players.Count() + "/" + game.MaxPlayers}",
                                                        game.Id.ToString(), InGame.EnterRoomCallback));
                }
                catch (Exception ex)
                {
                    await Bot.SendTextMessageAsync(message.Chat.Id,
                                                   "Ошибка при создании игры 😢: " + ex.Message);

                    return;
                }

                user.SetRoom(user.User.Id);
                await CommandsCenter.GetMenu("ExitGameMenu").ShowAsync(message.Chat.Id, Bot,
                                                                       "Комната успешно создана!\n*Ожидание игроков...*");

                Bot.ShowAnswerMessage((arg as CallbackQuery).Id,
                                      "На этом всё! :c\n\n" +
                                      "Увы, время защиты ограничено. Но не переживайте!\n" +
                                      "Подписывайтесь на бота и ждите обновлений!");
            }
        }
Exemplo n.º 9
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add(new ReplyButton("/vote", async(message, bot, arg) =>
     {
         string command = "/vote";
         if ((message.Chat.Id == 422672483))
         {
             try
             {
                 if (message.Text.Trim() == command)
                 {
                     GetVote(message, bot);
                     return;
                 }
                 AddVote(message, bot);
             }
             catch (Exception ex)
             {
                 await bot.SendTextMessageAsync(message.Chat.Id,
                                                $"*Не удалось начать голосование:* `{ex.Message}`", ParseMode.Markdown);
             }
         }
     }));
 }
Exemplo n.º 10
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add(new ReplyButton("/send", (message, bot, arg) =>
     {
         if ((message.Chat.Id == 422672483))
         {
             const string command = "/send";
             message.Text         = message.Text.Replace(command, "");
             if (!String.IsNullOrEmpty(message.Text))
             {
                 UserDatabase.Broadcast(user => true, user => message.Text, bot);
                 BotConsole.Write("Расслыка завершена.", MessageType.Info);
             }
         }
     }));
     CommandsCenter.Add(new ReplyButton("/count", async(message, bot, arg) =>
     {
         if ((message.Chat.Id == 422672483))
         {
             await bot.SendTextMessageAsync(message.Chat.Id,
                                            $"Количество пользователей: {UserDatabase.UsersCount()}", ParseMode.Markdown);
         }
     }));
 }
Exemplo n.º 11
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add(new InlineButton("", "callbackQueryAnswer", QueryAnswerCallback));
 }
Exemplo n.º 12
0
 public void AddInCommandCenter()
 {
     CommandsCenter.Add(this);
 }