Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ismygameserver.online links #4741

Merged
merged 14 commits into from
Jan 7, 2025
97 changes: 10 additions & 87 deletions 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]}")")"

jsoninfo=$(
json=$(
cat << EOF
{
"username": "LinuxGSM",
Expand All @@ -29,103 +29,32 @@ jsoninfo=$(
"url": "${alerticon}"
},
"fields": [
{
"name": "Server Name",
"value": "${servername}"
},
{
"name": "Information",
"value": "${alertmessage}"
},
{
"name": "Game",
"value": "${gamename}",
"inline": true
"name": "Server Name",
"value": "${servername}"
},
{
"name": "Server IP",
"value": "\`${alertip}:${port}\`",
"inline": true
},
{
"name": "Hostname",
"value": "${HOSTNAME}",
"inline": true
"name": "Information",
"value": "${alertmessage}"
},
{
"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
)

jsonnoinfo=$(
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",
"value": "\`${alertip}:${port}\`",
"inline": true
},
{
"name": "Hostname",
"value": "${HOSTNAME}",
"name": "Server Time",
"value": "$(date)",
"inline": true
},
{
"name": "Server Time",
"value": "$(date)",
"name": "Is my Game Server Online?",
"value": "https://ismygameserver.online/${querytype}/${alertip}:${queryport}",
"inline": true
}
],
"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}"
}
}
Expand All @@ -136,12 +65,6 @@ EOF

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}")

if [ -n "${discordsend}" ]; then
Expand Down
34 changes: 20 additions & 14 deletions lgsm/modules/alert_gotify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,38 @@

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

jsoninfo=$(
json=$(
cat << EOF
{
"title": "${alerttitle}",
"message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)",
"priority": 5
}
"message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n
EOF
)

jsonnoinfo=$(
if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
Is my Game Server Online?\nhttps://ismygameserver.online/${querytype}/${alertip}:${queryport}\n\n
EOF
)
fi

if [ -n "${alerturl}" ]; then
json+=$(
cat << EOF
More info\n${alerturl}\n\n
EOF
)
fi

json+=$(
cat << EOF
{
"title": "${alerttitle}",
"message": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)",
Server Time\n$(date)",
"priority": 5
}
EOF
)

if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi

fn_print_dots "Sending Gotify alert"
gotifysend=$(curl --connect-timeout 3 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")

Expand Down
34 changes: 20 additions & 14 deletions lgsm/modules/alert_ifttt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,38 @@

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

jsoninfo=$(
json=$(
cat << EOF
{
"value1": "${selfname}",
"value2": "${alerttitle}",
"value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)"
}
"value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n
EOF
)

jsonnoinfo=$(
if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
Is my Game Server Online?\nhttps://ismygameserver.online/${querytype}/${alertip}:${queryport}\n\n
EOF
)
fi

if [ -n "${alerturl}" ]; then
json+=$(
cat << EOF
More info\n${alerturl}\n\n
EOF
)
fi

json+=$(
cat << EOF
{
"value1": "${selfname}",
"value2": "${alerttitle}",
"value3": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)"
Server Time\n$(date)"
}
EOF
)

if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi

fn_print_dots "Sending IFTTT alert"
iftttsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://maker.ifttt.com/trigger/${iftttevent}/with/key/${ifttttoken}" | grep "Bad Request")

Expand Down
35 changes: 20 additions & 15 deletions lgsm/modules/alert_pushbullet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,39 @@

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

jsoninfo=$(
json=$(
cat << EOF
{
"channel_tag": "${channeltag}",
"type": "note",
"title": "${alerttitle}",
"body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nMore info\n${alerturl}\n\nServer Time\n$(date)"
}
"body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\n
EOF
)

jsonnoinfo=$(
if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
Is my Game Server Online?\nhttps://ismygameserver.online/${querytype}/${alertip}:${queryport}\n\n
EOF
)
fi

if [ -n "${alerturl}" ]; then
json+=$(
cat << EOF
More info\n${alerturl}\n\n
EOF
)
fi

json+=$(
cat << EOF
{
"channel_tag": "${channeltag}",
"type": "note",
"title": "${alerttitle}",
"body": "Server Name\n${servername}\n\nInformation\n${alertmessage}\n\nGame\n${gamename}\n\nServer IP\n${alertip}:${port}\n\nHostname\n${HOSTNAME}\n\nServer Time\n$(date)"
Server Time\n$(date)"
}
EOF
)

if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi

fn_print_dots "Sending Pushbullet alert"
pushbulletsend=$(curl --connect-timeout 3 -sSL -H "Access-Token: ${pushbullettoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "https://api.pushbullet.com/v2/pushes" | grep "error_code")

Expand Down
24 changes: 20 additions & 4 deletions lgsm/modules/alert_pushover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ else
alertpriority="0"
fi

if [ -z "${alerturl}" ]; then
pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
else
pushoversend=$(curl --connect-timeout 3 -sS -F token="${pushovertoken}" -F user="${pushoveruserkey}" -F html="1" -F sound="${alertsound}" -F priority="${alertpriority}" -F title="${alerttitle}" -F message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br><b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>Server Time<br>$(date)" "https://api.pushover.net/1/messages.json" | grep errors)
message=" <b>Server name</b><br>${servername}<br><br><b>Information</b><br>${alertmessage}<br><br><b>Game</b><br>${gamename}<br><br><b>Server IP</b><br>${alertip}:${port}<br><br><b>Hostname</b><br>${HOSTNAME}<br><br>"

if [ -n "${querytype}" ]; then
message+="<b>Is my Game Server Online?</b><br><a href='https://ismygameserver.online/${querytype}/${alertip}:${queryport}'>Check here</a><br><br>"
fi

if [ -n "${alerturl}" ]; then
message+="<b>More info</b><br><a href='${alerturl}'>${alerturl}</a><br><br>"
fi

message+="Server Time<br>$(date)"

pushoversend=$(curl --connect-timeout 3 -sS \
-F token="${pushovertoken}" \
-F user="${pushoveruserkey}" \
-F html="1" \
-F sound="${alertsound}" \
-F priority="${alertpriority}" \
-F title="${alerttitle}" \
-F message="${message}" \
"https://api.pushover.net/1/messages.json" | grep errors)

if [ -n "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
fn_script_log_fail "Sending Pushover alert: ${pushoversend}"
Expand Down
34 changes: 26 additions & 8 deletions lgsm/modules/alert_rocketchat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

jsoninfo=$(
json=$(
cat << EOF
{
"alias": "LinuxGSM",
Expand Down Expand Up @@ -64,7 +64,31 @@ jsoninfo=$(
EOF
)

jsonnoinfo=$(
if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
{
"short": false,
"title": "Is my Game Server Online?",
"value": "<https://ismygameserver.online/${querytype}/${alertip}:${queryport}|Check here>"
},
EOF
)
fi

if [ -n "${alerturl}" ]; then
json+=$(
cat << EOF
{
"short": false,
"title": "More info",
"value": "${alerturl}"
},
EOF
)
fi

json+=$(
cat << EOF
{
"alias": "LinuxGSM",
Expand Down Expand Up @@ -116,12 +140,6 @@ jsonnoinfo=$(
EOF
)

if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi

fn_print_dots "Sending Rocketchat alert"
rocketchatsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}")

Expand Down
Loading
Loading