fix: 修复非第一次登陆情况,已记录的gewechat的appid失效设备不存在导致无法重新登陆的bug
This commit is contained in:
@@ -309,16 +309,22 @@ class SimpleGewechatClient:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self.appid:
|
if self.appid:
|
||||||
|
try:
|
||||||
online = await self.check_online(self.appid)
|
online = await self.check_online(self.appid)
|
||||||
if online:
|
if online:
|
||||||
logger.info(f"APPID: {self.appid} 已在线")
|
logger.info(f"APPID: {self.appid} 已在线")
|
||||||
return
|
return
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"检查在线状态失败: {e}")
|
||||||
|
sp.put(f"gewechat-appid-{self.nickname}", "")
|
||||||
|
self.appid = None
|
||||||
|
|
||||||
payload = {"appId": self.appid}
|
payload = {"appId": self.appid}
|
||||||
|
|
||||||
if self.appid:
|
if self.appid:
|
||||||
logger.info(f"使用 APPID: {self.appid}, {self.nickname}")
|
logger.info(f"使用 APPID: {self.appid}, {self.nickname}")
|
||||||
|
|
||||||
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.post(
|
async with session.post(
|
||||||
f"{self.base_url}/login/getLoginQrCode",
|
f"{self.base_url}/login/getLoginQrCode",
|
||||||
@@ -327,6 +333,13 @@ class SimpleGewechatClient:
|
|||||||
) as resp:
|
) as resp:
|
||||||
json_blob = await resp.json()
|
json_blob = await resp.json()
|
||||||
if json_blob["ret"] != 200:
|
if json_blob["ret"] != 200:
|
||||||
|
error_msg = json_blob.get("data", {}).get("msg", "")
|
||||||
|
if "设备不存在" in error_msg:
|
||||||
|
logger.error(f"检测到无效的appid: {self.appid},将清除并重新登录。")
|
||||||
|
sp.put(f"gewechat-appid-{self.nickname}", "")
|
||||||
|
self.appid = None
|
||||||
|
return await self.login()
|
||||||
|
else:
|
||||||
raise Exception(f"获取二维码失败: {json_blob}")
|
raise Exception(f"获取二维码失败: {json_blob}")
|
||||||
qr_data = json_blob["data"]["qrData"]
|
qr_data = json_blob["data"]["qrData"]
|
||||||
qr_uuid = json_blob["data"]["uuid"]
|
qr_uuid = json_blob["data"]["uuid"]
|
||||||
@@ -335,6 +348,8 @@ class SimpleGewechatClient:
|
|||||||
logger.warning(
|
logger.warning(
|
||||||
f"请打开该网址,然后使用微信扫描二维码登录: https://api.cl2wm.cn/api/qrcode/code?text={qr_data}"
|
f"请打开该网址,然后使用微信扫描二维码登录: https://api.cl2wm.cn/api/qrcode/code?text={qr_data}"
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
raise e
|
||||||
|
|
||||||
# 执行登录
|
# 执行登录
|
||||||
retry_cnt = 64
|
retry_cnt = 64
|
||||||
|
|||||||
Reference in New Issue
Block a user