Browse Source

修复bug

liuyuqi-dellpc 8 years ago
parent
commit
d8db150ee9
3 changed files with 6 additions and 4 deletions
  1. 1 1
      bot.py
  2. 1 1
      test.py
  3. 4 2
      wxbot.py

+ 1 - 1
bot.py

@@ -94,7 +94,7 @@ class TulingWXBot(WXBot):
                         reply += u"对不起,只认字,其他杂七杂八的我都不认识,,,Ծ‸Ծ,,"
                         reply += u"对不起,只认字,其他杂七杂八的我都不认识,,,Ծ‸Ծ,,"
                     self.send_msg_by_uid(reply, msg['user']['id'])
                     self.send_msg_by_uid(reply, msg['user']['id'])
         else:
         else:
-            src_name = msg['content']['user']['name']
+            src_name = msg['user']['name']
             reply = 'to ' + src_name + ': '
             reply = 'to ' + src_name + ': '
             reply += u"对不起,只认字,其他杂七杂八的我都不认识,,,Ծ‸Ծ,,"
             reply += u"对不起,只认字,其他杂七杂八的我都不认识,,,Ծ‸Ծ,,"
             self.send_msg_by_uid(reply, msg['user']['id'])
             self.send_msg_by_uid(reply, msg['user']['id'])

+ 1 - 1
test.py

@@ -3,7 +3,7 @@
 
 
 from wxbot import *
 from wxbot import *
 
 
-
+#MyWXBot继承WXBot类
 class MyWXBot(WXBot):
 class MyWXBot(WXBot):
     def handle_msg_all(self, msg):
     def handle_msg_all(self, msg):
         if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:
         if msg['msg_type_id'] == 4 and msg['content']['type'] == 0:

+ 4 - 2
wxbot.py

@@ -1121,7 +1121,7 @@ class WXBot:
             print '[INFO] Get %d contacts' % len(self.contact_list)
             print '[INFO] Get %d contacts' % len(self.contact_list)
             print '[INFO] Start to process messages .'
             print '[INFO] Start to process messages .'
         self.proc_msg()
         self.proc_msg()
-
+#第一步:获取uuid
     def get_uuid(self):
     def get_uuid(self):
         url = 'https://login.weixin.qq.com/jslogin'
         url = 'https://login.weixin.qq.com/jslogin'
         params = {
         params = {
@@ -1133,6 +1133,7 @@ class WXBot:
         r = self.session.get(url, params=params)
         r = self.session.get(url, params=params)
         r.encoding = 'utf-8'
         r.encoding = 'utf-8'
         data = r.text
         data = r.text
+        #window.QRLogin.code = 200; window.QRLogin.uuid = "AfJkWJ4bxg==";
         regx = r'window.QRLogin.code = (\d+); window.QRLogin.uuid = "(\S+?)"'
         regx = r'window.QRLogin.code = (\d+); window.QRLogin.uuid = "(\S+?)"'
         pm = re.search(regx, data)
         pm = re.search(regx, data)
         if pm:
         if pm:
@@ -1140,7 +1141,7 @@ class WXBot:
             self.uuid = pm.group(2)
             self.uuid = pm.group(2)
             return code == '200'
             return code == '200'
         return False
         return False
-
+#第二步:拼凑二维码链接
     def gen_qr_code(self, qr_file_path):
     def gen_qr_code(self, qr_file_path):
         string = 'https://login.weixin.qq.com/l/' + self.uuid
         string = 'https://login.weixin.qq.com/l/' + self.uuid
         qr = pyqrcode.create(string)
         qr = pyqrcode.create(string)
@@ -1168,6 +1169,7 @@ class WXBot:
                408: timeout
                408: timeout
         tip=0, 等待用户确认登录,
         tip=0, 等待用户确认登录,
                200: confirmed
                200: confirmed
+               https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true&uuid=YeCkBn4EEg==&tip=0&r=-301174534&_=1482064866062
         """
         """
         LOGIN_TEMPLATE = 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s'
         LOGIN_TEMPLATE = 'https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?tip=%s&uuid=%s&_=%s'
         tip = 1
         tip = 1