🐛 Fix the missing account_id field when setting the Cookies

This commit is contained in:
洛水居室 2023-10-10 17:55:06 +08:00 committed by xtaodada
parent f801857884
commit c2535d01e9
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 12 additions and 3 deletions

View File

@ -75,6 +75,12 @@ class CookiesModel(BaseModel):
if self.account_id_v2 is None and self.account_mid_v2: if self.account_id_v2 is None and self.account_mid_v2:
self.account_id_v2 = user_id 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: def check(self) -> bool:
"""检查Cookies是否完整 """检查Cookies是否完整
:return: 成功返回 True 失败返回 False :return: 成功返回 True 失败返回 False

View File

@ -297,12 +297,15 @@ class AccountCookiesPlugin(Plugin.Conversation):
await message.reply_text("Stoken 非法,请重新绑定。", reply_markup=ReplyKeyboardRemove()) await message.reply_text("Stoken 非法,请重新绑定。", reply_markup=ReplyKeyboardRemove())
return ConversationHandler.END return ConversationHandler.END
try: try:
if client.account_id is None and cookies.is_v2: if cookies.account_id is None:
logger.info("检测到用户 %s[%s] 使用 V2 Cookie 正在尝试获取 account_id", user.full_name, user.id) logger.info("正在尝试获取用户 %s[%s] account_id", user.full_name, user.id)
account_info = await client.get_user_info() account_info = await client.get_user_info()
account_id = account_info.accident_id account_id = account_info.accident_id
account_cookies_plugin_data.account_id = account_id account_cookies_plugin_data.account_id = account_id
if cookies.is_v2:
cookies.set_v2_uid(account_id) 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) logger.success("获取用户 %s[%s] account_id[%s] 成功", user.full_name, user.id, account_id)
else: else:
account_cookies_plugin_data.account_id = client.account_id account_cookies_plugin_data.account_id = client.account_id