Skip to content

Commit

Permalink
修复获取消息发送者的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
eatmoreapple committed Dec 17, 2021
1 parent 3718d6c commit ed69f3e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (m *Message) SenderInGroup() (*User, error) {
if err := group.Detail(); err != nil {
return nil, err
}
if group.IsFriend() {
return group, nil
}
users := group.MemberList.SearchByUserName(1, m.senderInGroupUserName)
if users == nil {
return nil, ErrNoSuchUserFoundError
Expand Down Expand Up @@ -388,7 +391,7 @@ func (m *Message) init(bot *Bot) {
m.Raw = raw
// 如果是群消息
if m.IsSendByGroup() {
if m.IsText() {
if !m.IsSystem() {
// 将Username和正文分开
data := strings.Split(m.Content, ":<br/>")
m.Content = strings.Join(data[1:], "")
Expand Down Expand Up @@ -683,7 +686,7 @@ func (a AppMessageData) IsFile() bool {
// IsComeFromGroup 判断消息是否来自群组
// 可能是自己或者别的群员发送
func (m *Message) IsComeFromGroup() bool {
return m.IsSendByGroup() || strings.HasPrefix(m.ToUserName, "@@")
return m.IsSendByGroup() || (strings.HasPrefix(m.ToUserName, "@@") && m.IsSendBySelf())
}

func (m *Message) String() string {
Expand Down

0 comments on commit ed69f3e

Please sign in to comment.