mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
load notification conf
This commit is contained in:
parent
c315b79bd7
commit
ea05d998f2
|
@ -68,18 +68,22 @@ func compileRunFile(filepath string, config *bbgo.Config) error {
|
|||
|
||||
func runConfig(ctx context.Context, userConfig *bbgo.Config) error {
|
||||
// configure notifiers
|
||||
notifierSet := &bbgo.Notifiability{}
|
||||
|
||||
// for slack
|
||||
slackToken := viper.GetString("slack-token")
|
||||
if len(slackToken) > 0 {
|
||||
if conf := userConfig.Notifications.Slack; conf != nil {
|
||||
if conf.ErrorChannel != "" {
|
||||
log.Infof("found slack configured, setting up log hook...")
|
||||
log.AddHook(slacklog.NewLogHook(slackToken, viper.GetString("slack-error-channel")))
|
||||
log.AddHook(slacklog.NewLogHook(slackToken, conf.ErrorChannel))
|
||||
}
|
||||
|
||||
notifierSet := &bbgo.Notifiability{}
|
||||
if len(slackToken) > 0 {
|
||||
log.Infof("adding slack notifier...")
|
||||
var notifier = slacknotifier.New(slackToken, viper.GetString("slack-channel"))
|
||||
var notifier = slacknotifier.New(slackToken, conf.DefaultChannel)
|
||||
notifierSet.AddNotifier(notifier)
|
||||
}
|
||||
}
|
||||
|
||||
db, err := cmdutil.ConnectMySQL()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user