Added SMS and bot name config variables.

This commit is contained in:
Adrian Gallagher
2015-03-03 21:50:16 +11:00
parent 69f25aa4b8
commit a167f1f8f4
3 changed files with 33 additions and 1 deletions

View File

@@ -5,7 +5,15 @@ import (
"encoding/json"
)
type SMSContacts struct {
Name string
Number string
Enabled bool
}
type Config struct {
Name string
SMSContacts []SMSContacts
Exchanges []Exchanges
}

View File

@@ -1,4 +1,12 @@
{
"Name": "Skynet",
"SMSContacts" : [
{
"Name": "Bob",
"Number": "12345",
"Enabled": false
}
],
"Exchanges": [
{
"Name": "Bitfinex",

18
main.go
View File

@@ -29,7 +29,6 @@ type Bot struct {
var bot Bot
func main() {
log.Println("Bot started")
log.Println("Loading config file config.json..")
err := errors.New("")
@@ -41,6 +40,7 @@ func main() {
}
log.Println("Config file loaded.")
log.Printf("Bot '%s' started.\n", bot.config.Name)
enabledExchanges := 0
for _, exch := range bot.config.Exchanges {
@@ -54,6 +54,22 @@ func main() {
return
}
smsSupport := false
smsContacts := 0
for _, sms := range bot.config.SMSContacts {
if sms.Enabled {
smsSupport = true
smsContacts++
}
}
if smsSupport {
log.Printf("SMS support enabled. Number of SMS contacts %d.\n", smsContacts)
} else {
log.Println("SMS support disabled.")
}
log.Printf("Available Exchanges: %d. Enabled Exchanges: %d.\n", len(bot.config.Exchanges), enabledExchanges)
log.Println("Bot Exchange support:")