From 450e0fc4235dec92f357fe9d74fe3be45aee7eb0 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Mon, 15 Oct 2018 20:16:15 -0700 Subject: [PATCH] Design tweaks and JSON-safe escaping string --- lgsm/functions/alert_discord.sh | 92 +++++++++++++++++---------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/lgsm/functions/alert_discord.sh b/lgsm/functions/alert_discord.sh index 4818f8721..75c8be2f0 100644 --- a/lgsm/functions/alert_discord.sh +++ b/lgsm/functions/alert_discord.sh @@ -5,60 +5,62 @@ # Website: https://linuxgsm.com # Description: Sends Discord alert. +if ! command -v jq > /dev/null; then + fn_print_fail_nl "Sending Discord alert: jq is missing." + fn_script_log_fatal "Sending Discord alert: jq is missing." +fi + +EscapedServername="$(echo -n "${servername}" | jq -sRr "@json")" +EscapedAlertBody="$(echo -n "${alertbody}" | jq -sRr "@json")" + +echo "$servername" > /tmp/servername + json=$(cat <