fix slack attachment rendering

This commit is contained in:
c9s 2020-08-06 13:11:03 +08:00
parent 130407191a
commit 65f5a75bf1
2 changed files with 7 additions and 7 deletions

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"github.com/c9s/bbgo/pkg/bbgo/types"
"github.com/c9s/bbgo/pkg/slack/slackstyle"
"github.com/c9s/bbgo/pkg/util"
"github.com/sirupsen/logrus"
"github.com/slack-go/slack"
@ -20,6 +19,10 @@ type NullNotifier struct{}
func (n *NullNotifier) Notify(format string, args ...interface{}) {
}
type SlackAttachmentCreator interface {
SlackAttachment() slack.Attachment
}
type SlackNotifier struct {
Slack *slack.Client
@ -39,12 +42,14 @@ func (t *SlackNotifier) Notify(format string, args ...interface{}) {
if slackArgsStartIdx == -1 {
slackArgsStartIdx = idx
}
slackAttachments = append(slackAttachments, a)
case slackstyle.SlackAttachmentCreator:
case SlackAttachmentCreator:
if slackArgsStartIdx == -1 {
slackArgsStartIdx = idx
}
slackAttachments = append(slackAttachments, a.SlackAttachment())
}

View File

@ -1,7 +1,5 @@
package slackstyle
import "github.com/slack-go/slack"
const Green = "#228B22"
const Red = "#800000"
@ -14,7 +12,4 @@ func TrendIcon(trend int) string {
return ""
}
type SlackAttachmentCreator interface {
SlackAttachment() slack.Attachment
}