fix(itchat): add error log when hot reload fails and log out before logging in normally

This commit is contained in:
lanvent
2023-04-27 02:46:53 +08:00
parent 9b47e2d6f9
commit 527d5e1dbc
3 changed files with 10 additions and 17 deletions

View File

@@ -367,7 +367,7 @@ def sync_check(self):
regx = r'window.synccheck={retcode:"(\d+)",selector:"(\d+)"}'
pm = re.search(regx, r.text)
if pm is None or pm.group(1) != '0':
logger.debug('Unexpected sync check result: %s' % r.text)
logger.error('Unexpected sync check result: %s' % r.text)
return None
return pm.group(2)

View File

@@ -25,9 +25,11 @@ def auto_login(self, hotReload=False, statusStorageDir='itchat.pkl',
self.useHotReload = hotReload
self.hotReloadDir = statusStorageDir
if hotReload:
if self.load_login_status(statusStorageDir,
if rval:=self.load_login_status(statusStorageDir,
loginCallback=loginCallback, exitCallback=exitCallback):
return
logger.error('hot reload failed, logging in normally, {}'.format(rval))
self.logout()
self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback,
loginCallback=loginCallback, exitCallback=exitCallback)
self.dump_login_status(statusStorageDir)