🎨 Update error handler for UpdatePlugin

This commit is contained in:
洛水居室 2023-02-22 12:55:56 +08:00
parent a7f597708f
commit 9c8def3ce9
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -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)