load notification conf

This commit is contained in:
c9s 2020-10-27 08:57:00 +08:00
parent c315b79bd7
commit ea05d998f2

View File

@ -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 {