1
0
mirror of https://github.com/mgerb/ServerStatus synced 2026-01-10 03:03:04 +00:00

add polling interval to configurations - resolves #15

This commit is contained in:
2018-07-18 20:20:44 -05:00
parent 1cd9f139c2
commit bcb57c72a3
4 changed files with 21 additions and 6 deletions

View File

@@ -3,6 +3,7 @@
"RoomIDList":["room id list goes here"], "RoomIDList":["room id list goes here"],
"RolesToNotify": ["<@&roleid>", "<@userid>"], "RolesToNotify": ["<@&roleid>", "<@userid>"],
"GameStatus": "current playing game", "GameStatus": "current playing game",
"PollingInterval": 10,
"Servers": [ "Servers": [
{ {
"Name": "Your awesome server", "Name": "Your awesome server",

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"time"
) )
// Variables used for command line parameters // Variables used for command line parameters
@@ -17,6 +18,7 @@ type configStruct struct {
RolesToNotify []string `json:"RolesToNotify"` RolesToNotify []string `json:"RolesToNotify"`
Servers []server `json:"Servers"` Servers []server `json:"Servers"`
GameStatus string `json:"GameStatus"` GameStatus string `json:"GameStatus"`
PollingInterval time.Duration `json:"PollingInterval"`
} }
type server struct { type server struct {
@@ -43,4 +45,8 @@ func Configure() {
log.Println(err) log.Println(err)
} }
if Config.PollingInterval == 0 {
log.Fatal("Please set your PollingInterval > 0 in your config file.")
}
} }

View File

@@ -17,6 +17,14 @@ NOTE: This bot currently does not work for UDP servers.
- for user `<@userid>` - for user `<@userid>`
- for role `<@&roleid>` - 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 ## Usage
To get the current status of your servers simply type `!ServerStatus` in chat. To get the current status of your servers simply type `!ServerStatus` in chat.

View File

@@ -61,7 +61,7 @@ func scanServers() {
config.Config.Servers[index].Online = serverUp config.Config.Servers[index].Online = serverUp
} }
time.Sleep(time.Second * 5) time.Sleep(time.Second * config.Config.PollingInterval)
} }
} }