2024-11-05 08:02:34 +00:00
|
|
|
package bbgo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
|
2024-11-05 09:02:06 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/livenote"
|
2024-11-05 08:02:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// PostLiveNote posts a live note to slack or other services
|
|
|
|
// The MessageID will be set after the message is posted if it's not set.
|
2024-11-05 09:02:06 +00:00
|
|
|
func PostLiveNote(obj livenote.Object) {
|
2024-11-05 09:34:26 +00:00
|
|
|
if len(Notification.liveNotePosters) == 0 {
|
|
|
|
logrus.Warn("no live note poster is registered")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-11-05 08:02:34 +00:00
|
|
|
for _, poster := range Notification.liveNotePosters {
|
2024-11-05 09:02:06 +00:00
|
|
|
if err := poster.PostLiveNote(obj); err != nil {
|
|
|
|
logrus.WithError(err).Errorf("unable to post live note: %+v", obj)
|
2024-11-05 08:02:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type LiveNotePoster interface {
|
2024-11-05 09:02:06 +00:00
|
|
|
PostLiveNote(note livenote.Object) error
|
2024-11-05 08:02:34 +00:00
|
|
|
}
|