mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-09 18:52:50 +00:00
add polling interval to configurations - resolves #15
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
@@ -6,17 +6,19 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Variables used for command line parameters
|
// Variables used for command line parameters
|
||||||
var Config configStruct
|
var Config configStruct
|
||||||
|
|
||||||
type configStruct struct {
|
type configStruct struct {
|
||||||
Token string `json:"Token"`
|
Token string `json:"Token"`
|
||||||
RoomIDList []string `json:"RoomIDList"`
|
RoomIDList []string `json:"RoomIDList"`
|
||||||
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.")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user