From 7b62d86f46ce91f86d406902f6610b88e09b3ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 14 Mar 2023 13:53:05 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=20to=20schedule=20for=20dele?= =?UTF-8?q?tion=20after=20sending=20exception=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/errorhandler.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/system/errorhandler.py b/plugins/system/errorhandler.py index 6fbb1e5b..2a62b2ef 100644 --- a/plugins/system/errorhandler.py +++ b/plugins/system/errorhandler.py @@ -10,7 +10,7 @@ from httpx import HTTPError, TimeoutException from telegram import ReplyKeyboardRemove, Update, InlineKeyboardMarkup, InlineKeyboardButton from telegram.constants import ParseMode from telegram.error import BadRequest, Forbidden, TelegramError, TimedOut, NetworkError -from telegram.ext import CallbackContext, ApplicationHandlerStop +from telegram.ext import CallbackContext, ApplicationHandlerStop, filters from telegram.helpers import create_deep_linked_url from core.config import config @@ -83,8 +83,10 @@ class ErrorHandler(Plugin): try: if update.callback_query: await update.callback_query.answer(content, show_alert=True) - return None - return await message.reply_text(content, reply_markup=buttons, allow_sending_without_reply=True) + reply_text = await message.reply_text(content, reply_markup=buttons, allow_sending_without_reply=True) + if filters.ChatType.GROUPS.filter(reply_text): + self.add_delete_message_job(reply_text, context=context) + self.add_delete_message_job(message, context=context) except TelegramError as exc: logger.error(self.SEND_MSG_ERROR_NOTICE, update.update_id, exc.message) except Exception as exc: