From ae450372b1581ad67fb87252a37febd5fc4592b7 Mon Sep 17 00:00:00 2001 From: evilbeast Date: Wed, 28 Sep 2022 10:56:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- examples/show_login_qrcode.py | 18 ++++++++++++++++++ fastapi_example/main.py | 2 +- ntchat/conf/__init__.py | 2 +- ntchat/core/wechat.py | 5 ++++- setup.py | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 examples/show_login_qrcode.py diff --git a/README.md b/README.md index 4ca0689..e06eacd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

NtChat

- release + release License

diff --git a/examples/show_login_qrcode.py b/examples/show_login_qrcode.py new file mode 100644 index 0000000..49018ba --- /dev/null +++ b/examples/show_login_qrcode.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +import sys +import time +import ntchat + + +def version_tuple(v): + return tuple(map(int, (v.split(".")))) + + +if version_tuple(ntchat.__version__) < version_tuple('0.1.15'): + print("error: ntchat version required 0.1.15, use `pip install -U ntchat` to upgrade") + sys.exit() + +wechat = ntchat.WeChat() + +# 打开一个新的微信,并显示二维码界面 +wechat.open(smart=False, show_login_qrcode=True) diff --git a/fastapi_example/main.py b/fastapi_example/main.py index 9c4de2b..bc82691 100644 --- a/fastapi_example/main.py +++ b/fastapi_example/main.py @@ -56,7 +56,7 @@ async def client_create(): response_model=models.ResponseModel) @catch_exception() async def client_open(model: models.ClientOpenReqModel): - ret = client_mgr.get_client(model.guid).open(model.smart) + ret = client_mgr.get_client(model.guid).open(model.smart, model.show_login_qrcode) return response_json(1 if ret else 0) diff --git a/ntchat/conf/__init__.py b/ntchat/conf/__init__.py index 4164d4b..fc256b7 100644 --- a/ntchat/conf/__init__.py +++ b/ntchat/conf/__init__.py @@ -1,4 +1,4 @@ -VERSION = '0.1.13' +VERSION = '0.1.15' LOG_LEVEL = "DEBUG" LOG_KEY = 'NTCHAT_LOG' diff --git a/ntchat/core/wechat.py b/ntchat/core/wechat.py index 8e43efa..1582b0f 100644 --- a/ntchat/core/wechat.py +++ b/ntchat/core/wechat.py @@ -120,7 +120,10 @@ class WeChat: log.info("wait login...") self.__wait_login_event.wait(timeout) - def open(self, smart=False): + def open(self, smart=False, show_login_qrcode=False): + if show_login_qrcode: + wcprobe.show_login_qrcode() + self.pid = wcprobe.open(smart) log.info("open wechat pid: %d", self.pid) return self.pid != 0 diff --git a/setup.py b/setup.py index 3cdb8ee..9547166 100644 --- a/setup.py +++ b/setup.py @@ -194,7 +194,7 @@ extension.extra_compile_cpp_args = extra_compile_cpp_args[target_os] setup( name='ntchat', - version='0.1.13', + version='0.1.15', description='About Conversational RPA SDK for Chatbot Makers', long_description="", long_description_content_type='text/markdown',