接入GetLoginStatus增强864登录态判定

This commit is contained in:
liuwei
2026-05-07 15:28:36 +08:00
parent 1d8bf58014
commit 537a3d49e1
3 changed files with 100 additions and 1 deletions

View File

@@ -39,6 +39,24 @@ class UserMixin(Server864APIClientBase):
"""检查 864 当前账号是否在线。"""
del wxid
try:
# 优先使用 864 自己的登录状态接口判断在线态:
# 1. `GetProfile` 在某些版本里会比真实登录态更早失效,容易把“已登录但资料接口异常”误判成未登录;
# 2. 用户当前给出的 `GetLoginStatus` 正是更贴近 server 自身会话状态的一条探针;
# 3. 因此这里先走登录状态接口,只有它也无法确认时,才回退到资料接口兜底。
login_status = await self.get_login_status(auto_login=False)
if self._is_online_from_login_status_payload(login_status):
identity = self._extract_login_identity_from_status(login_status)
if identity.get("wxid"):
self.wxid = identity["wxid"]
if identity.get("nickname"):
self.nickname = identity["nickname"]
if identity.get("alias"):
self.alias = identity["alias"]
if identity.get("phone"):
self.phone = identity["phone"]
if identity.get("signature"):
self.signature = identity["signature"]
return True
await self.get_profile()
return True
except Exception as e: