From 24ce0dac92e6e30a532aec247f4f31c4b3740953 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, 7 Jan 2023 15:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Add=20Handle=201034=20Error=20Ra?= =?UTF-8?q?ised=20by=20Public=20Query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/abyss.py | 8 +++++++- plugins/genshin/userstats.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/genshin/abyss.py b/plugins/genshin/abyss.py index 4273e8d9..5066680a 100644 --- a/plugins/genshin/abyss.py +++ b/plugins/genshin/abyss.py @@ -7,7 +7,7 @@ from typing import Any, Coroutine, List, Match, Optional, Tuple, Union import ujson as json from arkowrapper import ArkoWrapper -from genshin import Client +from genshin import Client, GenshinException from pytz import timezone from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Message, Update from telegram.constants import ChatAction, ParseMode @@ -169,6 +169,12 @@ class Abyss(Plugin, BasePlugin): try: images = await self.get_rendered_pic(client, uid, floor, total, previous) + except GenshinException as exc: + if exc.retcode == 1034: + if client.uid != uid: + await message.reply_text("出错了呜呜呜 ~ 请稍后重试") + return + raise exc except AbyssUnlocked: # 若深渊未解锁 await reply_message_func("还未解锁深渊哦~") return diff --git a/plugins/genshin/userstats.py b/plugins/genshin/userstats.py index f6c1c526..c92a8aed 100644 --- a/plugins/genshin/userstats.py +++ b/plugins/genshin/userstats.py @@ -1,7 +1,7 @@ import random from typing import Optional -from genshin import Client +from genshin import Client, GenshinException from genshin.models import GenshinUserStats from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup from telegram.constants import ChatAction @@ -66,6 +66,12 @@ class UserStatsPlugins(Plugin, BasePlugin): else: await message.reply_text("未查询到您所绑定的账号信息,请先绑定账号", reply_markup=InlineKeyboardMarkup(buttons)) return + except GenshinException as exc: + if exc.retcode == 1034: + if uid: + await message.reply_text("出错了呜呜呜 ~ 请稍后重试") + return + raise exc except TooManyRequestPublicCookies: await message.reply_text("用户查询次数过多 请稍后重试") return