Exemplo n.º 1
0
        public static async void NewVoteButtonCallback(Message message, TelegramBotClient bot, object arg)
        {
            try
            {
                if ((message.Chat.Id != 422672483 && message.Chat.Id != 387628875 && message.From.Username != "gridmer"))
                {
                    return;
                }

                int hash = message.Text.GetHashCode();
                var menu = new InlineMenu("", new InlineKeyboardButton[][]
                {
                    new InlineKeyboardButton[]
                    {
                        CommandsCenter.GetInlineButton(hash + "retry").Button,
                        CommandsCenter.GetInlineButton(hash + "delete").Button
                    }
                });
                await bot.SendTextMessageAsync(message.Chat.Id,
                                               VoteSystem.GetVotesNames(message.Text).First(), ParseMode.Markdown, false, false, 0, menu.Keyboard);
            }
            catch
            {
                await bot.SendTextMessageAsync(message.Chat.Id,
                                               "*Опрос закрыт или не создан*");
            }
        }
Exemplo n.º 2
0
        private void AddRoleCallback(Message message, TelegramBotClient Bot, object arg)
        {
            var    user       = UserDatabase.GetUser(message.Chat.Id);
            string buttonText = CommandsCenter.GetInlineButton((arg as CallbackQuery).Data).Button.Text;

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

                else
                {
                    user.GameRoomCreation
                    .AddRole(buttonText.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2]);
                }
            }
            else if (buttonText.StartsWith("✅"))
            {
                user.GameRoomCreation
                .RemoveRole(buttonText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[2]);
            }

            new RolesListGenerator(user.GameRoomCreation.Roles).GenerateMenu()
            .ShowAsync(message.Chat.Id, Bot, user.GameRoomCreation.ToString(), true, message.MessageId);
        }
Exemplo n.º 3
0
        public BotMenu GenerateMenu()
        {
            InlineKeyboardButton[][] keyboard = new InlineKeyboardButton[4][];
            keyboard[0] = new InlineKeyboardButton[]
            {
                !roles.Contains(Roles.Comissar.GetRoleIcon())
                    ? CommandsCenter.GetInlineButton(Roles.Comissar.ToString() + "Add").Button
                    : CommandsCenter.GetInlineButton(Roles.Comissar.ToString() + "Remove").Button
            };
            keyboard[1] = new InlineKeyboardButton[]
            {
                !roles.Contains(Roles.Doctor.GetRoleIcon())
                    ? CommandsCenter.GetInlineButton(Roles.Doctor.ToString() + "Add").Button
                    : CommandsCenter.GetInlineButton(Roles.Doctor.ToString() + "Remove").Button
            };
            keyboard[2] = new InlineKeyboardButton[]
            {
                !roles.Contains(Roles.Maniac.GetRoleIcon())
                    ? CommandsCenter.GetInlineButton(Roles.Maniac.ToString() + "Add").Button
                    : CommandsCenter.GetInlineButton(Roles.Maniac.ToString() + "Remove").Button
            };
            keyboard[3] = new InlineKeyboardButton[]
            {
                CommandsCenter.GetInlineButton("createGame").Button
            };

            return(new InlineMenu("Выберите специальные роли:", keyboard));
        }
Exemplo n.º 4
0
        public BotMenu GenerateMenu()
        {
            InlineKeyboardButton[][] keyboard = new InlineKeyboardButton[games.Length][];

            int i = 0;

            foreach (var game in games)
            {
                keyboard[i++] = new InlineKeyboardButton[]
                {
                    CommandsCenter.GetInlineButton(game.Id.ToString()).Button
                };
            }
            return(new InlineMenu("", keyboard));
        }