bbgo: move authToken loader

This commit is contained in:
c9s 2022-01-15 00:29:35 +08:00
parent 3a13025d58
commit e385d96709

View File

@ -560,12 +560,6 @@ func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) erro
}
persistence := environ.PersistenceServiceFacade.Get()
authToken := viper.GetString("telegram-bot-auth-token")
if len(authToken) > 0 {
log.Debugf("telegram bot auth token is set, using fixed token for authorization...")
printAuthTokenGuide(authToken)
}
var otpQRCodeImagePath = fmt.Sprintf("otp.png")
var key *otp.Key
@ -599,6 +593,8 @@ func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) erro
authStrict := false
authMode := interact.AuthModeToken
authToken := viper.GetString("telegram-bot-auth-token")
if authToken != "" && key != nil {
authStrict = true
} else if authToken != "" {
@ -607,6 +603,11 @@ func (environ *Environment) ConfigureNotificationSystem(userConfig *Config) erro
authMode = interact.AuthModeOTP
}
if authMode == interact.AuthModeToken {
log.Debugf("found interaction auth token, using token mode for authorization...")
printAuthTokenGuide(authToken)
}
interact.AddCustomInteraction(&interact.AuthInteract{
Strict: authStrict,
Mode: authMode,