Add New Authkey Exception for Wish Log

This commit is contained in:
洛水居室 2022-12-28 21:57:40 +08:00
parent 6371db3b5e
commit f5ebe19ff1
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
3 changed files with 17 additions and 2 deletions

View File

@ -14,7 +14,15 @@ class GachaLogAccountNotFound(GachaLogException):
pass
class GachaLogInvalidAuthkey(GachaLogException):
class GachaLogAuthkeyException(GachaLogException):
pass
class GachaLogAuthkeyTimeout(GachaLogAuthkeyException):
pass
class GachaLogInvalidAuthkey(GachaLogAuthkeyException):
pass

View File

@ -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():

View File

@ -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: