修改echo_bot例子不回复群消息

This commit is contained in:
evilbeast 2022-08-25 14:18:47 +08:00
parent 0fc8d21920
commit 7e1bf189ee
2 changed files with 6 additions and 4 deletions

View File

@ -15,9 +15,10 @@ def on_recv_text_msg(wechat_instance: ntchat.WeChat, message):
data = message["data"]
from_wxid = data["from_wxid"]
self_wxid = wechat_instance.get_login_info()["wxid"]
room_wxid = data["room_wxid"]
# 判断消息不是自己发的回复对方
if from_wxid != self_wxid:
# 判断消息不是自己发的并且不是群消息时,回复对方
if from_wxid != self_wxid and not room_wxid:
wechat_instance.send_text(to_wxid=from_wxid, content=f"你发送的消息是: {data['msg']}")

View File

@ -12,9 +12,10 @@ def on_recv_text_msg(wechat_instance: ntchat.WeChat, message):
data = message["data"]
from_wxid = data["from_wxid"]
self_wxid = wechat_instance.get_login_info()["wxid"]
room_wxid = data["room_wxid"]
# 判断消息不是自己发的回复对方
if from_wxid != self_wxid:
# 判断消息不是自己发的并且不是群消息时,回复对方
if from_wxid != self_wxid and not room_wxid:
wechat_instance.send_text(to_wxid=from_wxid, content=f"你发送的消息是: {data['msg']}")