Skip to content

Commit a5e58d4

Browse files
committed
Standardizes alert messages across platforms
Ensures consistency in alert messages across Discord, NTFY, Pushover, Rocketchat, Slack, and Telegram. Updates Discord alerts to include server hostname and time, removes redundant formatting. Standardizes plain-text alert formatting for NTFY. Refactors Pushover messages to use consistent HTML formatting. Streamlines Rocketchat and Slack messages by removing duplicate server info and adding optional link support.
1 parent 65bc057 commit a5e58d4

File tree

6 files changed

+46
-154
lines changed

6 files changed

+46
-154
lines changed

lgsm/modules/alert_discord.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,19 @@ json=$(
4343
"inline": true
4444
},
4545
{
46-
"name": "Address:Port",
46+
"name": "Server IP",
4747
"value": "\`${alertip}:${port}\`",
4848
"inline": true
49+
},
50+
{
51+
"name": "Hostname",
52+
"value": "${HOSTNAME}",
53+
"inline": true
54+
},
55+
{
56+
"name": "Server Time",
57+
"value": "$(date)",
58+
"inline": true
4959
}
5060
EOF
5161
)

lgsm/modules/alert_ntfy.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,34 @@ else
3535
tags="${alertemoji}"
3636
fi
3737

38-
# Construct the message body
39-
message="Server Name: ${servername}
40-
Information: ${alertmessage}
41-
Game: ${gamename}
42-
Server IP: ${alertip}:${port}
43-
Hostname: ${HOSTNAME}
44-
Server Time: $(date)"
38+
# Construct the message body (keep formatting consistent with other plain-text alerts)
39+
message="Server Name
40+
${servername}
41+
42+
Information
43+
${alertmessage}
44+
45+
Game
46+
${gamename}
47+
48+
Server IP
49+
${alertip}:${port}
50+
51+
Hostname
52+
${HOSTNAME}
53+
54+
Server Time
55+
$(date)"
4556

4657
# Add optional links if available
4758
if [ -n "${querytype}" ]; then
48-
message+="\nIs my Game Server Online?: https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}"
59+
message+="\n\nIs my Game Server Online?\nhttps://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}"
4960
fi
5061

5162
# Use alerturl for the click action if available
5263
clickurl=""
5364
if [ -n "${alerturl}" ]; then
54-
message+="\nMore info: ${alerturl}"
65+
message+="\n\nMore info\n${alerturl}"
5566
clickurl="${alerturl}"
5667
fi
5768

lgsm/modules/alert_pushover.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ else
2222
alertpriority="0"
2323
fi
2424

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>"
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>"
2626

2727
if [ -n "${querytype}" ]; then
2828
message+="<b>Is my Game Server Online?</b><br><a href='https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}'>Check here</a><br><br>"
@@ -32,7 +32,7 @@ if [ -n "${alerturl}" ]; then
3232
message+="<b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>"
3333
fi
3434

35-
message+="Server Time<br>$(date)"
35+
message+="<b>Server Time</b><br>$(date)"
3636

3737
pushoversend=$(curl --connect-timeout 3 -sS \
3838
-F token="${pushovertoken}" \

lgsm/modules/alert_rocketchat.sh

Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -40,94 +40,45 @@ json=$(
4040
{
4141
"short": false,
4242
"title": "Server IP",
43-
"value": "${alertip}:${port}"
43+
"value": "\`${alertip}:${port}\`"
4444
},
4545
{
4646
"short": false,
4747
"title": "Hostname",
4848
"value": "${HOSTNAME}"
49-
},
50-
{
51-
"short": false,
52-
"title": "More info",
53-
"value": "${alerturl}"
54-
},
55-
{
56-
"short": false,
57-
"title": "Server Time",
58-
"value": "$(date)"
5949
}
60-
]
61-
}
62-
]
63-
}
6450
EOF
6551
)
6652

6753
if [ -n "${querytype}" ]; then
6854
json+=$(
6955
cat << EOF
56+
,
7057
{
7158
"short": false,
7259
"title": "Is my Game Server Online?",
7360
"value": "<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
74-
},
61+
}
7562
EOF
7663
)
7764
fi
7865

7966
if [ -n "${alerturl}" ]; then
8067
json+=$(
8168
cat << EOF
69+
,
8270
{
8371
"short": false,
8472
"title": "More info",
8573
"value": "${alerturl}"
86-
},
74+
}
8775
EOF
8876
)
8977
fi
9078

