@@ -59,7 +59,8 @@ def login(self, enableCmdQR=False, picDir=None, qrCallback=None,
5959 break
6060 if isLoggedIn :
6161 break
62- logger .info ('Log in time out, reloading QR code.' )
62+ elif self .isLogging :
63+ logger .info ('Log in time out, reloading QR code.' )
6364 else :
6465 return # log in process is stopped by user
6566 logger .info ('Loading the contact, this may take a little while.' )
@@ -129,8 +130,10 @@ def check_login(self, uuid=None):
129130 regx = r'window.code=(\d+)'
130131 data = re .search (regx , r .text )
131132 if data and data .group (1 ) == '200' :
132- process_login_info (self , r .text )
133- return '200'
133+ if process_login_info (self , r .text ):
134+ return '200'
135+ else :
136+ return '400'
134137 elif data :
135138 return data .group (1 )
136139 else :
@@ -171,6 +174,11 @@ def process_login_info(core, loginContent):
171174 core .loginInfo ['wxuin' ] = core .loginInfo ['BaseRequest' ]['Uin' ] = node .childNodes [0 ].data
172175 elif node .nodeName == 'pass_ticket' :
173176 core .loginInfo ['pass_ticket' ] = core .loginInfo ['BaseRequest' ]['DeviceID' ] = node .childNodes [0 ].data
177+ if not all ([key in core .loginInfo for key in ('skey' , 'wxsid' , 'wxuin' , 'pass_ticket' )]):
178+ logger .error ('Your wechat account may be LIMITED to log in WEB wechat, error info:\n %s' % r .text )
179+ core .isLogging = False
180+ return False
181+ return True
174182
175183def web_init (self ):
176184 url = '%s/webwxinit?r=%s' % (self .loginInfo ['url' ], int (time .time ()))
@@ -252,6 +260,8 @@ def maintain_loop():
252260 self .msgList .put (chatroomMsg )
253261 update_local_friends (self , otherList )
254262 retryCount = 0
263+ except requests .exceptions .ReadTimeout :
264+ pass
255265 except :
256266 retryCount += 1
257267 logger .error (traceback .format_exc ())
0 commit comments