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: