From 974157d35cc82e0d3859d692d4c77c6bf51e8c2d 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 Feb 2023 15:13:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Handling=20Genshin=20Exception?= =?UTF-8?q?=20Return=20Code=20-501101?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/reg_time.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/genshin/reg_time.py b/plugins/genshin/reg_time.py index 821a2d37..b43da2dd 100644 --- a/plugins/genshin/reg_time.py +++ b/plugins/genshin/reg_time.py @@ -1,7 +1,7 @@ from datetime import datetime -from genshin import Client +from genshin import Client, GenshinException from genshin.client.routes import InternationalRoute # noqa F401 from genshin.utility import recognize_genshin_server, get_ds_headers from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup @@ -107,6 +107,11 @@ class RegTimePlugin(Plugin, BasePlugin): parse_mode=ParseMode.HTML, reply_markup=InlineKeyboardMarkup(buttons), ) + except GenshinException as exc: + if exc.retcode == -501101: + await message.reply_text("当前角色冒险等阶未达到10级,暂时无法获取信息") + else: + raise exc except RegTimePlugin.NotFoundRegTimeError: await message.reply_text("未找到你的原神账号 [{game_uid}] 注册时间,仅限 2022 年 10 月 之前注册的账号")