Skip to content

Commit b4ed619

Browse files
committed
EWS: Catch up with itchat 1.2.24 update
1 parent 38d5d63 commit b4ed619

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

plugins/eh_wechat_slave.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import itchat
1212
import magic
1313
import xmltodict
14+
from pyqrcode import QRCode
1415
from PIL import Image
1516

1617
import config
@@ -145,16 +146,8 @@ def console_qr_code(self, uuid, status, qrcode):
145146
if status == 408:
146147
QR += "Previous code expired. Please scan the new one.\n"
147148
QR += "\n"
148-
time.sleep(0.5)
149-
img = Image.open(io.BytesIO(qrcode)).convert("1")
150-
img = img.resize((img.size[0] // 10, img.size[1] // 10))
151-
for i in range(img.size[0]):
152-
for j in range(img.size[1]):
153-
if img.getpixel((i, j)) > 0:
154-
QR += "\x1b[7m \x1b[0m"
155-
else:
156-
QR += "\x1b[49m \x1b[0m"
157-
QR += "\n"
149+
qr_url = "https://login.weixin.qq.com/l/" + uuid
150+
QR += QRCode(qr_url).terminal()
158151
QR += "\nIf you cannot read the QR code above, " \
159152
"please visit the following URL:\n" \
160153
"https://login.weixin.qq.com/qrcode/" + uuid
@@ -184,8 +177,8 @@ def master_qr_code(self, uuid, status, qrcode):
184177
os.makedirs(path)
185178
path = os.path.join(path, 'QR-%s.jpg' % int(time.time()))
186179
self.logger.debug("master_qr_code file path: %s", path)
187-
with open(path, 'wb') as f:
188-
f.write(qrcode)
180+
qr_url = "https://login.weixin.qq.com/l/" + uuid
181+
QRCode(qr_url).png(path, scale=10)
189182
msg.text = 'Scan this QR Code with WeChat to continue.'
190183
msg.path = path
191184
msg.file = open(path, 'rb')

requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ python_telegram_bot>=5.3
66
xmltodict
77
Pillow
88
python_magic
9-
itchat>=1.2.18
10-
python-daemon
9+
itchat>=1.2.24
10+
python-daemon
11+
pyqrcode

0 commit comments

Comments
 (0)