From 9c8def3ce9a4a1e8b7852d575166c3ff44f62c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Wed, 22 Feb 2023 12:55:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20error=20handler=20for?= =?UTF-8?q?=20`UpdatePlugin`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/update.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/system/update.py b/plugins/system/update.py index 8e58d60f..5c5f0dbe 100644 --- a/plugins/system/update.py +++ b/plugins/system/update.py @@ -4,7 +4,7 @@ from sys import executable from aiofiles import open as async_open from telegram import Update, Message -from telegram.error import BadRequest, Forbidden +from telegram.error import NetworkError from telegram.ext import CallbackContext, CommandHandler from core.bot import bot @@ -37,9 +37,10 @@ class UpdatePlugin(Plugin): try: reply_text = Message.de_json(data, bot.app.bot) await reply_text.edit_text("重启成功") - except (BadRequest, Forbidden, KeyError) as exc: - logger.error("UpdatePlugin 编辑消息出现错误") - logger.exception(exc) + except NetworkError as exc: + logger.error("UpdatePlugin 编辑消息出现错误 %s", exc.message) + except KeyError as exc: + logger.error("UpdatePlugin 编辑消息出现错误", exc_info=exc) os.remove(UPDATE_DATA) @handler(CommandHandler, command="update", block=False)