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]}")")"
if ! command -v jq > /dev/null; then
fn_print_fail_nl "Sending Discord alert: jq is missing."
fn_script_log_fatal "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."
fi
json=$(cat <<EOF
{
"username":"LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png",
"file":"content",
"embeds": [{
"color": "2067276",
"author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"},
"title": "${servername}",
"description": "${alertbody}",
"url": "",
"type": "content",
"thumbnail": {},
"footer": {"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}", "icon_url": ""},
"fields": [
{
"name": "Game",
"value": "${gamename}",
"inline": true
},
{
"name": "Server IP",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})",
"inline": true
},
{
"name": "Server Name",
"value": "${servername}",
"inline": true
}
]
}]
"username":"LinuxGSM",
"avatar_url":"https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png",
"file":"content",
"embeds": [{
"color": "2067276",
"author": {
"name": "${alertemoji} ${alertsubject} ${alertemoji}",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.png"},
"title": "${servername}",
"description": "${alertbody}",
"url": "",
"type": "content",
"thumbnail": {},
"footer": {"text": "Hostname: ${HOSTNAME} / More info: ${alerturl}", "icon_url": ""},
"fields": [
{
"name": "Game",
"value": "${gamename}",
"inline": true
},
{
"name": "Server IP",
"value": "[${alertip}:${port}](https://www.gametracker.com/server_info/${alertip}:${port})",
"inline": true
},
{
"name": "Server Name",
"value": "${servername}",
"inline": true
}
]
}]
}
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}")
if [ "${discordsend}" ]; then
fn_print_fail_nl "Sending Discord alert: ${discordsend}"
fn_script_log_fatal "Sending Discord alert: ${discordsend}"
fn_print_fail_nl "Sending Discord alert: ${discordsend}"
fn_script_log_fatal "Sending Discord alert: ${discordsend}"
else
fn_print_ok_nl "Sending Discord alert"
fn_script_log_pass "Sending Discord alert"
fn_print_ok_nl "Sending Discord alert"
fn_script_log_pass "Sending Discord alert"
fi

Loading…
Cancel
Save