Browse Source

feat: add alert icon and footer to Discord alerts

- Added a new variable `alerticon` to store the URL of the alert icon image.
- Included the `alerticon` in the JSON payload for both short info and no info alerts.
- Added a footer with text "Sent by LinuxGSM v23.5.3" to the JSON payload for both short info and no info alerts.

This commit enhances the appearance of Discord alerts by adding an icon, a footer, and additional information about the sender.
pull/4345/head
Daniel Gibbs 2 years ago
parent
commit
c8893c23cf
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 3
      lgsm/modules/alert.sh
  2. 145
      lgsm/modules/alert_discord.sh

3
lgsm/modules/alert.sh

@ -174,6 +174,9 @@ fn_alert_info() {
alertcolourdec="2003199" alertcolourdec="2003199"
} }
# Images
alerticon="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/gameicons/${shortname}-icon.png"
if [ "${alert}" == "permissions" ]; then if [ "${alert}" == "permissions" ]; then
fn_alert_permissions fn_alert_permissions
elif [ "${alert}" == "monitor-session" ]; then elif [ "${alert}" == "monitor-session" ]; then

145
lgsm/modules/alert_discord.sh

@ -10,38 +10,46 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsonshortinfo=$( jsonshortinfo=$(
cat << EOF cat << EOF
{ {
"username":"LinuxGSM", "username": "LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"file":"content", "file": "content",
"embeds": [{ "embeds": [
"color": "2067276", {
"author": { "author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}", "name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" "url": "",
}, "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg"
"title": "${servername}", },
"description": "${alertbody} \n More info: ${alerturl}", "title": "${servername}",
"url": "", "url": "",
"type": "content", "description": "${alertbody} \n More info: ${alerturl}",
"thumbnail": {}, "color": "${alertcolourdec}",
"fields": [ "type": "content",
{ "thumbnail": {
"name": "Game", "url": "${alerticon}"
"value": "${gamename}", },
"inline": true "fields": [
}, {
{ "name": "Game",
"name": "Server IP", "value": "${gamename}",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})", "inline": true
"inline": true },
}, {
{ "name": "Server IP",
"name": "Hostname", "value": "${alertip}:${port}",
"value": "${HOSTNAME}", "inline": true
"inline": true },
} {
] "name": "Hostname",
}] "value": "${HOSTNAME}",
"inline": true
}
],
"footer": {
"text": "Sent by LinuxGSM ${version}"
}
}
]
} }
EOF EOF
) )
@ -49,39 +57,46 @@ EOF
jsonshortnoinfo=$( jsonshortnoinfo=$(
cat << EOF cat << EOF
{ {
"username":"LinuxGSM", "username": "LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"file":"content", "file": "content",
"embeds": [{ "embeds": [
"color": "2067276", {
"author": { "author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}", "name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" "url": "",
}, "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg"
"title": "${servername}", },
"description": "${alertbody}", "title": "${servername}",
"color": "${alertcolourdec}", "url": "",
"url": "", "description": "${alertbody}",
"type": "content", "color": "${alertcolourdec}",
"thumbnail": {}, "type": "content",
"fields": [ "thumbnail": {
{ "url": "${alerticon}"
"name": "Game", },
"value": "${gamename}", "fields": [
"inline": true {
}, "name": "Game",
{ "value": "${gamename}",
"name": "Server IP", "inline": true
"value": "${alertip}:${port}", },
"inline": true {
}, "name": "Server IP",
{ "value": "${alertip}:${port}",
"name": "Hostname", "inline": true
"value": "${HOSTNAME}", },
"inline": true {
} "name": "Hostname",
] "value": "${HOSTNAME}",
}] "inline": true
}
],
"footer": {
"text": "Sent by LinuxGSM ${version}"
}
}
]
} }
EOF EOF
) )

Loading…
Cancel
Save