From f5ebe19ff1ecfec26b441a3dcebac01c8065603c 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, 28 Dec 2022 21:57:40 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20New=20Authkey=20Exception=20f?= =?UTF-8?q?or=20Wish=20Log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gacha_log/error.py | 10 +++++++++- modules/gacha_log/log.py | 5 ++++- plugins/genshin/gacha/gacha_log.py | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/gacha_log/error.py b/modules/gacha_log/error.py index 38b85fdf..27bd05e6 100644 --- a/modules/gacha_log/error.py +++ b/modules/gacha_log/error.py @@ -14,7 +14,15 @@ class GachaLogAccountNotFound(GachaLogException): pass -class GachaLogInvalidAuthkey(GachaLogException): +class GachaLogAuthkeyException(GachaLogException): + pass + + +class GachaLogAuthkeyTimeout(GachaLogAuthkeyException): + pass + + +class GachaLogInvalidAuthkey(GachaLogAuthkeyException): pass diff --git a/modules/gacha_log/log.py b/modules/gacha_log/log.py index 088a8e88..a72986da 100644 --- a/modules/gacha_log/log.py +++ b/modules/gacha_log/log.py @@ -6,7 +6,7 @@ from pathlib import Path from typing import Dict, IO, List, Optional, Tuple, Union import aiofiles -from genshin import Client, InvalidAuthkey +from genshin import Client, InvalidAuthkey, AuthkeyTimeout from genshin.models import BannerType from openpyxl import load_workbook @@ -22,6 +22,7 @@ from modules.gacha_log.error import ( GachaLogMixedProvider, GachaLogNotFound, PaimonMoeGachaLogFileError, + GachaLogAuthkeyTimeout, ) from modules.gacha_log.models import ( FiveStarItem, @@ -241,6 +242,8 @@ class GachaLog: gacha_log.item_list[pool_name].append(item) temp_id_data[pool_name].append(item.id) new_num += 1 + except AuthkeyTimeout as exc: + raise GachaLogAuthkeyTimeout from exc except InvalidAuthkey as exc: raise GachaLogInvalidAuthkey from exc for i in gacha_log.item_list.values(): diff --git a/plugins/genshin/gacha/gacha_log.py b/plugins/genshin/gacha/gacha_log.py index e36f1509..f277581a 100644 --- a/plugins/genshin/gacha/gacha_log.py +++ b/plugins/genshin/gacha/gacha_log.py @@ -3,6 +3,7 @@ from io import BytesIO import genshin from aiofiles import open as async_open +from genshin import AuthkeyTimeout from genshin.models import BannerType from telegram import Update, User, Message, Document, InlineKeyboardButton, InlineKeyboardMarkup from telegram.constants import ChatAction @@ -26,6 +27,7 @@ from modules.gacha_log.error import ( GachaLogNotFound, GachaLogAccountNotFound, GachaLogMixedProvider, + GachaLogAuthkeyTimeout, ) from modules.gacha_log.helpers import from_url_get_authkey from modules.gacha_log.log import GachaLog @@ -89,6 +91,8 @@ class GachaLogPlugin(Plugin.Conversation, BasePlugin.Conversation): return "导入失败,数据格式错误" except GachaLogInvalidAuthkey: return "更新数据失败,authkey 无效" + except GachaLogAuthkeyTimeout: + return "更新数据失败,authkey 已经过期" except GachaLogMixedProvider: return "导入失败,你已经通过其他方式导入过抽卡记录了,本次无法导入" except UserNotFoundError: