From 8fff2d64a842a6a8ea2b7e5d462451702255fd7d Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Wed, 17 Aug 2016 10:11:58 +0800 Subject: [PATCH 01/19] add QQ group --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 0bb6a6b..0d30a0b 100644 --- a/README.md +++ b/README.md @@ -264,3 +264,9 @@ python test.py [Urinx/WeixinBot](https://github.com/Urinx/WeixinBot) 网页版微信API,包含终端版微信及微信机器人 [zixia/wechaty](https://github.com/zixia/wechaty) Wechaty is wechat for bot in Javascript(ES6). It's a Personal Account Robot Framework/Library. + +## 7 交流讨论 + +问题可以直接开 **issue** + +**QQ** 交流群: **429134510** From a95b4d056d56fc23f121b84e3484211dd341084e Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Wed, 17 Aug 2016 18:50:14 +0800 Subject: [PATCH 02/19] reformat code --- wxbot.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/wxbot.py b/wxbot.py index c394bb3..3ed0cc8 100644 --- a/wxbot.py +++ b/wxbot.py @@ -542,17 +542,16 @@ def handle_msg(self, r): if msg['MsgType'] == 51: # init message msg_type_id = 0 user['name'] = 'system' - elif msg['MsgType'] == 37:# 有人加好友 ,37为加好友信息? - weixinhao=msg['Content'] - weixinhao=weixinhao[weixinhao.index('fromusername='):weixinhao.index('encryptusername')] - weixinhao=weixinhao[weixinhao.index('"')+1:weixinhao.rindex('"')] - print u'[INFO] 请求加好友!' - print u' 昵称:' + msg['RecommendInfo']['NickName'] - #print u'ID:' + msg['RecommendInfo']['UserName'] - print u' 附加消息:'+msg['RecommendInfo']['Content'] - #print u'Ticket:'+msg['RecommendInfo']['Ticket'] # Ticket添加好友时要用 - print u' 微信号:'+weixinhao #未设置微信号的 腾讯会自动生成一段微信ID 但是无法通过搜索 搜索到此人 - return + elif msg['MsgType'] == 37: # friend request + pass + # content = msg['Content'] + # username = content[content.index('fromusername='): content.index('encryptusername')] + # username = username[username.index('"') + 1: username.rindex('"')] + # print u'[Friend Request]' + # print u' Nickname:' + msg['RecommendInfo']['NickName'] + # print u' 附加消息:'+msg['RecommendInfo']['Content'] + # # print u'Ticket:'+msg['RecommendInfo']['Ticket'] # Ticket添加好友时要用 + # print u' 微信号:'+username #未设置微信号的 腾讯会自动生成一段微信ID 但是无法通过搜索 搜索到此人 elif msg['FromUserName'] == self.my_account['UserName']: # Self msg_type_id = 1 user['name'] = 'self' From 88c815fa4430a89647977b4dbc331663608dde65 Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Wed, 17 Aug 2016 19:20:46 +0800 Subject: [PATCH 03/19] fix null pointer --- wxbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxbot.py b/wxbot.py index 3ed0cc8..5ffeae7 100644 --- a/wxbot.py +++ b/wxbot.py @@ -493,7 +493,7 @@ def extract_msg_content(self, msg_type_id, msg): print ' | desc: %s' % self.search_content('des', content, 'xml') print ' | link: %s' % msg['Url'] print ' | from: %s' % self.search_content('appname', content, 'xml') - print ' | content: %s' % msg.get('content')[:20] + print ' | content: %s' % (msg.get('content')[:20] if msg.get('content') else "unknown") print ' --------------------------' elif mtype == 62: From addc6162624e474049e35f5fc9efa247d677a8bd Mon Sep 17 00:00:00 2001 From: vivre Date: Fri, 26 Aug 2016 22:15:10 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在hand_all_msg中调用即可 #自动通过好友申请 if msg['msg_type_id'] == 37: print json.dumps(msg,indent=4) print self.apply_useradd_requests(msg['content']['data']) #发送消息吧。。。。 --- wxbot.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/wxbot.py b/wxbot.py index 5ffeae7..35dbe5f 100644 --- a/wxbot.py +++ b/wxbot.py @@ -448,6 +448,11 @@ def extract_msg_content(self, msg_type_id, msg): if self.DEBUG: voice = self.get_voice(msg_id) print ' %s[Voice] %s' % (msg_prefix, voice) + elif mtype == 37: + msg_content['type'] = 37 + msg_content['data'] = msg['RecommendInfo'] + if self.DEBUG: + print ' %s[useradd] %s' % (msg_prefix,msg['RecommendInfo']['NickName']) elif mtype == 42: msg_content['type'] = 5 info = msg['RecommendInfo'] @@ -543,6 +548,7 @@ def handle_msg(self, r): msg_type_id = 0 user['name'] = 'system' elif msg['MsgType'] == 37: # friend request + msg_type_id = 37 pass # content = msg['Content'] # username = content[content.index('fromusername='): content.index('encryptusername')] @@ -639,6 +645,33 @@ def proc_msg(self): if check_time < 0.8: time.sleep(1 - check_time) + def apply_useradd_requests(self,RecommendInfo): + url = self.base_uri + '/webwxverifyuser?r='+str(int(time.time()))+'&lang=zh_CN' + params = { + "BaseRequest": self.base_request, + "Opcode": 3, + "VerifyUserListSize": 1, + "VerifyUserList": [ + { + "Value": RecommendInfo['UserName'], + "VerifyUserTicket": RecommendInfo['Ticket'] } + ], + "VerifyContent": "", + "SceneListCount": 1, + "SceneList": [ + 33 + ], + "skey": self.skey + } + headers = {'content-type': 'application/json; charset=UTF-8'} + data = json.dumps(params, ensure_ascii=False).encode('utf8') + try: + r = self.session.post(url, data=data, headers=headers) + except (ConnectionError, ReadTimeout): + return False + dic = r.json() + return dic['BaseResponse']['Ret'] == 0 + def send_msg_by_uid(self, word, dst='filehelper'): url = self.base_uri + '/webwxsendmsg?pass_ticket=%s' % self.pass_ticket msg_id = str(int(time.time() * 1000)) + str(random.random())[:5].replace('.', '') @@ -667,8 +700,8 @@ def upload_media(self, fpath, is_img=False): if not os.path.exists(fpath): print '[ERROR] File not exists.' return None - url_1 = 'https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' - url_2 = 'https://file2.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url_1 = 'https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url_2 = 'https://file2.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' flen = str(os.path.getsize(fpath)) ftype = mimetypes.guess_type(fpath)[0] or 'application/octet-stream' files = { From ea1bda0becb9731ad020d0fd655d79731f19ca2c Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Fri, 26 Aug 2016 22:28:53 +0800 Subject: [PATCH 05/19] change url of upload_media --- wxbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wxbot.py b/wxbot.py index 35dbe5f..8d71dd7 100644 --- a/wxbot.py +++ b/wxbot.py @@ -700,8 +700,8 @@ def upload_media(self, fpath, is_img=False): if not os.path.exists(fpath): print '[ERROR] File not exists.' return None - url_1 = 'https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' - url_2 = 'https://file2.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url_1 = 'https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url_2 = 'https://file2.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' flen = str(os.path.getsize(fpath)) ftype = mimetypes.guess_type(fpath)[0] or 'application/octet-stream' files = { From fae4cf1ec6818665c1317bf1abda736b688c425a Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Sat, 27 Aug 2016 00:18:56 +0800 Subject: [PATCH 06/19] change path for send file and img msg --- wxbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wxbot.py b/wxbot.py index 8d71dd7..0658155 100644 --- a/wxbot.py +++ b/wxbot.py @@ -721,7 +721,7 @@ def upload_media(self, fpath, is_img=False): })), 'webwx_data_ticket': (None, self.session.cookies['webwx_data_ticket']), 'pass_ticket': (None, self.pass_ticket), - 'filename': (os.path.basename(os.path.join(self.temp_pwd,fpath)), open(os.path.join(self.temp_pwd,fpath), 'rb'),ftype.split('/')[1]), + 'filename': (os.path.basename(fpath), open(fpath, 'rb'),ftype.split('/')[1]), } self.file_index += 1 try: @@ -815,7 +815,7 @@ def send_msg(self, name, word, isfile=False): uid = self.get_user_id(name) if uid is not None: if isfile: - with open(os.path.join(self.temp_pwd,word), 'r') as f: + with open(word, 'r') as f: result = True for line in f.readlines(): line = line.replace('\n', '') From faf1a3039f16ce46f6c7146ac80741c22eda0833 Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Sat, 27 Aug 2016 13:15:09 +0800 Subject: [PATCH 07/19] exception fix --- wxbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxbot.py b/wxbot.py index 0658155..69e0ea4 100644 --- a/wxbot.py +++ b/wxbot.py @@ -584,7 +584,7 @@ def handle_msg(self, r): user['name'] = HTMLParser.HTMLParser().unescape(user['name']) if self.DEBUG and msg_type_id != 0: - print '[MSG] %s:' % user['name'] + print u'[MSG] %s:' % user['name'] content = self.extract_msg_content(msg_type_id, msg) message = {'msg_type_id': msg_type_id, 'msg_id': msg['MsgId'], From d7f99d15e5a6f665746c802b1744ca3539c7b36d Mon Sep 17 00:00:00 2001 From: vivre Date: Sat, 27 Aug 2016 15:23:30 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E6=96=B0=E5=A2=9E3=E4=B8=AA=E7=BE=A4?= =?UTF-8?q?=E7=AE=A1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、主动向群内好友打招呼添加好友 2、将好友加入到群聊中 3、将群用户从群中剔除,只有群管理员有权限 --- wxbot.py | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/wxbot.py b/wxbot.py index 69e0ea4..be3a15c 100644 --- a/wxbot.py +++ b/wxbot.py @@ -620,6 +620,10 @@ def proc_msg(self): r = self.sync() if r is not None: self.handle_msg(r) + elif selector == '4': # 通讯录更新 + r = self.sync() + if r is not None: + self.get_contact() elif selector == '6': # 可能是红包 r = self.sync() if r is not None: @@ -672,6 +676,98 @@ def apply_useradd_requests(self,RecommendInfo): dic = r.json() return dic['BaseResponse']['Ret'] == 0 + def add_groupuser_to_friend_by_uid(self,uid,VerifyContent): + """ + 主动向群内人员打招呼,提交添加好友请求 + uid-群内人员得uid VerifyContent-好友招呼内容 + 慎用此接口!封号后果自负!慎用此接口!封号后果自负!慎用此接口!封号后果自负! + """ + if self.is_contact(uid): + return True + url = self.base_uri + '/webwxverifyuser?r='+str(int(time.time()))+'&lang=zh_CN' + params ={ + "BaseRequest": self.base_request, + "Opcode": 2, + "VerifyUserListSize": 1, + "VerifyUserList": [ + { + "Value": uid, + "VerifyUserTicket": "" + } + ], + "VerifyContent": VerifyContent, + "SceneListCount": 1, + "SceneList": [ + 33 + ], + "skey": self.skey + } + headers = {'content-type': 'application/json; charset=UTF-8'} + data = json.dumps(params, ensure_ascii=False).encode('utf8') + try: + r = self.session.post(url, data=data, headers=headers) + except (ConnectionError, ReadTimeout): + return False + dic = r.json() + return dic['BaseResponse']['Ret'] == 0 + + def add_friend_to_group(self,uid,group_name): + """ + 将好友加入到群聊中 + """ + gid = '' + #通过群名获取群id,群没保存到通讯录中的话无法添加哦 + for group in self.group_list: + if group['NickName'] == group_name: + gid = group['UserName'] + if gid == '': + return False + #通过群id判断uid是否在群中 + for user in self.group_members[gid]: + if user['UserName'] == uid: + #已经在群里面了,不用加了 + return True + url = self.base_uri + '/webwxupdatechatroom?fun=addmember&pass_ticket=%s' % self.pass_ticket + params ={ + "AddMemberList": uid, + "ChatRoomName": gid, + "BaseRequest": self.base_request + } + headers = {'content-type': 'application/json; charset=UTF-8'} + data = json.dumps(params, ensure_ascii=False).encode('utf8') + try: + r = self.session.post(url, data=data, headers=headers) + except (ConnectionError, ReadTimeout): + return False + dic = r.json() + return dic['BaseResponse']['Ret'] == 0 + + def delete_user_from_group(self,uname,gid): + """ + 将群用户从群中剔除,只有群管理员有权限 + """ + uid = "" + for user in self.group_members[gid]: + if user['NickName'] == uname: + uid = user['UserName'] + if uid == "": + return False + url = self.base_uri + '/webwxupdatechatroom?fun=delmember&pass_ticket=%s' % self.pass_ticket + params ={ + "DelMemberList": uid, + "ChatRoomName": gid, + "BaseRequest": self.base_request + } + headers = {'content-type': 'application/json; charset=UTF-8'} + data = json.dumps(params, ensure_ascii=False).encode('utf8') + try: + r = self.session.post(url, data=data, headers=headers) + except (ConnectionError, ReadTimeout): + return False + dic = r.json() + return dic['BaseResponse']['Ret'] == 0 + + def send_msg_by_uid(self, word, dst='filehelper'): url = self.base_uri + '/webwxsendmsg?pass_ticket=%s' % self.pass_ticket msg_id = str(int(time.time() * 1000)) + str(random.random())[:5].replace('.', '') From e954cafb832f42067466aa4c447df779f4a573e9 Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Thu, 29 Sep 2016 17:21:11 +0800 Subject: [PATCH 09/19] update README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d30a0b..d846902 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,14 @@ Web微信协议参考资料: [qwx: WeChat Qt frontend 微信Qt前端](https://github.com/xiangzhai/qwx) +**master-dev 分支为开发版本,用于测试新特性,欢迎使用后提出建议!** + ## 1 环境与依赖 此版本只能运行于Python 2环境 。 -**wxBot** 用到了Python **requests** , **pypng** , **Pillow* 以及 **pyqrcode** 库。 +**wxBot** 用到了Python **requests** , **pypng** , **Pillow** 以及 **pyqrcode** 库。 使用之前需要所依赖的库: From c949109325b6811843523b23b47918b352d4b4a7 Mon Sep 17 00:00:00 2001 From: liuwangsheng01 Date: Tue, 11 Oct 2016 11:57:59 +0800 Subject: [PATCH 10/19] change push url and file upload url --- wxbot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wxbot.py b/wxbot.py index be3a15c..ee3128f 100644 --- a/wxbot.py +++ b/wxbot.py @@ -796,8 +796,8 @@ def upload_media(self, fpath, is_img=False): if not os.path.exists(fpath): print '[ERROR] File not exists.' return None - url_1 = 'https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' - url_2 = 'https://file2.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url_1 = 'https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' + url_2 = 'https://file2.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json' flen = str(os.path.getsize(fpath)) ftype = mimetypes.guess_type(fpath)[0] or 'application/octet-stream' files = { @@ -1133,7 +1133,7 @@ def sync_check(self): 'synckey': self.sync_key_str, '_': int(time.time()), } - url = 'https://' + self.sync_host + '.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?' + urllib.urlencode(params) + url = 'https://' + self.sync_host + '.wx.qq.com/cgi-bin/mmwebwx-bin/synccheck?' + urllib.urlencode(params) try: r = self.session.get(url, timeout=60) r.encoding = 'utf-8' From 7db6de7b9efcec059c5fdb7476eca8ab9e7f8227 Mon Sep 17 00:00:00 2001 From: vivre Date: Wed, 12 Oct 2016 15:08:59 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D1102=EF=BC=8C0=E5=92=8C?= =?UTF-8?q?-1=EF=BC=8C-1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_sync_check函数完善,将4个服务器地址均放进去检测,得到合适的心跳服务器地址 --- wxbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wxbot.py b/wxbot.py index ee3128f..abea7fe 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1116,7 +1116,7 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host in ['webpush', 'webpush2']: + for host in ['webpush.wx', 'webpush2.wx','webpush.weixin', 'webpush2.weixin2',]: self.sync_host = host retcode = self.sync_check()[0] if retcode == '0': @@ -1133,7 +1133,7 @@ def sync_check(self): 'synckey': self.sync_key_str, '_': int(time.time()), } - url = 'https://' + self.sync_host + '.wx.qq.com/cgi-bin/mmwebwx-bin/synccheck?' + urllib.urlencode(params) + url = 'https://' + self.sync_host + '.qq.com/cgi-bin/mmwebwx-bin/synccheck?' + urllib.urlencode(params) try: r = self.session.get(url, timeout=60) r.encoding = 'utf-8' From 5c74dbd47566a238f555b7a48a792a58b555d0e9 Mon Sep 17 00:00:00 2001 From: vivre Date: Wed, 12 Oct 2016 15:15:52 +0800 Subject: [PATCH 12/19] fix bug fix bug --- wxbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxbot.py b/wxbot.py index abea7fe..c813dae 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1116,7 +1116,7 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host in ['webpush.wx', 'webpush2.wx','webpush.weixin', 'webpush2.weixin2',]: + for host in ['webpush.wx', 'webpush2.wx','webpush.weixin', 'webpush2.weixin2']: self.sync_host = host retcode = self.sync_check()[0] if retcode == '0': From b60084e4c978fa6df3ac9bc666ae57e23fa4947d Mon Sep 17 00:00:00 2001 From: vivre Date: Wed, 12 Oct 2016 15:54:24 +0800 Subject: [PATCH 13/19] fix bugs fix bugs --- wxbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wxbot.py b/wxbot.py index c813dae..b4d6a61 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1116,9 +1116,12 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host in ['webpush.wx', 'webpush2.wx','webpush.weixin', 'webpush2.weixin2']: + for host in ['webpush.wx', 'webpush2.wx2','webpush.weixin', 'webpush2.weixin2']: self.sync_host = host - retcode = self.sync_check()[0] + try: + retcode = self.sync_check()[0] + except: + retcode == -1 if retcode == '0': return True return False From d8907994ae1f25d650576a5323612db2259161fb Mon Sep 17 00:00:00 2001 From: vivre Date: Wed, 12 Oct 2016 17:57:38 +0800 Subject: [PATCH 14/19] =?UTF-8?q?test=5Fsync=5Fcheck=20=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_sync_check 兼容 --- wxbot.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/wxbot.py b/wxbot.py index b4d6a61..c7413be 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1116,14 +1116,15 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host in ['webpush.wx', 'webpush2.wx2','webpush.weixin', 'webpush2.weixin2']: - self.sync_host = host - try: - retcode = self.sync_check()[0] - except: - retcode == -1 - if retcode == '0': - return True + for host1 in ['webpush', 'webpush2']: + for host2 in ['weixin','weixin2','wx','wx2']: + self.sync_host = host1+host2 + try: + retcode = self.sync_check()[0] + except: + retcode == -1 + if retcode == '0': + return True return False def sync_check(self): From 51c37e02b3127a91e9e789cec5a6961c5ba1568b Mon Sep 17 00:00:00 2001 From: vivre Date: Wed, 12 Oct 2016 18:01:19 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E5=85=BC=E5=AE=B9sync=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B31102=EF=BC=8C0=E5=92=8C-1=EF=BC=8C-1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 兼容sync,解决1102,0和-1,-1问题 --- wxbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxbot.py b/wxbot.py index c7413be..66ca144 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1116,7 +1116,7 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host1 in ['webpush', 'webpush2']: + for host1 in ['webpush.', 'webpush2.']: for host2 in ['weixin','weixin2','wx','wx2']: self.sync_host = host1+host2 try: From b09cd76e2ce7b09b06d8eedf74d2ed98995e0177 Mon Sep 17 00:00:00 2001 From: vivre Date: Wed, 12 Oct 2016 19:01:20 +0800 Subject: [PATCH 16/19] fix --- wxbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wxbot.py b/wxbot.py index 66ca144..50f724a 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1118,7 +1118,7 @@ def status_notify(self): def test_sync_check(self): for host1 in ['webpush.', 'webpush2.']: for host2 in ['weixin','weixin2','wx','wx2']: - self.sync_host = host1+host2 + self.sync_host = host1+host2 try: retcode = self.sync_check()[0] except: From 3be2338f8b79576bf99dc7b5267213c30e067680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=C5=A9=C3=F1?= <1741159138@qq.com> Date: Thu, 13 Oct 2016 13:37:12 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D1120=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=20=E5=90=8C=E6=AD=A5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxbot.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/wxbot.py b/wxbot.py index 50f724a..79b1828 100644 --- a/wxbot.py +++ b/wxbot.py @@ -1116,15 +1116,11 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host1 in ['webpush.', 'webpush2.']: - for host2 in ['weixin','weixin2','wx','wx2']: - self.sync_host = host1+host2 - try: - retcode = self.sync_check()[0] - except: - retcode == -1 - if retcode == '0': - return True + for host in ['webpush.wx2']: + self.sync_host = host + retcode = self.sync_check()[0] + if retcode == '0': + return True return False def sync_check(self): @@ -1195,7 +1191,7 @@ def get_head_img(self, uid): url = self.base_uri + '/webwxgetheadimg?username=%s&skey=%s' % (uid, self.skey) r = self.session.get(url) data = r.content - fn = 'head_' + uid + '.jpg' + fn = '/group/head_' + uid + '.jpg' with open(os.path.join(self.temp_pwd,fn), 'wb') as f: f.write(data) return fn @@ -1250,3 +1246,4 @@ def set_remarkname(self,uid,remarkname):#设置联系人的备注名 return dic['BaseResponse']['ErrMsg'] except: return None + From 23a412d8c5d37f70cf6758ed56795d3ca53072b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=C5=A9=C3=F1?= <1741159138@qq.com> Date: Thu, 13 Oct 2016 16:17:14 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=9A=E5=8F=B7?= =?UTF-8?q?=E7=99=BB=E9=99=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxbot.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 wxbot.py diff --git a/wxbot.py b/wxbot.py old mode 100644 new mode 100755 index 79b1828..29f5826 --- a/wxbot.py +++ b/wxbot.py @@ -1116,12 +1116,15 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host in ['webpush.wx2']: - self.sync_host = host - retcode = self.sync_check()[0] - if retcode == '0': - return True - return False + for host1 in ['webpush', 'webpush2']: + for host2 in ['weixin','weixin2','wx','wx2']: + self.sync_host = host1+host2 + try: + retcode = self.sync_check()[0] + except: + retcode == -1 + if retcode == '0': + return True def sync_check(self): params = { @@ -1191,7 +1194,7 @@ def get_head_img(self, uid): url = self.base_uri + '/webwxgetheadimg?username=%s&skey=%s' % (uid, self.skey) r = self.session.get(url) data = r.content - fn = '/group/head_' + uid + '.jpg' + fn = 'head_' + uid + '.jpg' with open(os.path.join(self.temp_pwd,fn), 'wb') as f: f.write(data) return fn From 55954dbf8b9b701ea8735070d759b6a58eaef983 Mon Sep 17 00:00:00 2001 From: sixian67 <1741159138@qq.com> Date: Thu, 13 Oct 2016 16:41:43 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=92=88=E5=AF=B9?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E8=B4=A6=E5=8F=B7=E8=B7=9F=E8=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wxbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wxbot.py b/wxbot.py index 29f5826..69f938c 100755 --- a/wxbot.py +++ b/wxbot.py @@ -1116,8 +1116,8 @@ def status_notify(self): return dic['BaseResponse']['Ret'] == 0 def test_sync_check(self): - for host1 in ['webpush', 'webpush2']: - for host2 in ['weixin','weixin2','wx','wx2']: + for host1 in ['webpush.', 'webpush2.']: + for host2 in ['weixin','wx','wx2']: self.sync_host = host1+host2 try: retcode = self.sync_check()[0]