Skip to content

Commit

Permalink
feat: remove more info if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Oct 15, 2023
1 parent 3b39c78 commit c8d2715
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion lgsm/modules/alert_discord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"

json=$(
jsonshortinfo=$(
cat << EOF
{
"username":"LinuxGSM",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c8d2715

Please sign in to comment.