Skip to content

Commit

Permalink
🐛 修复系统消息类型的Content为空的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
eatmoreapple committed Dec 17, 2021
1 parent 26473a5 commit 2db696d
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,21 +388,23 @@ func (m *Message) init(bot *Bot) {
m.Raw = raw
// 如果是群消息
if m.IsSendByGroup() {
// 将Username和正文分开
data := strings.Split(m.Content, ":<br/>")
m.Content = strings.Join(data[1:], "")
m.senderInGroupUserName = data[0]
receiver, err := m.Receiver()
if err == nil {
displayName := receiver.DisplayName
if displayName == "" {
displayName = receiver.NickName
}
// 判断是不是@消息
atFlag := "@" + displayName + "\u2005"
if strings.Contains(m.Content, atFlag) {
m.isAt = true
m.Content = strings.Replace(m.Content, atFlag, "", -1)
if m.MsgType == MsgTypeText {
// 将Username和正文分开
data := strings.Split(m.Content, ":<br/>")
m.Content = strings.Join(data[1:], "")
m.senderInGroupUserName = data[0]
receiver, err := m.Receiver()
if err == nil {
displayName := receiver.DisplayName
if displayName == "" {
displayName = receiver.NickName
}
// 判断是不是@消息
atFlag := "@" + displayName + "\u2005"
if strings.Contains(m.Content, atFlag) {
m.isAt = true
m.Content = strings.Replace(m.Content, atFlag, "", -1)
}
}
}
}
Expand Down

0 comments on commit 2db696d

Please sign in to comment.