From 97257141b2ea399b3910aeb65f3b0f894f88312e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sat, 5 Nov 2022 23:28:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=201034=20GenshinException=20?= =?UTF-8?q?error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/decorators/error.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/utils/decorators/error.py b/utils/decorators/error.py index 461267fa..ba74e23a 100644 --- a/utils/decorators/error.py +++ b/utils/decorators/error.py @@ -17,7 +17,9 @@ from utils.log import logger async def send_user_notification(update: Update, context: CallbackContext, text: str): if update.inline_query is not None: # 忽略 inline_query return - buttons = InlineKeyboardMarkup([[InlineKeyboardButton("点我重新绑定", url=f"https://t.me/{context.bot.username}?start=set_cookie")]]) + buttons = InlineKeyboardMarkup( + [[InlineKeyboardButton("点我重新绑定", url=f"https://t.me/{context.bot.username}?start=set_cookie")]] + ) user = update.effective_user message = update.effective_message chat = update.effective_chat @@ -102,10 +104,14 @@ def error_callable(func: Callable) -> Callable: except GenshinException as exc: if exc.retcode == -130: await send_user_notification(update, context, "出错了呜呜呜 ~ 未设置默认角色,请尝试重新绑定") - return ConversationHandler.END - logger.error("GenshinException") - logger.exception(exc) - await send_user_notification(update, context, f"出错了呜呜呜 ~ 获取账号信息发生错误 错误信息为 {exc.msg} ~ 请稍后再试") + elif exc.retcode == 1034: + await send_user_notification(update, context, "出错了呜呜呜 ~ 服务器检测到该账号可能存在异常,请求被拒绝") + else: + logger.error("GenshinException") + logger.exception(exc) + await send_user_notification( + update, context, f"出错了呜呜呜 ~ 获取账号信息发生错误 错误信息为 { exc.msg if exc.msg else exc.retcode} ~ 请稍后再试" + ) return ConversationHandler.END except ReturnCodeError as exc: await send_user_notification(update, context, f"出错了呜呜呜 ~ API请求错误 错误信息为 {exc.message} ~ 请稍后再试")