From e680f8496a78af1a3fc6389c1b69326c63b98a8b Mon Sep 17 00:00:00 2001 From: xtaodada Date: Thu, 18 Jul 2024 20:55:16 +0800 Subject: [PATCH] :bug: Fix wish log auto import error player_id fix #846 --- plugins/genshin/wish_log.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/genshin/wish_log.py b/plugins/genshin/wish_log.py index f3aef331..101380ed 100644 --- a/plugins/genshin/wish_log.py +++ b/plugins/genshin/wish_log.py @@ -200,8 +200,8 @@ class WishLogPlugin(Plugin.Conversation): return True return False - async def gen_authkey(self, uid: int) -> Optional[str]: - player_info = await self.players_service.get_player(uid, region=RegionEnum.HYPERION) + async def gen_authkey(self, uid: int, player_id: int) -> Optional[str]: + player_info = await self.players_service.get_player(uid, region=RegionEnum.HYPERION, player_id=player_id) if player_info is not None: cookies = await self.cookie_service.get(uid, account_id=player_info.account_id) if cookies is not None and cookies.data and "stoken" in cookies.data: @@ -243,7 +243,7 @@ class WishLogPlugin(Plugin.Conversation): await message.reply_text("请发送文件或链接") return INPUT_URL if message.text == "自动导入": - authkey = await self.gen_authkey(user.id) + authkey = await self.gen_authkey(user.id, player_id) if not authkey: await message.reply_text( "自动生成 authkey 失败,请尝试通过其他方式导入。", reply_markup=ReplyKeyboardRemove() @@ -359,10 +359,12 @@ class WishLogPlugin(Plugin.Conversation): @handler.command(command="gacha_log_url", filters=filters.ChatType.PRIVATE, block=False) @handler.message(filters=filters.Regex("^抽卡记录链接(.*)") & filters.ChatType.PRIVATE, block=False) async def command_start_url(self, update: "Update", _: "ContextTypes.DEFAULT_TYPE") -> None: + uid, offset = self.get_real_uid_or_offset(update) message = update.effective_message user = update.effective_user - logger.info("用户 %s[%s] 生成抽卡记录链接命令请求", user.full_name, user.id) - authkey = await self.gen_authkey(user.id) + player_id = await self.get_player_id(user.id, uid, offset) + logger.info("用户 %s[%s] 生成抽卡记录链接命令请求 player_id[%s]", user.full_name, user.id, player_id) + authkey = await self.gen_authkey(user.id, player_id) if not authkey: await message.reply_text("生成失败,仅国服且绑定 stoken 的用户才能生成抽卡记录链接") else: