Browse Source
feat: remove more info if not enabled
pull/4345/head
Daniel Gibbs
2 years ago
No known key found for this signature in database
GPG Key ID: 2076B128385E8C55
1 changed files with
46 additions and
1 deletions
-
lgsm/modules/alert_discord.sh
|
|
@ -7,7 +7,7 @@ |
|
|
|
|
|
|
|
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" |
|
|
|
|
|
|
|
json=$( |
|
|
|
jsonshortinfo=$( |
|
|
|
cat << EOF |
|
|
|
{ |
|
|
|
"username":"LinuxGSM", |
|
|
@ -46,8 +46,53 @@ json=$( |
|
|
|
EOF |
|
|
|
) |
|
|
|
|
|
|
|
jsonshortnoinfo=$( |
|
|
|
cat << EOF |
|
|
|
{ |
|
|
|
"username":"LinuxGSM", |
|
|
|
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", |
|
|
|
"file":"content", |
|
|
|
"embeds": [{ |
|
|
|
"color": "2067276", |
|
|
|
"author": { |
|
|
|
"name": "${alertemoji} ${alertsubject} ${alertemoji}", |
|
|
|
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg" |
|
|
|
}, |
|
|
|
"title": "${servername}", |
|
|
|
"description": "${alertbody}", |
|
|
|
"url": "", |
|
|
|
"type": "content", |
|
|
|
"thumbnail": {}, |
|
|
|
"fields": [ |
|
|
|
{ |
|
|
|
"name": "Game", |
|
|
|
"value": "${gamename}", |
|
|
|
"inline": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "Server IP", |
|
|
|
"value": "${alertip}:${port}", |
|
|
|
"inline": true |
|
|
|
}, |
|
|
|
{ |
|
|
|
"name": "Hostname", |
|
|
|
"value": "${HOSTNAME}", |
|
|
|
"inline": true |
|
|
|
} |
|
|
|
] |
|
|
|
}] |
|
|
|
} |
|
|
|
EOF |
|
|
|
) |
|
|
|
|
|
|
|
fn_print_dots "Sending Discord alert" |
|
|
|
|
|
|
|
if [ "${alerturl}" == "not enabled" ]; then |
|
|
|
json="${jsonshortnoinfo}" |
|
|
|
else |
|
|
|
json="${jsonshortinfo}" |
|
|
|
fi |
|
|
|
|
|
|
|
discordsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}") |
|
|
|
|
|
|
|
if [ -n "${discordsend}" ]; then |
|
|
|