Skip to content

Commit

Permalink
feat(alert): add alert action and information to Discord message
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
dgibbs64 committed Oct 16, 2023
1 parent 6cc6cd5 commit 03fbfc9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions lgsm/modules/alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 21 additions & 7 deletions lgsm/modules/alert_discord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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}"
}
}
Expand All @@ -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": {
Expand All @@ -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}"
}
}
Expand Down

0 comments on commit 03fbfc9

Please sign in to comment.