From 797821e2ed231db642112d1bbf57f58c674398c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 7 Mar 2024 09:48:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:art:=20=E9=80=BB=E8=BE=91=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mq/handler.go | 5 +++++ tcpserver/parse.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mq/handler.go b/mq/handler.go index 3350a87d..b24a61b7 100644 --- a/mq/handler.go +++ b/mq/handler.go @@ -22,6 +22,11 @@ func parse(msg []byte) { // 记录原始数据 m.Raw = string(msg) + // 如果不是自己的消息,直接返回 + if m.FromUser == current.GetRobotInfo().WxId { + return + } + // 提取出群成员信息 // Sys类型的消息正文不包含微信 Id,所以不需要处理 if m.IsGroup() && m.Type != types.MsgTypeSys { diff --git a/tcpserver/parse.go b/tcpserver/parse.go index 981d5436..ceaacffe 100644 --- a/tcpserver/parse.go +++ b/tcpserver/parse.go @@ -23,6 +23,11 @@ func parse(remoteAddr net.Addr, msg []byte) { // 记录原始数据 m.Raw = string(msg) + // 如果不是自己的消息,直接返回 + if m.FromUser == current.GetRobotInfo().WxId { + return + } + // 提取出群成员信息 // Sys类型的消息正文不包含微信 Id,所以不需要处理 if m.IsGroup() && m.Type != types.MsgTypeSys { From 22474efc57c7be11875301c9c82c9edc17b5f1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 7 Mar 2024 09:49:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:art:=20=E9=80=BB=E8=BE=91=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mq/handler.go | 2 +- tcpserver/parse.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mq/handler.go b/mq/handler.go index b24a61b7..223014b5 100644 --- a/mq/handler.go +++ b/mq/handler.go @@ -23,7 +23,7 @@ func parse(msg []byte) { m.Raw = string(msg) // 如果不是自己的消息,直接返回 - if m.FromUser == current.GetRobotInfo().WxId { + if m.ToUser == current.GetRobotInfo().WxId { return } diff --git a/tcpserver/parse.go b/tcpserver/parse.go index ceaacffe..6f3b35d9 100644 --- a/tcpserver/parse.go +++ b/tcpserver/parse.go @@ -24,7 +24,7 @@ func parse(remoteAddr net.Addr, msg []byte) { m.Raw = string(msg) // 如果不是自己的消息,直接返回 - if m.FromUser == current.GetRobotInfo().WxId { + if m.ToUser == current.GetRobotInfo().WxId { return } From 165fefdb482e042aadd0aca0d58343b32b6909b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 7 Mar 2024 10:04:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E6=89=AB?= =?UTF-8?q?=E7=A0=81=E5=8A=A0=E5=85=A5=E7=BE=A4=E8=81=8A=E7=9A=84=E6=88=90?= =?UTF-8?q?=E5=91=98=E6=97=A0=E6=B3=95=E8=AF=86=E5=88=AB=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/message.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/model/message.go b/model/message.go index f2d240b9..951ee0f8 100644 --- a/model/message.go +++ b/model/message.go @@ -88,7 +88,13 @@ func (m Message) IsRevokeMsg() bool { // @receiver m // @return bool func (m Message) IsNewUserJoin() bool { - sysFlag := m.Type == types.MsgTypeSys && strings.Contains(m.Content, "\"邀请\"") && strings.Contains(m.Content, "\"加入了群聊") + if m.Type != types.MsgTypeSys { + return false + } + + isInvitation := strings.Contains(m.Content, "\"邀请\"") && strings.Contains(m.Content, "\"加入了群聊") + isScanQrCode := strings.Contains(m.Content, "通过扫描") && strings.Contains(m.Content, "加入群聊") + sysFlag := isInvitation || isScanQrCode if sysFlag { return true } @@ -97,7 +103,7 @@ func (m Message) IsNewUserJoin() bool { if err := xml.Unmarshal([]byte(m.Content), &d); err != nil { return false } - return m.Type == types.MsgTypeSys && d.Type == "delchatroommember" + return d.Type == "delchatroommember" } // IsAt