From 65a149a046cb0639a69372960defd90f12460bb4 Mon Sep 17 00:00:00 2001 From: xiao bo Date: Fri, 22 Nov 2024 15:38:05 +0800 Subject: [PATCH] login: support qrcode png Signed-off-by: xiao bo --- channel/wechat/wechat_channel.py | 9 +++++++++ requirements.txt | 1 + 2 files changed, 10 insertions(+) diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index ce3f0861e..4f3c2c96f 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -10,6 +10,7 @@ import threading import time import requests +import qrcode from bridge.context import * from bridge.reply import * @@ -87,6 +88,14 @@ def qrCallback(uuid, status, qrcode): url = f"https://login.weixin.qq.com/l/{uuid}" + img = qrcode.make(data=url) + + if not os.path.exists('tmp'): + os.makedirs('tmp') + + with open('tmp/login.png', 'wb') as f: + img.save(f) + qr_api1 = "https://api.isoyu.com/qr/?m=1&e=L&p=20&url={}".format(url) qr_api2 = "https://api.qrserver.com/v1/create-qr-code/?size=400×400&data={}".format(url) qr_api3 = "https://api.pwmqr.com/qrcode/create/?url={}".format(url) diff --git a/requirements.txt b/requirements.txt index 45d09cc1c..fa3308977 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ Pillow pre-commit web.py linkai>=0.0.6.0 +qrcode