🐛 Fix plugin not handling notice correctly in InvalidCookies exception

This commit is contained in:
洛水居室 2022-11-17 16:19:01 +08:00
parent b7d2e1962a
commit 762c9bc907
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC
2 changed files with 6 additions and 1 deletions

View File

@ -4,7 +4,7 @@ from typing import Iterable, List, Optional, Sequence
from arkowrapper import ArkoWrapper from arkowrapper import ArkoWrapper
from enkanetwork import Assets as EnkaAssets, EnkaNetworkAPI from enkanetwork import Assets as EnkaAssets, EnkaNetworkAPI
from genshin import Client, GenshinException from genshin import Client, GenshinException, InvalidCookies
from genshin.models import CalculatorCharacterDetails, CalculatorTalent, Character from genshin.models import CalculatorCharacterDetails, CalculatorTalent, Character
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Message, Update, User from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Message, Update, User
from telegram.constants import ChatAction, ParseMode from telegram.constants import ChatAction, ParseMode
@ -198,6 +198,9 @@ class AvatarListPlugin(Plugin, BasePlugin):
avatar_datas: List[AvatarData] = await self.get_avatars_data( avatar_datas: List[AvatarData] = await self.get_avatars_data(
characters, client, None if all_avatars else 20 characters, client, None if all_avatars else 20
) )
except InvalidCookies as e:
await notice.delete()
raise e
except GenshinException as e: except GenshinException as e:
if e.retcode == -502002: if e.retcode == -502002:
self._add_delete_message_job(context, notice.chat_id, notice.message_id, 5) self._add_delete_message_job(context, notice.chat_id, notice.message_id, 5)

View File

@ -274,6 +274,8 @@ class DailyMaterial(Plugin, BasePlugin):
try: try:
skills = await self._get_skills_data(client, i.gid) skills = await self._get_skills_data(client, i.gid)
i.skills = skills i.skills = skills
except InvalidCookies:
calculator_sync = False
except GenshinException as e: except GenshinException as e:
if e.retcode == -502002: if e.retcode == -502002:
calculator_sync = False # 发现角色养成计算器没启用 设置状态为 False 并防止下次继续获取 calculator_sync = False # 发现角色养成计算器没启用 设置状态为 False 并防止下次继续获取