From cf69a36a72053453c12909e97af4d05c4a6018f9 Mon Sep 17 00:00:00 2001 From: evilbeast Date: Sat, 10 Sep 2022 12:16:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=91=E9=80=81=E7=BE=A4@?= =?UTF-8?q?=E4=BE=8B=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/send_room_at_msg.py | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 examples/send_room_at_msg.py diff --git a/examples/send_room_at_msg.py b/examples/send_room_at_msg.py new file mode 100644 index 0000000..cc1478b --- /dev/null +++ b/examples/send_room_at_msg.py @@ -0,0 +1,42 @@ +# -*- 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="xxxxxx@chatroom", + content="测试, 你好{$@},你好{$@}", + at_list=['wxid_xxxxxxxx', 'wxid_xxxxxxxxx']) + + +# 以下是为了让程序不结束,如果有用于PyQt等有主循环消息的框架,可以去除下面代码 +try: + while True: + time.sleep(0.5) +except KeyboardInterrupt: + ntchat.exit_() + sys.exit() + + + +