Browse Source

tabs

pull/3051/head
Daniel Gibbs 5 years ago
parent
commit
94532ae3da
  1. 76
      lgsm/functions/alert_discord.sh

76
lgsm/functions/alert_discord.sh

@ -8,44 +8,44 @@
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if ! command -v jq > /dev/null; then if ! command -v jq > /dev/null; then
fn_print_fail_nl "Sending Discord alert: jq is missing." fn_print_fail_nl "Sending Discord alert: jq is missing."
fn_script_log_fatal "Sending Discord alert: jq is missing." fn_script_log_fatal "Sending Discord alert: jq is missing."
fi fi
json=$(cat <<EOF json=$(cat <<EOF
{ {
"username":"LinuxGSM", "username":"LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png", "avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png",
"file":"content", "file":"content",
"embeds": [{ "embeds": [{
"color": "2067276", "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.png"}, "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"},
"title": "${servername}", "title": "${servername}",
"description": "${alertbody}", "description": "${alertbody}",
"url": "", "url": "",
"type": "content", "type": "content",
"thumbnail": {}, "thumbnail": {},
"footer": {"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}", "icon_url": ""}, "footer": {"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}", "icon_url": ""},
"fields": [ "fields": [
{ {
"name": "Game", "name": "Game",
"value": "${gamename}", "value": "${gamename}",
"inline": true "inline": true
}, },
{ {
"name": "Server IP", "name": "Server IP",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})", "value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})",
"inline": true "inline": true
}, },
{ {
"name": "Server Name", "name": "Server Name",
"value": "${servername}", "value": "${servername}",
"inline": true "inline": true
} }
] ]
}] }]
} }
EOF EOF
) )
@ -55,9 +55,9 @@ fn_print_dots "Sending Discord alert"
discordsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${discordwebhook}") discordsend=$(curl -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "$json" | jq -c .)" "${discordwebhook}")
if [ "${discordsend}" ]; then if [ "${discordsend}" ]; then
fn_print_fail_nl "Sending Discord alert: ${discordsend}" fn_print_fail_nl "Sending Discord alert: ${discordsend}"
fn_script_log_fatal "Sending Discord alert: ${discordsend}" fn_script_log_fatal "Sending Discord alert: ${discordsend}"
else else
fn_print_ok_nl "Sending Discord alert" fn_print_ok_nl "Sending Discord alert"
fn_script_log_pass "Sending Discord alert" fn_script_log_pass "Sending Discord alert"
fi fi

Loading…
Cancel
Save