9179
json+=$(
9280
cat << EOF
93-
{
94-
"alias": "LinuxGSM",
95-
"text": "*${alerttitle}*",
96-
"attachments": [
97-
{
98-
"title": "",
99-
"color": "${alertcolourhex}",
100-
"author_name": "LinuxGSM Alert",
101-
"author_link": "https://linuxgsm.com",
102-
"author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
103-
"thumb_url": "${alerticon}",
104-
"text": "",
105-
"fields": [
106-
{
107-
"short": false,
108-
"title": "Server Name",
109-
"value": "${servername}"
110-
},
111-
{
112-
"short": false,
113-
"title": "Information",
114-
"value": "${alertmessage}"
115-
},
116-
{
117-
"short": false,
118-
"title": "Game",
119-
"value": "${gamename}"
120-
},
121-
{
122-
"short": false,
123-
"title": "Server IP",
124-
"value": "${alertip}:${port}"
125-
},
126-
{
127-
"short": false,
128-
"title": "Hostname",
129-
"value": "${HOSTNAME}"
130-
},
81+
,
13182
{
13283
"short": false,
13384
"title": "Server Time",

lgsm/modules/alert_slack.sh

Lines changed: 6 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -62,124 +62,44 @@ json=$(
6262
"accessory": {
6363
"type": "image",
6464
"image_url": "${alerticon}",
65-
"alt_text": "cute cat"
65+
"alt_text": "LinuxGSM game icon"
6666
}
67-
},
68-
{
69-
"type": "context",
70-
"elements": [
71-
{
72-
"type": "image",
73-
"image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
74-
"alt_text": "LinuxGSM icon"
75-
},
76-
{
77-
"type": "plain_text",
78-
"text": "Sent by LinuxGSM ${version}",
79-
"emoji": true
80-
}
81-
]
82-
}
83-
]
84-
}
85-
]
86-
}
8767
EOF
8868
)
8969

9070
if [ -n "${querytype}" ]; then
9171
json+=$(
9272
cat << EOF
73+
,
9374
{
9475
"type": "section",
9576
"text": {
9677
"type": "mrkdwn",
9778
"text": "*Is my Game Server Online?*\n<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
9879
}
99-
},
80+
}
10081
EOF
10182
)
10283
fi
10384

10485
if [ -n "${alerturl}" ]; then
10586
json+=$(
10687
cat << EOF
88+
,
10789
{
10890
"type": "section",
10991
"text": {
11092
"type": "mrkdwn",
11193
"text": "*More info*\n<${alerturl}|${alerturl}>"
11294
}
113-
},
95+
}
11496
EOF
11597
)
11698
fi
11799

118100
json+=$(
119101
cat << EOF
120-
{
121-
"attachments": [
122-
{
123-
"color": "${alertcolourhex}",
124-
"blocks": [
125-
{
126-
"type": "header",
127-
"text": {
128-
"type": "mrkdwn",
129-
"text": "${alerttitle}",
130-
"emoji": true
131-
}
132-
},
133-
{
134-
"type": "divider"
135-
},
136-
{
137-
"type": "section",
138-
"text": {
139-
"type": "mrkdwn",
140-
"text": "*Server Name*\n${servername}"
141-
}
142-
},
143-
{
144-
"type": "section",
145-
"text": {
146-
"type": "mrkdwn",
147-
"text": "*Information*\n${alertmessage}"
148-
}
149-
},
150-
{
151-
"type": "section",
152-
"fields": [
153-
{
154-
"type": "mrkdwn",
155-
"text": "*Game*\n${gamename}"
156-
},
157-
{
158-
"type": "mrkdwn",
159-
"text": "*Server IP*\n\`${alertip}:${port}\`"
160-
},
161-
{
162-
"type": "mrkdwn",
163-
"text": "*Hostname*\n${HOSTNAME}"
164-
},
165-
{
166-
"type": "mrkdwn",
167-
"text": "*Server Time*\n$(date)"
168-
}
169-
],
170-
"accessory": {
171-
"type": "image",
172-
"image_url": "${alerticon}",
173-
"alt_text": "cute cat"
174-
}
175-
},
176-
{
177-
"type": "section",
178-
"text": {
179-
"type": "mrkdwn",
180-
"text": "*Server Time*\n${alertmessage}"
181-
}
182-
},
102+
,
183103
{
184104
"type": "context",
185105
"elements": [

lgsm/modules/alert_telegram.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ json=$(
1414
"message_thread_id": "${telegramthreadid}",
1515
"parse_mode": "HTML",
1616
"disable_notification": "${telegramdisablenotification}",
17-
"text": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n
17+
"text": "<b>${alerttitle}</b>\n\n<b>Server Name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n
1818
EOF
1919
)
2020

0 commit comments

Comments
 (0)