From 598587a74df567c2e9dcca92893ff5ac5c04ba15 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Mon, 13 Mar 2023 20:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Invite=20Bot=20Cannot=20Ex?= =?UTF-8?q?it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/chat_member.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/system/chat_member.py b/plugins/system/chat_member.py index feab54c2..702f7bd8 100644 --- a/plugins/system/chat_member.py +++ b/plugins/system/chat_member.py @@ -1,4 +1,7 @@ +import contextlib + from telegram import Update, Chat, User +from telegram.error import BadRequest from telegram.ext import CallbackContext, ChatMemberHandler from core.admin.services import BotAdminService @@ -85,7 +88,8 @@ class ChatMember(Plugin): else: quit_status = True if quit_status: - await context.bot.send_message(chat.id, "派蒙不想进去!不是旅行者的邀请!") + with contextlib.suppress(BadRequest): + await context.bot.send_message(chat.id, "派蒙不想进去!不是旅行者的邀请!") await context.bot.leave_chat(chat.id) else: await context.bot.send_message(chat.id, "感谢邀请小派蒙到本群!请使用 /help 查看咱已经学会的功能。")