From 008e6867eff49b137618c0c1c3b0884c3b18afcf Mon Sep 17 00:00:00 2001 From: evilbeast Date: Tue, 6 Sep 2022 13:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF=E8=BD=B0?= =?UTF-8?q?=E7=82=B8=E6=9C=BA=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- examples/bomber.py | 43 +++++++++++++++++++++++++++++++++++++++++ ntchat/conf/__init__.py | 2 +- ntchat/core/wechat.py | 3 +-- setup.py | 2 +- 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 examples/bomber.py diff --git a/README.md b/README.md index 9a55e21..e85bc81 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

NtChat

- release + release License

diff --git a/examples/bomber.py b/examples/bomber.py new file mode 100644 index 0000000..d1f8ee9 --- /dev/null +++ b/examples/bomber.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +import os +os.environ['NTCHAT_LOG'] = "ERROR" + +import time +import ntchat + +wechat = ntchat.WeChat() +wechat.open(smart=True) + +print("正在登录微信") +wechat.wait_login() + +peer_wxid = None + +while True: + contact_remark = input("请输入想发送的联系人备注: ") + contacts = wechat.search_contacts(remark=contact_remark) + if not contacts: + print(f"没有搜索到备注是{contact_remark}的联系人") + else: + print(f"搜索到{len(contacts)}个联系人: ") + print("0. 重新选择") + for i, contact in enumerate(contacts): + print(f"{i+1}. 昵称: {contact['nickname']}, 备注: {contact['remark']}") + seq = int(input("输入上面编号进行选择: ")) + if seq != 0: + peer_wxid = contacts[seq-1]["wxid"] + break + +content = input("请输入发送的内容: ") +number = int(input("请输入发送的次数: ")) + +for i in range(1, number+1): + time.sleep(0.1) + print("正在发送第%d遍" % i) + wechat.send_text(to_wxid=peer_wxid, content=content) + + +ntchat.exit_() + + + diff --git a/ntchat/conf/__init__.py b/ntchat/conf/__init__.py index 09496f8..51a1dd2 100644 --- a/ntchat/conf/__init__.py +++ b/ntchat/conf/__init__.py @@ -1,4 +1,4 @@ -VERSION = '0.1.8' +VERSION = '0.1.10' LOG_LEVEL = "DEBUG" LOG_KEY = 'NTCHAT_LOG' diff --git a/ntchat/core/wechat.py b/ntchat/core/wechat.py index 1ab8b67..9b13e11 100644 --- a/ntchat/core/wechat.py +++ b/ntchat/core/wechat.py @@ -201,7 +201,7 @@ class WeChat: account: Union[None, str] = None, nickname: Union[None, str] = None, remark: Union[None, str] = None, - fuzzy_search: bool = False): + fuzzy_search: bool = True): """ 根据wxid、微信号、昵称和备注模糊搜索联系人 """ @@ -225,7 +225,6 @@ class WeChat: cond_str = " or ".join(cond_pairs) sql = f"select username from contact where {cond_str}" message = self.sql_query(sql, 1) - print(message) if not message: return [] diff --git a/setup.py b/setup.py index 85cb245..2bd55f6 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.8', + version='0.1.10', description='About Conversational RPA SDK for Chatbot Makers', long_description="", long_description_content_type='text/markdown',