From 9b47e2d6f922cb1caa58a40bde058d33763bfab3 Mon Sep 17 00:00:00 2001 From: lanvent Date: Wed, 26 Apr 2023 22:54:53 +0800 Subject: [PATCH] fix: output itchat error msg rightly --- lib/itchat/components/login.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/itchat/components/login.py b/lib/itchat/components/login.py index 60ca395..3a359ee 100644 --- a/lib/itchat/components/login.py +++ b/lib/itchat/components/login.py @@ -195,13 +195,17 @@ def process_login_info(core, loginContent): core.loginInfo['logintime'] = int(time.time() * 1e3) core.loginInfo['BaseRequest'] = {} cookies = core.s.cookies.get_dict() - skey = re.findall('(.*?)', r.text, re.S)[0] - pass_ticket = re.findall( - '(.*?)', r.text, re.S)[0] - core.loginInfo['skey'] = core.loginInfo['BaseRequest']['Skey'] = skey + res = re.findall('(.*?)', r.text, re.S) + skey = res[0] if res else None + res = re.findall( + '(.*?)', r.text, re.S) + pass_ticket = res[0] if res else None + if skey is not None: + core.loginInfo['skey'] = core.loginInfo['BaseRequest']['Skey'] = skey core.loginInfo['wxsid'] = core.loginInfo['BaseRequest']['Sid'] = cookies["wxsid"] core.loginInfo['wxuin'] = core.loginInfo['BaseRequest']['Uin'] = cookies["wxuin"] - core.loginInfo['pass_ticket'] = pass_ticket + if pass_ticket is not None: + core.loginInfo['pass_ticket'] = pass_ticket # A question : why pass_ticket == DeviceID ? # deviceID is only a randomly generated number