Browse Source

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.
pull/4854/head
Daniel Gibbs 5 months ago
parent
commit
a5e58d4792
Failed to extract signature
  1. 12
      lgsm/modules/alert_discord.sh
  2. 29
      lgsm/modules/alert_ntfy.sh
  3. 4
      lgsm/modules/alert_pushover.sh
  4. 61
      lgsm/modules/alert_rocketchat.sh
  5. 92
      lgsm/modules/alert_slack.sh
  6. 2
      lgsm/modules/alert_telegram.sh

12
lgsm/modules/alert_discord.sh

@ -43,9 +43,19 @@ json=$(
"inline": true "inline": true
}, },
{ {
"name": "Address:Port", "name": "Server IP",
"value": "\`${alertip}:${port}\`", "value": "\`${alertip}:${port}\`",
"inline": true "inline": true
},
{
"name": "Hostname",
"value": "${HOSTNAME}",
"inline": true
},
{
"name": "Server Time",
"value": "$(date)",
"inline": true
} }
EOF EOF
) )

29
lgsm/modules/alert_ntfy.sh

@ -35,23 +35,34 @@ else
tags="${alertemoji}" tags="${alertemoji}"
fi fi
# Construct the message body # Construct the message body (keep formatting consistent with other plain-text alerts)
message="Server Name: ${servername} message="Server Name
Information: ${alertmessage} ${servername}
Game: ${gamename}
Server IP: ${alertip}:${port} Information
Hostname: ${HOSTNAME} ${alertmessage}
Server Time: $(date)"
Game
${gamename}
Server IP
${alertip}:${port}
Hostname
${HOSTNAME}
Server Time
$(date)"
# Add optional links if available # Add optional links if available
if [ -n "${querytype}" ]; then if [ -n "${querytype}" ]; then
message+="\nIs my Game Server Online?: https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}" message+="\n\nIs my Game Server Online?\nhttps://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}"
fi fi
# Use alerturl for the click action if available # Use alerturl for the click action if available
clickurl="" clickurl=""
if [ -n "${alerturl}" ]; then if [ -n "${alerturl}" ]; then
message+="\nMore info: ${alerturl}" message+="\n\nMore info\n${alerturl}"
clickurl="${alerturl}" clickurl="${alerturl}"
fi fi

4
lgsm/modules/alert_pushover.sh

