From c5e5878c5e8ac23c6e071c2209a4ef6798b0449a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 10 Oct 2023 17:55:06 +0800 Subject: [PATCH] :bug: Fix the missing `account_id` field when setting the Cookies --- modules/apihelper/models/genshin/cookies.py | 6 ++++++ plugins/account/cookies.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/apihelper/models/genshin/cookies.py b/modules/apihelper/models/genshin/cookies.py index 7d6845d3..14ee86f8 100644 --- a/modules/apihelper/models/genshin/cookies.py +++ b/modules/apihelper/models/genshin/cookies.py @@ -75,6 +75,12 @@ class CookiesModel(BaseModel): if self.account_id_v2 is None and self.account_mid_v2: self.account_id_v2 = user_id + def set_uid(self, user_id: int): + if self.account_id is None and self.cookie_token: + self.account_id = user_id + if self.ltuid is None and self.ltoken: + self.ltuid = user_id + def check(self) -> bool: """检查Cookies是否完整 :return: 成功返回 True 失败返回 False diff --git a/plugins/account/cookies.py b/plugins/account/cookies.py index a275410c..a52a9cda 100644 --- a/plugins/account/cookies.py +++ b/plugins/account/cookies.py @@ -297,12 +297,15 @@ class AccountCookiesPlugin(Plugin.Conversation): await message.reply_text("Stoken 非法,请重新绑定。", reply_markup=ReplyKeyboardRemove()) return ConversationHandler.END try: - if client.account_id is None and cookies.is_v2: - logger.info("检测到用户 %s[%s] 使用 V2 Cookie 正在尝试获取 account_id", user.full_name, user.id) + if cookies.account_id is None: + logger.info("正在尝试获取用户 %s[%s] account_id", user.full_name, user.id) account_info = await client.get_user_info() account_id = account_info.accident_id account_cookies_plugin_data.account_id = account_id - cookies.set_v2_uid(account_id) + if cookies.is_v2: + cookies.set_v2_uid(account_id) + else: + cookies.set_uid(account_id) logger.success("获取用户 %s[%s] account_id[%s] 成功", user.full_name, user.id, account_id) else: account_cookies_plugin_data.account_id = client.account_id