From 6f7d63bdcd6bc760fa83afbafc5ac5d33d2ee694 Mon Sep 17 00:00:00 2001 From: LittleCoder Date: Tue, 27 Jun 2017 16:16:47 +0800 Subject: [PATCH] Add limited warning --- README.md | 2 ++ itchat/components/login.py | 16 +++++++++++++--- itchat/config.py | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 43d6adc..f5ae45f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ itchat.run() 这是一个基于这一项目的[开源小机器人][robot-source-code],百闻不如一见,有兴趣可以尝试一下。 +由于好友数量实在增长过快,自动通过好友验证的功能演示暂时关闭。 + ![QRCode][robot-qr] ## 截屏 diff --git a/itchat/components/login.py b/itchat/components/login.py index 254ed97..086e0d6 100644 --- a/itchat/components/login.py +++ b/itchat/components/login.py @@ -59,7 +59,8 @@ def login(self, enableCmdQR=False, picDir=None, qrCallback=None, break if isLoggedIn: break - logger.info('Log in time out, reloading QR code.') + elif self.isLogging: + logger.info('Log in time out, reloading QR code.') else: return # log in process is stopped by user logger.info('Loading the contact, this may take a little while.') @@ -129,8 +130,10 @@ def check_login(self, uuid=None): regx = r'window.code=(\d+)' data = re.search(regx, r.text) if data and data.group(1) == '200': - process_login_info(self, r.text) - return '200' + if process_login_info(self, r.text): + return '200' + else: + return '400' elif data: return data.group(1) else: @@ -171,6 +174,11 @@ def process_login_info(core, loginContent): core.loginInfo['wxuin'] = core.loginInfo['BaseRequest']['Uin'] = node.childNodes[0].data elif node.nodeName == 'pass_ticket': core.loginInfo['pass_ticket'] = core.loginInfo['BaseRequest']['DeviceID'] = node.childNodes[0].data + if not all([key in core.loginInfo for key in ('skey', 'wxsid', 'wxuin', 'pass_ticket')]): + logger.error('Your wechat account may be LIMITED to log in WEB wechat, error info:\n%s' % r.text) + core.isLogging = False + return False + return True def web_init(self): url = '%s/webwxinit?r=%s' % (self.loginInfo['url'], int(time.time())) @@ -252,6 +260,8 @@ def start_receiving(self, exitCallback=None, getReceivingFnOnly=False): self.msgList.put(chatroomMsg) update_local_friends(self, otherList) retryCount = 0 + except requests.exceptions.ReadTimeout: + pass except: retryCount += 1 logger.error(traceback.format_exc()) diff --git a/itchat/config.py b/itchat/config.py index 173f77a..cc785e7 100644 --- a/itchat/config.py +++ b/itchat/config.py @@ -1,8 +1,8 @@ import os, platform -VERSION = '1.3.7' +VERSION = '1.3.8' BASE_URL = 'https://login.weixin.qq.com' -OS = platform.system() #Windows, Linux, Darwin +OS = platform.system() # Windows, Linux, Darwin DIR = os.getcwd() DEFAULT_QR = 'QR.png' TIMEOUT = (10, 60) -- GitLab