bot.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:MusicBot 作者: BjoernPetersen 项目源码 文件源码
def ban_user_command(self, bot, update):
        chat_id = update.message.chat_id

        if not config.get_state(_password_enabled_key):
            bot.send_message(chat_id=chat_id, text="Password is disabled")
            return

        if not _clients:
            bot.send_message(chat_id=chat_id, text="No clients logged in")
            return

        text = "Who should be banned?"
        keyboard_items = list(
            map(lambda client: InlineKeyboardButton(text=client.name, callback_data=str(client.user_id)), _clients))

        @decorators.callback_keyboard_answer_handler
        def _action(chat_id, data):
            global _clients
            global _password
            _clients = set(filter(lambda client: str(client.user_id) != data, _clients))
            _password = None
            return "Banned user. Please set a new password."

        self.send_callback_keyboard(bot, chat_id, text, keyboard_items, _action)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号