@ -22,7 +22,7 @@ else
alertpriority="0" alertpriority="0"
fi fi
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>" 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>"
if [ -n "${querytype}" ]; then if [ -n "${querytype}" ]; then
message+="<b>Is my Game Server Online?</b><br><a href='https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}'>Check here</a><br><br>" 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
message+="<b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>" message+="<b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>"
fi fi
message+="Server Time<br>$(date)" message+="<b>Server Time</b><br>$(date)"
pushoversend=$(curl --connect-timeout 3 -sS \ pushoversend=$(curl --connect-timeout 3 -sS \
-F token="${pushovertoken}" \ -F token="${pushovertoken}" \

61
lgsm/modules/alert_rocketchat.sh

@ -40,38 +40,25 @@ json=$(
{ {
"short": false, "short": false,
"title": "Server IP", "title": "Server IP",
"value": "${alertip}:${port}" "value": "\`${alertip}:${port}\`"
}, },
{ {
"short": false, "short": false,
"title": "Hostname", "title": "Hostname",
"value": "${HOSTNAME}" "value": "${HOSTNAME}"
},
{
"short": false,
"title": "More info",
"value": "${alerturl}"
},
{
"short": false,
"title": "Server Time",
"value": "$(date)"
} }
]
}
]
}
EOF EOF
) )
if [ -n "${querytype}" ]; then if [ -n "${querytype}" ]; then
json+=$( json+=$(
cat << EOF cat << EOF
,
{ {
"short": false, "short": false,
"title": "Is my Game Server Online?", "title": "Is my Game Server Online?",
"value": "<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>" "value": "<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
}, }
EOF EOF
) )
fi fi
@ -79,55 +66,19 @@ fi
if [ -n "${alerturl}" ]; then if [ -n "${alerturl}" ]; then
json+=$( json+=$(
cat << EOF cat << EOF
,
{ {
"short": false, "short": false,
"title": "More info", "title": "More info",
"value": "${alerturl}" "value": "${alerturl}"
}, }
EOF EOF
) )
fi fi
json+=$( json+=$(
cat << EOF cat << EOF
{ ,
"alias": "LinuxGSM",
"text": "*${alerttitle}*",
"attachments": [
{
"title": "",
"color": "${alertcolourhex}",
"author_name": "LinuxGSM Alert",
"author_link": "https://linuxgsm.com",
"author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"thumb_url": "${alerticon}",
"text": "",
"fields": [
{
"short": false,
"title": "Server Name",
"value": "${servername}"
},
{
"short": false,
"title": "Information",
"value": "${alertmessage}"
},
{
"short": false,
"title": "Game",
"value": "${gamename}"
},
{
"short": false,
"title": "Server IP",
"value": "${alertip}:${port}"
},
{
"short": false,
"title": "Hostname",
"value": "${HOSTNAME}"
},
{ {
"short": false, "short": false,
"title": "Server Time", "title": "Server Time",

92
lgsm/modules/alert_slack.sh

@ -62,41 +62,22 @@ json=$(
"accessory": { "accessory": {
"type": "image", "type": "image",
"image_url": "${alerticon}", "image_url": "${alerticon}",
"alt_text": "cute cat" "alt_text": "LinuxGSM game icon"
} }
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"alt_text": "LinuxGSM icon"
},
{
"type": "plain_text",
"text": "Sent by LinuxGSM ${version}",
"emoji": true
}
]
}
]
}
]
}
EOF EOF
) )
if [ -n "${querytype}" ]; then if [ -n "${querytype}" ]; then
json+=$( json+=$(
cat << EOF cat << EOF
,
{ {
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Is my Game Server Online?*\n<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>" "text": "*Is my Game Server Online?*\n<https://ismygameserver.online/${imgsoquerytype}/${alertip}:${queryport}|Check here>"
} }
}, }
EOF EOF
) )
fi fi
@ -104,82 +85,21 @@ fi
if [ -n "${alerturl}" ]; then if [ -n "${alerturl}" ]; then
json+=$( json+=$(
cat << EOF cat << EOF
,
{ {
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*More info*\n<${alerturl}|${alerturl}>" "text": "*More info*\n<${alerturl}|${alerturl}>"
} }
}, }
EOF EOF
) )
fi fi
json+=$( json+=$(
cat << EOF cat << EOF
{ ,
"attachments": [
{
"color": "${alertcolourhex}",
"blocks": [
{
"type": "header",
"text": {
"type": "mrkdwn",
"text": "${alerttitle}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Server Name*\n${servername}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Information*\n${alertmessage}"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Game*\n${gamename}"
},
{
"type": "mrkdwn",
"text": "*Server IP*\n\`${alertip}:${port}\`"
},
{
"type": "mrkdwn",
"text": "*Hostname*\n${HOSTNAME}"
},
{
"type": "mrkdwn",
"text": "*Server Time*\n$(date)"
}
],
"accessory": {
"type": "image",
"image_url": "${alerticon}",
"alt_text": "cute cat"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Server Time*\n${alertmessage}"
}
},
{ {
"type": "context", "type": "context",
"elements": [ "elements": [

2
lgsm/modules/alert_telegram.sh

@ -14,7 +14,7 @@ json=$(
"message_thread_id": "${telegramthreadid}", "message_thread_id": "${telegramthreadid}",
"parse_mode": "HTML", "parse_mode": "HTML",
"disable_notification": "${telegramdisablenotification}", "disable_notification": "${telegramdisablenotification}",
"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 "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
EOF EOF
) )

Loading…
Cancel
Save