mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-19 21:38:18 +08:00
Merge pull request #587 from lanvent/dev2
fix: request qrscan when hotreload failed
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
wechat channel
|
wechat channel
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import itchat
|
import itchat
|
||||||
import json
|
import json
|
||||||
from itchat.content import *
|
from itchat.content import *
|
||||||
@@ -50,9 +51,20 @@ class WechatChannel(Channel):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def startup(self):
|
def startup(self):
|
||||||
# login by scan QRCode
|
|
||||||
itchat.auto_login(enableCmdQR=2, hotReload=conf().get('hot_reload', False))
|
|
||||||
|
|
||||||
|
itchat.instance.receivingRetryCount = 600 # 修改断线超时时间
|
||||||
|
# login by scan QRCode
|
||||||
|
hotReload = conf().get('hot_reload', False)
|
||||||
|
try:
|
||||||
|
itchat.auto_login(enableCmdQR=2, hotReload=hotReload)
|
||||||
|
except Exception as e:
|
||||||
|
if hotReload:
|
||||||
|
logger.error("Hot reload failed, try to login without hot reload")
|
||||||
|
itchat.logout()
|
||||||
|
os.remove("itchat.pkl")
|
||||||
|
itchat.auto_login(enableCmdQR=2, hotReload=hotReload)
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
# start message listener
|
# start message listener
|
||||||
itchat.run()
|
itchat.run()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user