Browse Source

Merge pull request #2 from gjwang/master

Fixed syntax error and dependencies on Mac OS
Wons Liu 9 years ago
parent
commit
b606a37403
2 changed files with 8 additions and 8 deletions
  1. 1 0
      README.md
  2. 7 8
      wxbot.py

+ 1 - 0
README.md

@@ -10,6 +10,7 @@ Python包装Web微信实现的微信机器人框架。可以很容易地实现
 ```bash
 pip install requests
 pip install pyqrcode
+pip install pypng
 ```
 
 ## 快速开发

+ 7 - 8
wxbot.py

@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # coding: utf-8
-import qrcode
+from collections import defaultdict
+import pyqrcode
 import requests
 import json
 import xml.dom.minidom
@@ -68,15 +69,13 @@ class WXBot:
 
     def gen_qr_code(self, qr_file_path):
         string = 'https://login.weixin.qq.com/l/' + self.uuid
-        qr = qrcode.QRCode()
-        qr.border = 1
-        qr.add_data(string)
-        qr.make(fit=True)
+        qr = pyqrcode.create(string)
         if self.conf['qr'] == 'png':
-            img = qr.make_image()
-            img.save(qr_file_path)
+            qr.png(qr_file_path)
         elif self.conf['qr'] == 'tty':
-            qr.print_tty()
+            print 'Not support tty'
+            pass
+            #qr.print_tty()
 
     def wait4login(self, tip):
         time.sleep(tip)