def restrict_user(update, context): '''禁言用户''' bot = context.bot target_user = update.message.new_chat_members[0] permission = ChatPermissions( can_send_messages=False, can_send_media_messages=False, can_send_polls=False, can_send_other_messages=False, can_add_web_page_previews=False, can_change_info=False, can_invite_users=False, can_pin_messages=False, ) bot.restrict_chat_member( chat_id=update.message.chat_id, user_id=target_user.id, permissions=permission ) bot_print( update, '已禁言用户【' + str(target_user.full_name) + '】' )
def done(update, context): '''结束输入, 开始选择''' global choice_num user_data = context.user_data try: choice_list = random.sample(list(user_data['option_list'].values()), choice_num) choices = '】\n【'.join(choice_list) except: bot_print(update, '你似乎还没输入选项, 小嘤可不笨噢') return ConversationHandler.END message = f'经过深思熟虑, 小嘤建议选择:\n\n【{choices}】' bot_print(update, message) user_data.clear() return ConversationHandler.END
def revoke_restrict_user(update, context): '''解除禁言''' query = update.callback_query bot = context.bot target_user = query.message.reply_to_message.new_chat_members[0] permission = ChatPermissions( can_send_messages=True, can_send_media_messages=True, can_send_polls=True, can_send_other_messages=True, can_add_web_page_previews=True, ) bot.restrict_chat_member( chat_id=query.message.chat_id, user_id=target_user.id, permissions=permission ) bot_print( query, '已将用户【' + str(target_user.full_name) + '】解除禁言' )
def input_options(update, context): '''输入选项''' message = '告诉小嘤你的选项吧, \n格式: 选项1,选项2,...' bot_print(update, message) return TYPING_REPLY
def change_number_info(update, context): '''更改选择数量提示''' message = '想让小嘤帮你选出几个选项?' bot_print(update, message) return CHANGE_NUMBER