diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index 162b296eb..364d76f10 100755 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -7,9 +7,6 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" fn_alert_log(){ - info_distro.sh - info_config.sh - info_messages.sh if [ -f "${alertlog}" ]; then rm -f "${alertlog:?}" fi @@ -78,6 +75,14 @@ fn_alert_config(){ alertbody="${selfname} has received a new _default.cfg. Check file for changes." } +info_distro.sh +info_config.sh +info_messages.sh + +# JSON-safe escaping string. - use this is json based alerts +escaped_servername=$(echo -n "${servername}" | jq -sRr "@json") +escaped_alertbody=$(echo -n "${alertbody}" | jq -sRr "@json") + if [ "${alert}" == "permissions" ]; then fn_alert_permissions elif [ "${alert}" == "restart" ]; then diff --git a/lgsm/functions/alert_discord.sh b/lgsm/functions/alert_discord.sh index ac9923d09..8c126c384 100755 --- a/lgsm/functions/alert_discord.sh +++ b/lgsm/functions/alert_discord.sh @@ -12,9 +12,6 @@ if ! command -v jq > /dev/null; then fn_script_log_fatal "Sending Discord alert: jq is missing." fi -escaped_servername=$(echo -n "${servername}" | jq -sRr "@json") -escaped_alertbody=$(echo -n "${alertbody}" | jq -sRr "@json") - json=$(cat <${alertemoji} ${alertsubject} ${alertemoji}\n\nMessage\n${alertbody}\n\nGame\n${gamename}\n\nServer name\n${servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${alertip}:${port}\n\nMore info\n${alerturl}", + "text": "${alertemoji} ${alertsubject} ${alertemoji}\n\nMessage\n${escaped_alertbody}\n\nGame\n${gamename}\n\nServer name\n${escaped_servername}\n\nHostname\n${HOSTNAME}\n\nServer IP\n${alertip}:${port}\n\nMore info\n${alerturl}", "disable_web_page_preview": "yes", EOF )