From 03fbfc9089f0fd02ea44c5bb121cd58821e84d0f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 17 Oct 2023 00:01:43 +0100 Subject: [PATCH] feat(alert): add alert action and information to Discord message - Added a new variable `alertaction` to store the action performed in the alert - Modified the Discord message template to include the alert action and information - Updated the author name in the Discord message template to "LinuxGSM Alert" The changes allow for more informative and descriptive alerts in Discord messages. --- lgsm/modules/alert.sh | 1 + lgsm/modules/alert_discord.sh | 28 +++++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lgsm/modules/alert.sh b/lgsm/modules/alert.sh index 3e7c2d199d..f8734150c9 100644 --- a/lgsm/modules/alert.sh +++ b/lgsm/modules/alert.sh @@ -30,6 +30,7 @@ fn_alert_log() { fn_alert_test() { fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken" alerttitle="Alert - ${selfname} - Test" + alertaction="Tested" alertemoji="🚧" alertsound="1" alerturl="not enabled" diff --git a/lgsm/modules/alert_discord.sh b/lgsm/modules/alert_discord.sh index 2296503181..48a4e999b4 100644 --- a/lgsm/modules/alert_discord.sh +++ b/lgsm/modules/alert_discord.sh @@ -16,13 +16,13 @@ jsonshortinfo=$( "embeds": [ { "author": { - "name": "${alertemoji} ${alerttitle} ${alertemoji}", + "name": "LinuxGSM Alert", "url": "", "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" }, - "title": "${servername}", + "title": "${alertemoji} ${alertaction} - ${servername}", "url": "", - "description": "${alertmessage} \n More info: ${alerturl}", + "description": "", "color": "${alertcolourdec}", "type": "content", "thumbnail": { @@ -43,9 +43,18 @@ jsonshortinfo=$( "name": "Hostname", "value": "${HOSTNAME}", "inline": true - } + }, + { + "name": "Information", + "value": "${alertmessage}" + }, + { + "name": "More Information", + "value": "${alerturl}" + } ], "footer": { + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "text": "Sent by LinuxGSM ${version}" } } @@ -63,13 +72,13 @@ jsonshortnoinfo=$( "embeds": [ { "author": { - "name": "${alertemoji} ${alerttitle} ${alertemoji}", + "name": "LinuxGSM Alert", "url": "", "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" }, "title": "${servername}", "url": "", - "description": "${alertmessage}", + "description": "${alertemoji} ${alerttitle} ${alertemoji}", "color": "${alertcolourdec}", "type": "content", "thumbnail": { @@ -90,9 +99,14 @@ jsonshortnoinfo=$( "name": "Hostname", "value": "${HOSTNAME}", "inline": true - } + }, + { + "name": "Information", + "value": "${alertmessage}" + } ], "footer": { + "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "text": "Sent by LinuxGSM ${version}" } }