mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-09 02:52:47 +00:00
add polling interval to configurations - resolves #15
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"RoomIDList":["room id list goes here"],
|
||||
"RolesToNotify": ["<@&roleid>", "<@userid>"],
|
||||
"GameStatus": "current playing game",
|
||||
"PollingInterval": 10,
|
||||
"Servers": [
|
||||
{
|
||||
"Name": "Your awesome server",
|
||||
|
||||
@@ -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.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ func scanServers() {
|
||||
config.Config.Servers[index].Online = serverUp
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 5)
|
||||
time.Sleep(time.Second * config.Config.PollingInterval)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user