From 892a633d9d176f9c332c97d8f545ccfb0ae5a5d3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Wed, 18 Oct 2023 00:00:12 +0100 Subject: [PATCH] refactor: improve alert message formatting - Refactored the code in `alert_pushover.sh` and `alert_telegram.sh` to improve the formatting of the alert messages. - Updated the message structure to include the server name before other information. - Added line breaks for better readability. - Made sure that all variables are properly interpolated within the messages. --- lgsm/modules/alert_pushover.sh | 4 ++-- lgsm/modules/alert_telegram.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lgsm/modules/alert_pushover.sh b/lgsm/modules/alert_pushover.sh index 48009ab2c2..05dfd0bb7f 100644 --- a/lgsm/modules/alert_pushover.sh +++ b/lgsm/modules/alert_pushover.sh @@ -23,9 +23,9 @@ else fi if [ -z "${alerturl}" ]; then - pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}" "https://api.pushover.net/1/messages.json" | grep errors) + pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message="Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}" "https://api.pushover.net/1/messages.json" | grep errors) else - pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

More info
${alerturl}" "https://api.pushover.net/1/messages.json" | grep errors) + pushoversend=$(curl --connect-timeout 10 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message="Server name
${servername}

Information
${alertmessage}

Game
${gamename}

Server IP
${alertip}:${port}

Hostname
${HOSTNAME}

More info
${alerturl}" "https://api.pushover.net/1/messages.json" | grep errors) fi if [ -n "${pushoversend}" ]; then diff --git a/lgsm/modules/alert_telegram.sh b/lgsm/modules/alert_telegram.sh index fb89263a6e..1a03aec132 100644 --- a/lgsm/modules/alert_telegram.sh +++ b/lgsm/modules/alert_telegram.sh @@ -12,7 +12,7 @@ jsoninfo=$( { "chat_id": "${telegramchatid}", "parse_mode": "HTML", - "text": "${alerttitle}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}", + "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\nMore info\n${alerturl}", "disable_web_page_preview": "yes" } EOF @@ -23,7 +23,7 @@ jsonnoinfo=$( { "chat_id": "${telegramchatid}", "parse_mode": "HTML", - "text": "${alerttitle}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}", + "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}", "disable_web_page_preview": "yes" } EOF