mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-11 03:32:50 +00:00
added role notification configuration
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Token": "your_bot_token_id",
|
"Token": "your_bot_token_id",
|
||||||
"RoomIDList": ["id_1", "id_2", "id_3"],
|
"RoomIDList": ["id_1", "id_2", "id_3"],
|
||||||
|
"RoleToNotify": "@Elysium",
|
||||||
"Servers": [
|
"Servers": [
|
||||||
{
|
{
|
||||||
"Name": "Elysium PvP",
|
"Name": "Elysium PvP",
|
||||||
|
|||||||
BIN
dist/ServerStatus-linux
vendored
BIN
dist/ServerStatus-linux
vendored
Binary file not shown.
BIN
dist/ServerStatus-windows.exe
vendored
BIN
dist/ServerStatus-windows.exe
vendored
Binary file not shown.
1
dist/config.json
vendored
1
dist/config.json
vendored
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"Token": "your_bot_token_id",
|
"Token": "your_bot_token_id",
|
||||||
"RoomIDList": ["id_1", "id_2", "id_3"],
|
"RoomIDList": ["id_1", "id_2", "id_3"],
|
||||||
|
"RoleToNotify": "@Elysium",
|
||||||
"Servers": [
|
"Servers": [
|
||||||
{
|
{
|
||||||
"Name": "Elysium PvP",
|
"Name": "Elysium PvP",
|
||||||
|
|||||||
14
makefile
14
makefile
@@ -1,8 +1,16 @@
|
|||||||
run:
|
run:
|
||||||
@go run ./src/main.go
|
@go run ./src/main.go
|
||||||
|
|
||||||
build:
|
linux:
|
||||||
@rm -rf ./dist
|
|
||||||
@GOOS=windows GOARCH=386 go build -o ./dist/ServerStatus-windows.exe ./src/main.go
|
|
||||||
@go build -o ./dist/ServerStatus-linux ./src/main.go
|
@go build -o ./dist/ServerStatus-linux ./src/main.go
|
||||||
|
|
||||||
|
windows:
|
||||||
|
@GOOS=windows GOARCH=386 go build -o ./dist/ServerStatus-windows.exe ./src/main.go
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -rf ./dist
|
||||||
|
|
||||||
|
copyfiles:
|
||||||
@cp config.template.json ./dist/config.json
|
@cp config.template.json ./dist/config.json
|
||||||
|
|
||||||
|
all: linux windows copyfiles
|
||||||
@@ -29,3 +29,9 @@ Anathema PvP is online!
|
|||||||
Darrowshire PvE is online!
|
Darrowshire PvE is online!
|
||||||
Elysium Authentication Server is online!
|
Elysium Authentication Server is online!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Compiling
|
||||||
|
|
||||||
|
Make sure you have Go installed.
|
||||||
|
|
||||||
|
`make clean all`
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ import (
|
|||||||
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"`
|
||||||
Servers []server `json:"Servers"`
|
RoleToNotify string `json:"RoleToNotify"`
|
||||||
|
Servers []server `json:"Servers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type server struct {
|
type server struct {
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ func loop() {
|
|||||||
serverUp := elysiumPvP.IsOpen(server.Port) //check if the port is open
|
serverUp := elysiumPvP.IsOpen(server.Port) //check if the port is open
|
||||||
|
|
||||||
if serverUp && serverUp != prevServerUp {
|
if serverUp && serverUp != prevServerUp {
|
||||||
sendMessage("@here " + server.Name + " is now online!")
|
sendMessage(config.Config.RoleToNotify + " " + server.Name + " is now online!")
|
||||||
} else if !serverUp && serverUp != prevServerUp {
|
} else if !serverUp && serverUp != prevServerUp {
|
||||||
sendMessage("@here " + server.Name + " went offline!")
|
sendMessage(config.Config.RoleToNotify + " " + server.Name + " went offline!")
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Config.Servers[index].Online = serverUp
|
config.Config.Servers[index].Online = serverUp
|
||||||
|
|||||||
Reference in New Issue
Block a user