forked from bumandpunk/ntchat-wx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_room_at_msg.py
49 lines (35 loc) · 1.2 KB
/
send_room_at_msg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'''
Date: 2022-11-21 15:09:14
LastEditors: Zfj
LastEditTime: 2023-01-16 16:46:09
FilePath: \ntchat\examples\send_room_at_msg.py
Description:
'''
# -*- coding: utf-8 -*-
import sys
import time
import ntchat
wechat = ntchat.WeChat()
# 打开pc微信, smart: 是否管理已经登录的微信
wechat.open(smart=True)
# 等待登录
wechat.wait_login()
'''
test,你好{$@},你好{$@}.早上好
发送内容中{$@}占位符说明:
文本消息的content的内容中设置占位字符串 {$@},这些字符的位置就是最终的@符号所在的位置
假设这两个被@的微信号的群昵称分别为aa,bb
则实际发送的内容为 "test,你好@ aa,你好@ bb.早上好"(占位符被替换了)
占位字符串的数量必须和at_list中的微信数量相等.
'''
# 下面是@两个人的发送例子,room_wxid, at_list需要自己替换
wechat.send_room_at_msg(to_wxid="19627160857@chatroom",
content=" ",
at_list=['wxid_9lioqr8pgjkg21'])
# 以下是为了让程序不结束,如果有用于PyQt等有主循环消息的框架,可以去除下面代码
try:
while True:
time.sleep(0.5)
except KeyboardInterrupt:
ntchat.exit_()
sys.exit()