From 44cb54a9ea499c0c86bbcf83bf343e5c98f1de64 Mon Sep 17 00:00:00 2001 From: SSMario Date: Tue, 16 May 2023 09:38:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=8B=E6=9C=BA=E4=B8=8A=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=B6=88=E6=81=AF=EF=BC=8C=E4=B8=8D=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channel/chat_message.py | 1 + channel/wechat/wechat_channel.py | 3 +++ channel/wechat/wechat_message.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/channel/chat_message.py b/channel/chat_message.py index fdd4d90..0e2f652 100644 --- a/channel/chat_message.py +++ b/channel/chat_message.py @@ -48,6 +48,7 @@ class ChatMessage(object): to_user_nickname = None other_user_id = None other_user_nickname = None + my_msg = False is_group = False is_at = False diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index c888157..10c5003 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -59,6 +59,9 @@ def _check(func): if conf().get("hot_reload") == True and int(create_time) < int(time.time()) - 60: # 跳过1分钟前的历史消息 logger.debug("[WX]history message {} skipped".format(msgId)) return + if cmsg.my_msg: + logger.debug("[WX]my message {} skipped".format(msgId)) + return return func(self, cmsg) return wrapper diff --git a/channel/wechat/wechat_message.py b/channel/wechat/wechat_message.py index 5d9bf28..b9824f9 100644 --- a/channel/wechat/wechat_message.py +++ b/channel/wechat/wechat_message.py @@ -58,6 +58,8 @@ class WechatMessage(ChatMessage): if self.to_user_id == user_id: self.to_user_nickname = nickname try: # 陌生人时候, 'User'字段可能不存在 + self.my_msg = itchat_msg["ToUserName"] == itchat_msg["User"]["UserName"] and \ + itchat_msg["ToUserName"] != itchat_msg["FromUserName"] self.other_user_id = itchat_msg["User"]["UserName"] self.other_user_nickname = itchat_msg["User"]["NickName"] if self.other_user_id == self.from_user_id: