mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-21 22:58:05 +00:00
🐛 Fix the exception caused by player or cookie not found
This commit is contained in:
parent
5ecdfc3c09
commit
1525d7cafd
@ -17,7 +17,7 @@ from core.services.users.services import UserService
|
||||
from metadata.genshin import AVATAR_DATA
|
||||
from metadata.shortname import roleToId, roleToName
|
||||
from modules.apihelper.client.components.calendar import Calendar
|
||||
from plugins.tools.genshin import GenshinHelper
|
||||
from plugins.tools.genshin import GenshinHelper, CookiesNotFoundError, PlayerNotFoundError
|
||||
from utils.genshin import fetch_hk4e_token_by_cookie, recognize_genshin_game_biz
|
||||
from utils.log import logger
|
||||
|
||||
@ -147,8 +147,9 @@ class BirthdayPlugin(Plugin):
|
||||
self.add_delete_message_job(message)
|
||||
self.add_delete_message_job(reply_message)
|
||||
return
|
||||
client = await self.helper.get_genshin_client(user.id)
|
||||
if client is None:
|
||||
try:
|
||||
client = await self.helper.get_genshin_client(user.id)
|
||||
except (CookiesNotFoundError, PlayerNotFoundError):
|
||||
buttons = [[InlineKeyboardButton("点我绑定账号", url=create_deep_linked_url(context.bot.username, "set_cookie"))]]
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
reply_msg = await message.reply_text(
|
||||
|
@ -7,7 +7,7 @@ from core.plugin import Plugin
|
||||
from core.services.cookies import CookiesService
|
||||
from modules.apihelper.client.components.verify import Verify
|
||||
from modules.apihelper.error import ResponseException, APIHelperException
|
||||
from plugins.tools.genshin import GenshinHelper, PlayerNotFoundError
|
||||
from plugins.tools.genshin import GenshinHelper, PlayerNotFoundError, CookiesNotFoundError
|
||||
from utils.log import logger
|
||||
|
||||
__all__ = ("ChallengeSystemException", "ChallengeSystem")
|
||||
@ -49,6 +49,8 @@ class ChallengeSystem(Plugin):
|
||||
client = await self.genshin_helper.get_genshin_client(user_id)
|
||||
except PlayerNotFoundError:
|
||||
raise ChallengeSystemException("用户未找到")
|
||||
except CookiesNotFoundError:
|
||||
raise ChallengeSystemException("无需验证")
|
||||
if client.region != Region.CHINESE:
|
||||
raise ChallengeSystemException("非法用户")
|
||||
if need_verify:
|
||||
@ -58,7 +60,7 @@ class ChallengeSystem(Plugin):
|
||||
if exc.retcode != 1034:
|
||||
raise exc
|
||||
else:
|
||||
raise ChallengeSystemException("账户正常,无需认证")
|
||||
raise ChallengeSystemException("账户正常,无需验证")
|
||||
verify = Verify(cookies=client.cookie_manager.cookies)
|
||||
try:
|
||||
data = await verify.create()
|
||||
|
Loading…
Reference in New Issue
Block a user