mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 07:26:47 +00:00
Adjusted SMS global logic in main.go
This commit is contained in:
31
config.go
31
config.go
@@ -101,26 +101,21 @@ func UpdateExchangeConfig(e Exchanges) error {
|
||||
}
|
||||
|
||||
func CheckSMSGlobalConfigValues() error {
|
||||
if bot.config.SMS.Enabled {
|
||||
if bot.config.SMS.Username == "" || bot.config.SMS.Username == "Username" || bot.config.SMS.Password == "" || bot.config.SMS.Password == "Password" {
|
||||
bot.config.SMS.Enabled = false
|
||||
return errors.New(WarningSMSGlobalDefaultOrEmptyValues)
|
||||
}
|
||||
contacts := 0
|
||||
for i := range bot.config.SMS.Contacts {
|
||||
if bot.config.SMS.Contacts[i].Enabled {
|
||||
if bot.config.SMS.Contacts[i].Name == "" || bot.config.SMS.Contacts[i].Number == "" || (bot.config.SMS.Contacts[i].Name == "Bob" && bot.config.SMS.Contacts[i].Number == "12345") {
|
||||
log.Printf(WarningSSMSGlobalSMSContactDefaultOrEmptyValues, i)
|
||||
bot.config.SMS.Contacts[i].Enabled = false
|
||||
continue
|
||||
}
|
||||
contacts++
|
||||
if bot.config.SMS.Username == "" || bot.config.SMS.Username == "Username" || bot.config.SMS.Password == "" || bot.config.SMS.Password == "Password" {
|
||||
return errors.New(WarningSMSGlobalDefaultOrEmptyValues)
|
||||
}
|
||||
contacts := 0
|
||||
for i := range bot.config.SMS.Contacts {
|
||||
if bot.config.SMS.Contacts[i].Enabled {
|
||||
if bot.config.SMS.Contacts[i].Name == "" || bot.config.SMS.Contacts[i].Number == "" || (bot.config.SMS.Contacts[i].Name == "Bob" && bot.config.SMS.Contacts[i].Number == "12345") {
|
||||
log.Printf(WarningSSMSGlobalSMSContactDefaultOrEmptyValues, i)
|
||||
continue
|
||||
}
|
||||
contacts++
|
||||
}
|
||||
if contacts == 0 {
|
||||
bot.config.SMS.Enabled = false
|
||||
return errors.New(WarningSSMSGlobalSMSNoContacts)
|
||||
}
|
||||
}
|
||||
if contacts == 0 {
|
||||
return errors.New(WarningSSMSGlobalSMSNoContacts)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
18
main.go
18
main.go
@@ -56,16 +56,18 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
err = CheckSMSGlobalConfigValues()
|
||||
if err != nil {
|
||||
// non fatal event
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
log.Printf("Bot '%s' started.\n", bot.config.Name)
|
||||
|
||||
if bot.config.SMS.Enabled {
|
||||
log.Printf("SMS support enabled. Number of SMS contacts %d.\n", GetEnabledSMSContacts())
|
||||
} else {
|
||||
err = CheckSMSGlobalConfigValues()
|
||||
if err != nil {
|
||||
log.Println(err) // non fatal event
|
||||
bot.config.SMS.Enabled = false
|
||||
} else {
|
||||
log.Printf("SMS support enabled. Number of SMS contacts %d.\n", GetEnabledSMSContacts())
|
||||
}
|
||||
}
|
||||
if !bot.config.SMS.Enabled {
|
||||
log.Println("SMS support disabled.")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user