mirror of
https://github.com/mgerb/ServerStatus
synced 2026-01-11 03:32:50 +00:00
add multiple room ID's for notifications
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Token": "your_bot_token_id",
|
"Token": "your_bot_token_id",
|
||||||
"AlertRoomID": "your_room_id",
|
"RoomIDList": ["id_1", "id_2", "id_3"],
|
||||||
"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.
2
dist/config.json
vendored
2
dist/config.json
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Token": "your_bot_token_id",
|
"Token": "your_bot_token_id",
|
||||||
"AlertRoomID": "your_room_id",
|
"RoomIDList": ["id_1", "id_2", "id_3"],
|
||||||
"Servers": [
|
"Servers": [
|
||||||
{
|
{
|
||||||
"Name": "Elysium PvP",
|
"Name": "Elysium PvP",
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
var Config configStruct
|
var Config configStruct
|
||||||
|
|
||||||
type configStruct struct {
|
type configStruct struct {
|
||||||
Token string `json:"Token"`
|
Token string `json:"Token"`
|
||||||
AlertRoomID string `json:"AlertRoomID"`
|
RoomIDList []string `json:"RoomIDList"`
|
||||||
Servers []server `json:"Servers"`
|
Servers []server `json:"Servers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type server struct {
|
type server struct {
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ func loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sendMessage(message string) {
|
func sendMessage(message string) {
|
||||||
bot.Session.ChannelMessageSend(config.Config.AlertRoomID, message)
|
for _, roomID := range config.Config.RoomIDList {
|
||||||
|
bot.Session.ChannelMessageSend(roomID, message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function will be called every time a new
|
// This function will be called every time a new
|
||||||
@@ -66,7 +68,7 @@ func MessageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
if server.Online {
|
if server.Online {
|
||||||
s.ChannelMessageSend(m.ChannelID, server.Name+" is online!")
|
s.ChannelMessageSend(m.ChannelID, server.Name+" is online!")
|
||||||
} else {
|
} else {
|
||||||
s.ChannelMessageSend(m.ChannelID, server.Name+"is down!")
|
s.ChannelMessageSend(m.ChannelID, server.Name+" is down!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user