@@ -48,6 +48,7 @@ class ChatMessage(object): | |||||
to_user_nickname = None | to_user_nickname = None | ||||
other_user_id = None | other_user_id = None | ||||
other_user_nickname = None | other_user_nickname = None | ||||
my_msg = False | |||||
is_group = False | is_group = False | ||||
is_at = False | is_at = False | ||||
@@ -59,6 +59,9 @@ def _check(func): | |||||
if conf().get("hot_reload") == True and int(create_time) < int(time.time()) - 60: # 跳过1分钟前的历史消息 | if conf().get("hot_reload") == True and int(create_time) < int(time.time()) - 60: # 跳过1分钟前的历史消息 | ||||
logger.debug("[WX]history message {} skipped".format(msgId)) | logger.debug("[WX]history message {} skipped".format(msgId)) | ||||
return | return | ||||
if cmsg.my_msg: | |||||
logger.debug("[WX]my message {} skipped".format(msgId)) | |||||
return | |||||
return func(self, cmsg) | return func(self, cmsg) | ||||
return wrapper | return wrapper | ||||
@@ -58,6 +58,8 @@ class WechatMessage(ChatMessage): | |||||
if self.to_user_id == user_id: | if self.to_user_id == user_id: | ||||
self.to_user_nickname = nickname | self.to_user_nickname = nickname | ||||
try: # 陌生人时候, 'User'字段可能不存在 | 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_id = itchat_msg["User"]["UserName"] | ||||
self.other_user_nickname = itchat_msg["User"]["NickName"] | self.other_user_nickname = itchat_msg["User"]["NickName"] | ||||
if self.other_user_id == self.from_user_id: | if self.other_user_id == self.from_user_id: | ||||