Skip to content

Commit 8d17622

Browse files
authored
feat: add ismygameserver.online links (#4742)
1 parent 81c4f80 commit 8d17622

11 files changed

+205
-169
lines changed

lgsm/modules/alert_discord.sh

+10-87
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
99

10-
jsoninfo=$(
10+
json=$(
1111
cat << EOF
1212
{
1313
"username": "LinuxGSM",
@@ -29,103 +29,32 @@ jsoninfo=$(
2929
"url": "${alerticon}"
3030
},
3131
"fields": [
32-
{
33-
"name": "Server Name",
34-
"value": "${servername}"
35-
},
36-
{
37-
"name": "Information",
38-
"value": "${alertmessage}"
39-
},
4032
{
41-
"name": "Game",
42-
"value": "${gamename}",
43-
"inline": true
33+
"name": "Server Name",
34+
"value": "${servername}"
4435
},
4536
{
46-
"name": "Server IP",
47-
"value": "\`${alertip}:${port}\`",
48-
"inline": true
49-
},
50-
{
51-
"name": "Hostname",
52-
"value": "${HOSTNAME}",
53-
"inline": true
37+
"name": "Information",
38+
"value": "${alertmessage}"
5439
},
55-
{
56-
"name": "More info",
57-
"value": "${alerturl}",
58-
"inline": true
59-
},
60-
{
61-
"name": "Server Time",
62-
"value": "$(date)",
63-
"inline": true
64-
}
65-
],
66-
"footer": {
67-
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
68-
"text": "Sent by LinuxGSM ${version}"
69-
}
70-
}
71-
]
72-
}
73-
EOF
74-
)
75-
76-
jsonnoinfo=$(
77-
cat << EOF
78-
{
79-
"username": "LinuxGSM",
80-
"avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
81-
"file": "content",
82-
"embeds": [
83-
{
84-
"author": {
85-
"name": "LinuxGSM Alert",
86-
"url": "",
87-
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg"
88-
},
89-
"title": "${alerttitle}",
90-
"url": "",
91-
"description": "",
92-
"color": "${alertcolourdec}",
93-
"type": "content",
94-
"thumbnail": {
95-
"url": "${alerticon}"
96-
},
97-
"fields": [
98-
{
99-
"name": "Server Name",
100-
"value": "${servername}"
101-
},
102-
{
103-
"name": "Information",
104-
"value": "${alertmessage}"
105-
},
10640
{
10741
"name": "Game",
10842
"value": "${gamename}",
10943
"inline": true
11044
},
11145
{
112-
"name": "Server IP",
113-
"value": "\`${alertip}:${port}\`",
114-
"inline": true
115-
},
116-
{
117-
"name": "Hostname",
118-
"value": "${HOSTNAME}",
46+
"name": "Server Time",
47+
"value": "$(date)",
11948
"inline": true
12049
},
12150
{
122-
"name": "Server Time",
123-
"value": "$(date)",
51+
"name": "Is my Game Server Online?",
52+
"value": "https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}",
12453
"inline": true
12554
}
12655
],
12756
"footer": {
128-
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
57+
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
12958
"text": "Sent by LinuxGSM ${version}"
13059
}
13160
}
@@ -136,12 +65,6 @@ EOF
13665

13766
fn_print_dots "Sending Discord alert"
13867

139-
if [ -z "${alerturl}" ]; then
140-
json="${jsonnoinfo}"
141-
else
142-
json="${jsoninfo}"
143-
fi
144-
14568
discordsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}")
14669

14770
if [ -n "${discordsend}" ]; then

lgsm/modules/alert_gotify.sh

+20-14
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,38 @@
77

88
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
99

10-
jsoninfo=$(
10+
json=$(
1111
cat << EOF
1212
{
1313
"title": "${alerttitle}",
14-
"message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)",
15-
"priority": 5
16-
}
14+
"message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n
1715
EOF
1816
)
1917

20-
jsonnoinfo=$(
18+
if [ -n "${querytype}" ]; then
19+
json+=$(
20+
cat << EOF
21+
Is my Game Server Online?\nhttps://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}\n\n
22+
EOF
23+
)
24+
fi
25+
26+
if [ -n "${alerturl}" ]; then
27+
json+=$(
28+
cat << EOF
29+
More info\n${alerturl}\n\n
30+
EOF
31+
)
32+
fi
33+
34+
json+=$(
2135
cat << EOF
22-
{
23-
"title": "${alerttitle}",
24-
"message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)",
36+
Server Time\n$(date)",
2537
"priority": 5
2638
}
2739
EOF
2840
)
2941

30-
if [ -z "${alerturl}" ]; then
31-
json="${jsonnoinfo}"
32-
else
33-
json="${jsoninfo}"
34-
fi
35-
3642
fn_print_dots "Sending Gotify alert"
3743
gotifysend=$(curl --connect-timeout 3 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")
3844

lgsm/modules/alert_ifttt.sh

+20-14
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,38 @@
77

88
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
99

10-
jsoninfo=$(
10+
json=$(
1111
cat << EOF
1212
{
1313
"value1": "${selfname}",
1414
"value2": "${alerttitle}",
15-
"value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)"
16-
}
15+
"value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n
1716
EOF
1817
)
1918

20-
jsonnoinfo=$(
19+
if [ -n "${querytype}" ]; then
20+
json+=$(
21+
cat << EOF
22+
Is my Game Server Online?\nhttps://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}\n\n
23+
EOF
24+
)
25+
fi
26+
27+
if [ -n "${alerturl}" ]; then
28+
json+=$(
29+
cat << EOF
30+
More info\n${alerturl}\n\n
31+
EOF
32+
)
33+
fi
34+
35+
json+=$(
2136
cat << EOF
22-
{
23-
"value1": "${selfname}",
24-
"value2": "${alerttitle}",
25-
"value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)"
37+
Server Time\n$(date)"
2638
}
2739
EOF
2840
)
2941

30-
if [ -z "${alerturl}" ]; then
31-
json="${jsonnoinfo}"
32-
else
33-
json="${jsoninfo}"
34-
fi
35-
3642
fn_print_dots "Sending IFTTT alert"
3743
iftttsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")
3844

lgsm/modules/alert_pushbullet.sh

+20-15
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,39 @@
77

88
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
99

10-
jsoninfo=$(
10+
json=$(
1111
cat << EOF
1212
{
1313
"channel_tag": "${channeltag}",
1414
"type": "note",
1515
"title": "${alerttitle}",
16-
"body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)"
17-
}
16+
"body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n
1817
EOF
1918
)
2019

21-
jsonnoinfo=$(
20+
if [ -n "${querytype}" ]; then
21+
json+=$(
22+
cat << EOF
23+
Is my Game Server Online?\nhttps://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}\n\n
24+
EOF
25+
)
26+
fi
27+
28+
if [ -n "${alerturl}" ]; then
29+
json+=$(
30+
cat << EOF
31+
More info\n${alerturl}\n\n
32+
EOF
33+
)
34+
fi
35+
36+
json+=$(
2237
cat << EOF
23-
{
24-
"channel_tag": "${channeltag}",
25-
"type": "note",
26-
"title": "${alerttitle}",
27-
"body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)"
38+
Server Time\n$(date)"
2839
}
2940
EOF
3041
)
3142

32-
if [ -z "${alerturl}" ]; then
33-
json="${jsonnoinfo}"
34-
else
35-
json="${jsoninfo}"
36-
fi
37-
3843
fn_print_dots "Sending Pushbullet alert"
3944
pushbulletsend=$(curl --connect-timeout 3 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://api.pushbullet.com/v2/pushes" | grep "error_code")
4045

lgsm/modules/alert_pushover.sh

+20-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,28 @@ else
2222
alertpriority="0"
2323
fi
2424

25-
if [ -z "${alerturl}" ]; then
26-
pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
27-
else
28-
pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
25+
message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>"
26+
27+
if [ -n "${querytype}" ]; then
28+
message+="<b>Is my Game Server Online?</b><br><a href='https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}'>Check here</a><br><br>"
29+
fi
30+
31+
if [ -n "${alerturl}" ]; then
32+
message+="<b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>"
2933
fi
3034

35+
message+="Server Time<br>$(date)"
36+
37+
pushoversend=$(curl --connect-timeout 3 -sS \
38+
-F token="${pushovertoken}" \
39+
-F user="${pushoveruserkey}" \
40+
-F html="1" \
41+
-F sound="${alertsound}" \
42+
-F priority="${alertpriority}" \
43+
-F title="${alerttitle}" \
44+
-F message="${message}" \
45+
"https://api.pushover.net/1/messages.json" | grep errors)
46+
3147
if [ -n "${pushoversend}" ]; then
3248
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
3349
fn_script_log_fail "Sending Pushover alert: ${pushoversend}"

lgsm/modules/alert_rocketchat.sh

+26-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
99

10-
jsoninfo=$(
10+
json=$(
1111
cat << EOF
1212
{
1313
"alias": "LinuxGSM",
@@ -64,7 +64,31 @@ jsoninfo=$(
6464
EOF
6565
)
6666

67-
jsonnoinfo=$(
67+
if [ -n "${querytype}" ]; then
68+
json+=$(
69+
cat << EOF
70+
{
71+
"short": false,
72+
"title": "Is my Game Server Online?",
73+
"value": "<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
74+
},
75+
EOF
76+
)
77+
fi
78+
79+
if [ -n "${alerturl}" ]; then
80+
json+=$(
81+
cat << EOF
82+
{
83+
"short": false,
84+
"title": "More info",
85+
"value": "${alerturl}"
86+
},
87+
EOF
88+
)
89+
fi
90+
91+
json+=$(
6892
cat << EOF
6993
{
7094
"alias": "LinuxGSM",
@@ -116,12 +140,6 @@ jsonnoinfo=$(
116140
EOF
117141
)
118142

119-
if [ -z "${alerturl}" ]; then
120-
json="${jsonnoinfo}"
121-
else
122-
json="${jsoninfo}"
123-
fi
124-
125143
fn_print_dots "Sending Rocketchat alert"
126144
rocketchatsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}")
127145

0 commit comments

Comments
 (0)