From a5e58d47926d43675118790f9869ad54d8cc0eb1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 8 Feb 2026 22:27:48 +0000 Subject: [PATCH] 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. --- lgsm/modules/alert_discord.sh | 12 ++++- lgsm/modules/alert_ntfy.sh | 29 ++++++---- lgsm/modules/alert_pushover.sh | 4 +- lgsm/modules/alert_rocketchat.sh | 61 +++------------------ lgsm/modules/alert_slack.sh | 92 +++----------------------------- lgsm/modules/alert_telegram.sh | 2 +- 6 files changed, 46 insertions(+), 154 deletions(-) diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index a445cf813..359704d56 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -43,9 +43,19 @@ json=$( "inline": true }, { - "name": "Address:Port", + "name": "Server IP", "value": "\`${alertip}:${port}\`", "inline": true + }, + { + "name": "Hostname", + "value": "${HOSTNAME}", + "inline": true + }, + { + "name": "Server Time", + "value": "$(date)", + "inline": true } EOF ) diff --git a/lgsm/modules/alert_ntfy.sh b/lgsm/modules/alert_ntfy.sh index 35e3f4c55..27e6b8f53 100644 --- a/lgsm/modules/alert_ntfy.sh +++ b/lgsm/modules/alert_ntfy.sh @@ -35,23 +35,34 @@ else tags="${alertemoji}" fi -# Construct the message body -message="Server Name: ${servername} -Information: ${alertmessage} -Game: ${gamename} -Server IP: ${alertip}:${port} -Hostname: ${HOSTNAME} -Server Time: $(date)" +# Construct the message body (keep formatting consistent with other plain-text alerts) +message="Server Name +${servername} + +Information +${alertmessage} + +Game +${gamename} + +Server IP +${alertip}:${port} + +Hostname +${HOSTNAME} + +Server Time +$(date)" # Add optional links if available 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 # Use alerturl for the click action if available clickurl="" if [ -n "${alerturl}" ]; then - message+="\nMore info: ${alerturl}" + message+="\n\nMore info\n${alerturl}" clickurl="${alerturl}" fi diff --git a/lgsm/modules/alert_pushover.sh b/lgsm/modules/alert_pushover.sh index 8dc0ce2dc..b2f92a453 100644 --- a/lgsm/modules/alert_pushover.sh +++ b/lgsm/modules/alert_pushover.sh @@ -22,7 +22,7 @@ else alertpriority="0" fi -message=" Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

" +message=" Server Name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

" if [ -n "${querytype}" ]; then message+="Is my Game Server Online?
Check here

" @@ -32,7 +32,7 @@ if [ -n "${alerturl}" ]; then message+="More info
${alerturl}

" fi -message+="Server Time
$(date)" +message+="Server Time
$(date)" pushoversend=$(curl --connect-timeout 3 -sS \ -F token="${pushovertoken}" \ diff --git a/lgsm/modules/alert_rocketchat.sh b/lgsm/modules/alert_rocketchat.sh index 35bcf4928..87bd3faac 100644 --- a/lgsm/modules/alert_rocketchat.sh +++ b/lgsm/modules/alert_rocketchat.sh @@ -40,38 +40,25 @@ json=$( { "short": false, "title": "Server IP", - "value": "${alertip}:${port}" + "value": "\`${alertip}:${port}\`" }, { "short": false, "title": "Hostname", "value": "${HOSTNAME}" - }, - { - "short": false, - "title": "More info", - "value": "${alerturl}" - }, - { - "short": false, - "title": "Server Time", - "value": "$(date)" } - ] - } - ] -} EOF ) if [ -n "${querytype}" ]; then json+=$( cat << EOF + , { "short": false, "title": "Is my Game Server Online?", "value": "" - }, + } EOF ) fi @@ -79,55 +66,19 @@ fi if [ -n "${alerturl}" ]; then json+=$( cat << EOF + , { "short": false, "title": "More info", "value": "${alerturl}" - }, + } EOF ) fi json+=$( 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, "title": "Server Time", diff --git a/lgsm/modules/alert_slack.sh b/lgsm/modules/alert_slack.sh index 0a1e9015e..22f7f1048 100644 --- a/lgsm/modules/alert_slack.sh +++ b/lgsm/modules/alert_slack.sh @@ -62,41 +62,22 @@ json=$( "accessory": { "type": "image", "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 ) if [ -n "${querytype}" ]; then json+=$( cat << EOF + , { "type": "section", "text": { "type": "mrkdwn", "text": "*Is my Game Server Online?*\n" } - }, + } EOF ) fi @@ -104,82 +85,21 @@ fi if [ -n "${alerturl}" ]; then json+=$( cat << EOF + , { "type": "section", "text": { "type": "mrkdwn", "text": "*More info*\n<${alerturl}|${alerturl}>" } - }, + } EOF ) fi json+=$( 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", "elements": [ diff --git a/lgsm/modules/alert_telegram.sh b/lgsm/modules/alert_telegram.sh index d7c9b8447..6261f92b2 100644 --- a/lgsm/modules/alert_telegram.sh +++ b/lgsm/modules/alert_telegram.sh @@ -14,7 +14,7 @@ json=$( "message_thread_id": "${telegramthreadid}", "parse_mode": "HTML", "disable_notification": "${telegramdisablenotification}", - "text": "${alerttitle}\n\nServer name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n + "text": "${alerttitle}\n\nServer Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n EOF )