Skip to content

Commit 008e686

Browse files
committedSep 6, 2022
添加消息轰炸机示例
1 parent 91d1257 commit 008e686

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 align="center">NtChat</h1>
22
<p align="center">
3-
<a href="https://github.com/smallevilbeast/ntchat/releases"><img src="https://img.shields.io/badge/release-0.1.8-blue.svg?" alt="release"></a>
3+
<a href="https://github.com/smallevilbeast/ntchat/releases"><img src="https://img.shields.io/badge/release-0.1.10-blue.svg?" alt="release"></a>
44
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-brightgreen.svg?" alt="License"></a>
55
</p>
66

‎examples/bomber.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
os.environ['NTCHAT_LOG'] = "ERROR"
4+
5+
import time
6+
import ntchat
7+
8+
wechat = ntchat.WeChat()
9+
wechat.open(smart=True)
10+
11+
print("正在登录微信")
12+
wechat.wait_login()
13+
14+
peer_wxid = None
15+
16+
while True:
17+
contact_remark = input("请输入想发送的联系人备注: ")
18+
contacts = wechat.search_contacts(remark=contact_remark)
19+
if not contacts:
20+
print(f"没有搜索到备注是{contact_remark}的联系人")
21+
else:
22+
print(f"搜索到{len(contacts)}个联系人: ")
23+
print("0. 重新选择")
24+
for i, contact in enumerate(contacts):
25+
print(f"{i+1}. 昵称: {contact['nickname']}, 备注: {contact['remark']}")
26+
seq = int(input("输入上面编号进行选择: "))
27+
if seq != 0:
28+
peer_wxid = contacts[seq-1]["wxid"]
29+
break
30+
31+
content = input("请输入发送的内容: ")
32+
number = int(input("请输入发送的次数: "))
33+
34+
for i in range(1, number+1):
35+
time.sleep(0.1)
36+
print("正在发送第%d遍" % i)
37+
wechat.send_text(to_wxid=peer_wxid, content=content)
38+
39+
40+
ntchat.exit_()
41+
42+
43+

‎ntchat/conf/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '0.1.8'
1+
VERSION = '0.1.10'
22

33
LOG_LEVEL = "DEBUG"
44
LOG_KEY = 'NTCHAT_LOG'

‎ntchat/core/wechat.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def search_contacts(self,
201201
account: Union[None, str] = None,
202202
nickname: Union[None, str] = None,
203203
remark: Union[None, str] = None,
204-
fuzzy_search: bool = False):
204+
fuzzy_search: bool = True):
205205
"""
206206
根据wxid、微信号、昵称和备注模糊搜索联系人
207207
"""
@@ -225,7 +225,6 @@ def search_contacts(self,
225225
cond_str = " or ".join(cond_pairs)
226226
sql = f"select username from contact where {cond_str}"
227227
message = self.sql_query(sql, 1)
228-
print(message)
229228
if not message:
230229
return []
231230

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def add_prefix(l, prefix):
194194

195195
setup(
196196
name='ntchat',
197-
version='0.1.8',
197+
version='0.1.10',
198198
description='About Conversational RPA SDK for Chatbot Makers',
199199
long_description="",
200200
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)
Please sign in to comment.