Skip to content

Commit

Permalink
fix: 转发消息发生错误时不中断后续消息的转发 (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
eatmoreapple authored Dec 5, 2023
1 parent be1350a commit 9f03f1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,18 @@ func (s *Self) forwardMessage(msg *SentMessage, delay time.Duration, users ...*U
default:
return fmt.Errorf("unsupported message type: %s", msg.Type)
}
var errGroup []error
for _, user := range users {
msg.FromUserName = s.UserName
msg.ToUserName = user.UserName
if err := forwardFunc(); err != nil {
return err
errGroup = append(errGroup, err)
}
time.Sleep(delay)
}
if len(errGroup) > 0 {
return errors.Join(errGroup...)
}
return nil
}

Expand Down

0 comments on commit 9f03f1f

Please sign in to comment.