Browse Source

add ismygameserveronline

pull/4741/head
Daniel Gibbs 8 months ago
parent
commit
45c220a471
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 102
      lgsm/modules/alert_discord.sh

102
lgsm/modules/alert_discord.sh

@ -7,7 +7,7 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsoninfo=$( json=$(
cat << EOF cat << EOF
{ {
"username": "LinuxGSM", "username": "LinuxGSM",
@ -29,14 +29,14 @@ jsoninfo=$(
"url": "${alerticon}" "url": "${alerticon}"
}, },
"fields": [ "fields": [
{ {
"name": "Server Name", "name": "Server Name",
"value": "${servername}" "value": "${servername}"
}, },
{ {
"name": "Information", "name": "Information",
"value": "${alertmessage}" "value": "${alertmessage}"
}, },
{ {
"name": "Game", "name": "Game",
"value": "${gamename}", "value": "${gamename}",
@ -52,80 +52,26 @@ jsoninfo=$(
"value": "${HOSTNAME}", "value": "${HOSTNAME}",
"inline": true "inline": true
}, },
EOF
)
if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
{ {
"name": "Is my Game Server Online?", "name": "Is my Game Server Online?",
"value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}", "value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}",
"inline": true "inline": true
}, },
{
"name": "More info",
"value": "${alerturl}",
"inline": true
},
{
"name": "Server Time",
"value": "$(date)",
"inline": true
}
],
"footer": {
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"text": "Sent by LinuxGSM ${version}"
}
}
]
}
EOF EOF
) )
fi
jsonnoinfo=$( json+=$(
cat << EOF cat << EOF
{
"username": "LinuxGSM",
"avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"file": "content",
"embeds": [
{
"author": {
"name": "LinuxGSM Alert",
"url": "",
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg"
},
"title": "${alerttitle}",
"url": "",
"description": "",
"color": "${alertcolourdec}",
"type": "content",
"thumbnail": {
"url": "${alerticon}"
},
"fields": [
{
"name": "Server Name",
"value": "${servername}"
},
{
"name": "Information",
"value": "${alertmessage}"
},
{
"name": "Game",
"value": "${gamename}",
"inline": true
},
{ {
"name": "Server IP", "name": "More info",
"value": "\`${alertip}:${port}\`", "value": "${alerturl}",
"inline": true
},
{
"name": "Hostname",
"value": "${HOSTNAME}",
"inline": true
},
{
"name": "Is my Game Server Online?",
"value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}",
"inline": true "inline": true
}, },
{ {
@ -135,7 +81,7 @@ jsonnoinfo=$(
} }
], ],
"footer": { "footer": {
"icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "icon_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"text": "Sent by LinuxGSM ${version}" "text": "Sent by LinuxGSM ${version}"
} }
} }
@ -146,12 +92,6 @@ EOF
fn_print_dots "Sending Discord alert" fn_print_dots "Sending Discord alert"
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
discordsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}") discordsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${discordwebhook}")
if [ -n "${discordsend}" ]; then if [ -n "${discordsend}" ]; then

Loading…
Cancel
Save