Browse Source

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.
pull/4345/head
Daniel Gibbs 2 years ago
parent
commit
b20dc3aa68
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 1
      lgsm/modules/alert.sh
  2. 30
      lgsm/modules/alert_discord.sh

1
lgsm/modules/alert.sh

@ -30,6 +30,7 @@ fn_alert_log() {
fn_alert_test() { fn_alert_test() {
fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken" fn_script_log_info "Sending alert: Testing LinuxGSM Alert. No action to be taken"
alerttitle="Alert - ${selfname} - Test" alerttitle="Alert - ${selfname} - Test"
alertaction="Tested"
alertemoji="🚧" alertemoji="🚧"
alertsound="1" alertsound="1"
alerturl="not enabled" alerturl="not enabled"

30
lgsm/modules/alert_discord.sh

@ -16,13 +16,13 @@ jsonshortinfo=$(
"embeds": [ "embeds": [
{ {
"author": { "author": {
"name": "${alertemoji} ${alerttitle} ${alertemoji}", "name": "LinuxGSM Alert",
"url": "", "url": "",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg"
}, },
"title": "${servername}", "title": "${alertemoji} ${alertaction} - ${servername} ${alertemoji}",
"url": "", "url": "",
"description": "${alertmessage} \n More info: ${alerturl}", "description": "",
"color": "${alertcolourdec}", "color": "${alertcolourdec}",
"type": "content", "type": "content",
"thumbnail": { "thumbnail": {
@ -43,9 +43,18 @@ jsonshortinfo=$(
"name": "Hostname", "name": "Hostname",
"value": "${HOSTNAME}", "value": "${HOSTNAME}",
"inline": true "inline": true
} },
{
"name": "Information",
"value": "${alertmessage}"
},
{
"name": "More Information",
"value": "${alerturl}"
}
], ],
"footer": { "footer": {
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"text": "Sent by LinuxGSM ${version}" "text": "Sent by LinuxGSM ${version}"
} }
} }
@ -63,13 +72,13 @@ jsonshortnoinfo=$(
"embeds": [ "embeds": [
{ {
"author": { "author": {
"name": "${alertemoji} ${alerttitle} ${alertemoji}", "name": "LinuxGSM Alert",
"url": "", "url": "",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg"
}, },
"title": "${servername}", "title": "${alertemoji} ${alertaction} - ${servername} ${alertemoji}",
"url": "", "url": "",
"description": "${alertmessage}", "description": "",
"color": "${alertcolourdec}", "color": "${alertcolourdec}",
"type": "content", "type": "content",
"thumbnail": { "thumbnail": {
@ -90,9 +99,14 @@ jsonshortnoinfo=$(
"name": "Hostname", "name": "Hostname",
"value": "${HOSTNAME}", "value": "${HOSTNAME}",
"inline": true "inline": true
} },
{
"name": "Information",
"value": "${alertmessage}"
}
], ],
"footer": { "footer": {
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"text": "Sent by LinuxGSM ${version}" "text": "Sent by LinuxGSM ${version}"
} }
} }

Loading…
Cancel
Save