🐛 Fix wish log auto import error player_id

fix #846
This commit is contained in:
xtaodada 2024-07-18 20:55:16 +08:00
parent 7946b0b179
commit e680f8496a
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -200,8 +200,8 @@ class WishLogPlugin(Plugin.Conversation):
return True return True
return False return False
async def gen_authkey(self, uid: int) -> Optional[str]: 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_info = await self.players_service.get_player(uid, region=RegionEnum.HYPERION, player_id=player_id)
if player_info is not None: if player_info is not None:
cookies = await self.cookie_service.get(uid, account_id=player_info.account_id) 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: 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("请发送文件或链接") await message.reply_text("请发送文件或链接")
return INPUT_URL return INPUT_URL
if message.text == "自动导入": if message.text == "自动导入":
authkey = await self.gen_authkey(user.id) authkey = await self.gen_authkey(user.id, player_id)
if not authkey: if not authkey:
await message.reply_text( await message.reply_text(
"自动生成 authkey 失败,请尝试通过其他方式导入。", reply_markup=ReplyKeyboardRemove() "自动生成 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.command(command="gacha_log_url", filters=filters.ChatType.PRIVATE, block=False)
@handler.message(filters=filters.Regex("^抽卡记录链接(.*)") & 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: 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 message = update.effective_message
user = update.effective_user user = update.effective_user
logger.info("用户 %s[%s] 生成抽卡记录链接命令请求", user.full_name, user.id) player_id = await self.get_player_id(user.id, uid, offset)
authkey = await self.gen_authkey(user.id) 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: if not authkey:
await message.reply_text("生成失败,仅国服且绑定 stoken 的用户才能生成抽卡记录链接") await message.reply_text("生成失败,仅国服且绑定 stoken 的用户才能生成抽卡记录链接")
else: else: