🐛 Fix Invite Bot Cannot Exit

This commit is contained in:
xtaodada 2023-03-13 20:35:22 +08:00
parent 50a9decb0a
commit 598587a74d
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -1,4 +1,7 @@
import contextlib
from telegram import Update, Chat, User from telegram import Update, Chat, User
from telegram.error import BadRequest
from telegram.ext import CallbackContext, ChatMemberHandler from telegram.ext import CallbackContext, ChatMemberHandler
from core.admin.services import BotAdminService from core.admin.services import BotAdminService
@ -85,6 +88,7 @@ class ChatMember(Plugin):
else: else:
quit_status = True quit_status = True
if quit_status: if quit_status:
with contextlib.suppress(BadRequest):
await context.bot.send_message(chat.id, "派蒙不想进去!不是旅行者的邀请!") await context.bot.send_message(chat.id, "派蒙不想进去!不是旅行者的邀请!")
await context.bot.leave_chat(chat.id) await context.bot.leave_chat(chat.id)
else: else: