diff --git a/modules/gacha_log/error.py b/modules/gacha_log/error.py index 38b85fd..27bd05e 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 088a8e8..a72986d 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 e36f150..f277581 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: