接入GetLoginStatus增强864登录态判定
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user