diff --git a/config.template.json b/config.template.json index 198f92a..f65fe2d 100644 --- a/config.template.json +++ b/config.template.json @@ -3,6 +3,7 @@ "RoomIDList":["room id list goes here"], "RolesToNotify": ["<@&roleid>", "<@userid>"], "GameStatus": "current playing game", + "PollingInterval": 10, "Servers": [ { "Name": "Your awesome server", diff --git a/config/config.go b/config/config.go index ebf4bd1..69be37d 100644 --- a/config/config.go +++ b/config/config.go @@ -6,17 +6,19 @@ import ( "io/ioutil" "log" "os" + "time" ) // Variables used for command line parameters var Config configStruct type configStruct struct { - Token string `json:"Token"` - RoomIDList []string `json:"RoomIDList"` - RolesToNotify []string `json:"RolesToNotify"` - Servers []server `json:"Servers"` - GameStatus string `json:"GameStatus"` + Token string `json:"Token"` + RoomIDList []string `json:"RoomIDList"` + RolesToNotify []string `json:"RolesToNotify"` + Servers []server `json:"Servers"` + GameStatus string `json:"GameStatus"` + PollingInterval time.Duration `json:"PollingInterval"` } type server struct { @@ -43,4 +45,8 @@ func Configure() { log.Println(err) } + if Config.PollingInterval == 0 { + log.Fatal("Please set your PollingInterval > 0 in your config file.") + } + } diff --git a/readme.md b/readme.md index a91ec5a..e09dbfd 100644 --- a/readme.md +++ b/readme.md @@ -17,6 +17,14 @@ NOTE: This bot currently does not work for UDP servers. - for user `<@userid>` - for role `<@&roleid>` +### Polling Interval +The polling interval is how often the bot will try to ping the servers. +A good interval is 10 seconds, but this may need some adjustment if +it happens to be spamming notifications. + +- time in seconds +- configurable in `config.json` + ## Usage To get the current status of your servers simply type `!ServerStatus` in chat. diff --git a/serverstatus/serverstatus.go b/serverstatus/serverstatus.go index 8da791e..2da3061 100644 --- a/serverstatus/serverstatus.go +++ b/serverstatus/serverstatus.go @@ -61,7 +61,7 @@ func scanServers() { config.Config.Servers[index].Online = serverUp } - time.Sleep(time.Second * 5) + time.Sleep(time.Second * config.Config.PollingInterval) } }