From 851f4ed63e5cea1a892cc52890269c6dd69b9173 Mon Sep 17 00:00:00 2001 From: eatmoreapple <15055461510@163.com> Date: Wed, 29 Sep 2021 18:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=A4=E6=96=AD@=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9A=84bug=20:bug:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- message.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/message.go b/message.go index 678180e..fefe82e 100644 --- a/message.go +++ b/message.go @@ -12,11 +12,10 @@ import ( "strings" "sync" "time" - "unicode" ) type Message struct { - IsAt bool + isAt bool AppInfo struct { Type int AppID string @@ -362,11 +361,10 @@ func (m *Message) init(bot *Bot) { displayName = receiver.NickName } // 判断是不是@消息 - atFlag := "@" + displayName - index := len(atFlag) + 1 + 1 - if strings.HasPrefix(m.Content, atFlag) && unicode.IsSpace(rune(m.Content[index])) { - m.IsAt = true - m.Content = m.Content[index+1:] + atFlag := "@" + displayName + "\u2005" + if strings.Contains(m.Content, atFlag) { + m.isAt = true + m.Content = strings.Replace(m.Content, atFlag, "", -1) } } } @@ -651,3 +649,8 @@ func (m *Message) IsComeFromGroup() bool { func (m *Message) String() string { return fmt.Sprintf("<%s:%s>", m.MsgType, m.MsgId) } + +// IsAt 判断消息是否为@消息 +func (m *Message) IsAt() bool { + return m.isAt +}