mirror of
https://github.com/PaiGramTeam/PamGram.git
synced 2024-11-21 13:48:19 +00:00
🎨 Update Handle InvalidCookies
Exception
This commit is contained in:
parent
c927b7b86b
commit
3de0f8beb5
@ -184,7 +184,7 @@ class AvatarListPlugin(Plugin, BasePlugin):
|
||||
|
||||
all_avatars = any(["all" in args, "全部" in args]) # 是否发送全部角色
|
||||
|
||||
logger.info(f"用户 {user.full_name}[{user.id}] [bold]练度统计[/bold]: all={all_avatars}", extra={"markup": True})
|
||||
logger.info("用户 %s[%s] [bold]练度统计[/bold]: all=%s", user.full_name, user.id, all_avatars, extra={"markup": True})
|
||||
|
||||
client = await self.get_user_client(user, message, context)
|
||||
if not client:
|
||||
@ -193,20 +193,25 @@ class AvatarListPlugin(Plugin, BasePlugin):
|
||||
notice = await message.reply_text("派蒙需要收集整理数据,还请耐心等待哦~")
|
||||
await message.reply_chat_action(ChatAction.TYPING)
|
||||
|
||||
characters = await client.get_genshin_characters(client.uid)
|
||||
|
||||
try:
|
||||
characters = await client.get_genshin_characters(client.uid)
|
||||
avatar_datas: List[AvatarData] = await self.get_avatars_data(
|
||||
characters, client, None if all_avatars else 20
|
||||
)
|
||||
except InvalidCookies as e:
|
||||
except InvalidCookies as exc:
|
||||
await notice.delete()
|
||||
raise e
|
||||
await client.get_genshin_user(client.uid)
|
||||
logger.warning("用户 %s[%s] 无法请求角色数数据 API返回信息为 [%s]%s", user.full_name, user.id, exc.retcode, exc.original)
|
||||
reply_message = await message.reply_text("出错了呜呜呜 ~ 当前账号无法请求角色数数据。\n请尝试登录通行证,在账号管理里面选择账号游戏信息,将原神设置为默认角色。")
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
return
|
||||
except GenshinException as e:
|
||||
if e.retcode == -502002:
|
||||
self._add_delete_message_job(context, notice.chat_id, notice.message_id, 5)
|
||||
notice = await message.reply_text("请先在米游社中使用一次<b>养成计算器</b>后再使用此功能~", parse_mode=ParseMode.HTML)
|
||||
self._add_delete_message_job(context, notice.chat_id, notice.message_id, 20)
|
||||
await notice.delete()
|
||||
reply_message = await message.reply_html("请先在米游社中使用一次<b>养成计算器</b>后再使用此功能~")
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 20)
|
||||
return
|
||||
raise e
|
||||
|
||||
@ -246,7 +251,10 @@ class AvatarListPlugin(Plugin, BasePlugin):
|
||||
await image.reply_photo(message)
|
||||
|
||||
logger.info(
|
||||
f"用户 {user.full_name}[{user.id}] [bold]练度统计[/bold]发送{'文件' if all_avatars else '图片'}成功",
|
||||
"用户 %s[%s] [bold]练度统计[/bold]发送%s成功",
|
||||
user.full_name,
|
||||
user.id,
|
||||
"文件" if all_avatars else "图片",
|
||||
extra={"markup": True},
|
||||
)
|
||||
|
||||
|
@ -119,15 +119,20 @@ class Ledger(Plugin, BasePlugin):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
return
|
||||
logger.info(f"用户 {user.full_name}[{user.id}] 查询旅行札记")
|
||||
logger.info("用户 %s[%s] 查询旅行札记", user.full_name, user.id)
|
||||
await message.reply_chat_action(ChatAction.TYPING)
|
||||
try:
|
||||
client = await get_genshin_client(user.id)
|
||||
try:
|
||||
render_result = await self._start_get_ledger(client, month)
|
||||
except InvalidCookies: # 如果抛出InvalidCookies 判断是否真的玄学过期(或权限不足?)
|
||||
except InvalidCookies as exc: # 如果抛出InvalidCookies 判断是否真的玄学过期(或权限不足?)
|
||||
await client.get_genshin_user(client.uid)
|
||||
reply_message = await message.reply_text("出错了呜呜呜 ~ 当前账号无法请求旅行札记数据。")
|
||||
logger.warning(
|
||||
"用户 %s[%s] 无法请求旅行札记数据 API返回信息为 [%s]%s", user.full_name, user.id, exc.retcode, exc.original
|
||||
)
|
||||
reply_message = await message.reply_text(
|
||||
"出错了呜呜呜 ~ 当前账号无法请求旅行札记数据。\n请尝试登录通行证,在账号管理里面选择账号游戏信息,将原神设置为默认角色。"
|
||||
)
|
||||
if filters.ChatType.GROUPS.filter(message):
|
||||
self._add_delete_message_job(context, reply_message.chat_id, reply_message.message_id, 30)
|
||||
self._add_delete_message_job(context, message.chat_id, message.message_id, 30)
|
||||
|
@ -103,7 +103,7 @@ def error_callable(func: Callable) -> Callable:
|
||||
if exc.retcode in (10001, -100):
|
||||
text = "出错了呜呜呜 ~ Cookie 无效,请尝试重新绑定"
|
||||
elif exc.retcode == 10103:
|
||||
text = "出错了呜呜呜 ~ Cookie 有效,但没有绑定到游戏帐户,请尝试重新绑定"
|
||||
text = "出错了呜呜呜 ~ Cookie 有效,但没有绑定到游戏帐户,请尝试登录通行证,在账号管理里面选择账号游戏信息,将原神设置为默认角色。"
|
||||
else:
|
||||
logger.warning("Cookie错误")
|
||||
logger.exception(exc)
|
||||
|
Loading…
Reference in New Issue
Block a user