Browse Source

feat(alerts): add ismygameserver.online

pull/4741/head
Daniel Gibbs 8 months ago
parent
commit
ad60556722
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 128
      lgsm/modules/alert_discord.sh
  2. 38
      lgsm/modules/alert_gotify.sh
  3. 38
      lgsm/modules/alert_ifttt.sh
  4. 41
      lgsm/modules/alert_pushbullet.sh
  5. 24
      lgsm/modules/alert_pushover.sh
  6. 176
      lgsm/modules/alert_rocketchat.sh
  7. 266
      lgsm/modules/alert_slack.sh
  8. 47
      lgsm/modules/alert_telegram.sh
  9. 5
      lgsm/modules/info_messages.sh

128
lgsm/modules/alert_discord.sh

@ -10,82 +10,82 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
json=$( json=$(
cat << EOF cat << EOF
{ {
"username": "LinuxGSM", "username": "LinuxGSM",
"avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "avatar_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"file": "content", "file": "content",
"embeds": [ "embeds": [
{ {
"author": { "author": {
"name": "LinuxGSM Alert", "name": "LinuxGSM Alert",
"url": "", "url": "",
"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"
}, },
"title": "${alerttitle}", "title": "${alerttitle}",
"url": "", "url": "",
"description": "", "description": "",
"color": "${alertcolourdec}", "color": "${alertcolourdec}",
"type": "content", "type": "content",
"thumbnail": { "thumbnail": {
"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}",
"inline": true "inline": true
}, },
{ {
"name": "Server IP", "name": "Server IP",
"value": "\`${alertip}:${port}\`", "value": "\`${alertip}:${port}\`",
"inline": true "inline": true
}, },
{ {
"name": "Hostname", "name": "Hostname",
"value": "${HOSTNAME}", "value": "${HOSTNAME}",
"inline": true "inline": true
}, },
EOF EOF
) )
if [ -n "${querytype}" ]; then if [ -n "${querytype}" ]; then
json+=$( json+=$(
cat << EOF 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
}, },
EOF EOF
) )
fi fi
json+=$( json+=$(
cat << EOF cat << EOF
{ {
"name": "More info", "name": "More info",
"value": "${alerturl}", "value": "${alerturl}",
"inline": true "inline": true
}, },
{ {
"name": "Server Time", "name": "Server Time",
"value": "$(date)", "value": "$(date)",
"inline": true "inline": true
} }
], ],
"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}"
} }
} }
] ]
} }
EOF EOF
) )

38
lgsm/modules/alert_gotify.sh

@ -7,32 +7,38 @@
module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" module_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsoninfo=$( json=$(
cat << EOF cat << EOF
{ {
"title": "${alerttitle}", "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)", "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
"priority": 5
}
EOF 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 cat << EOF
{ Server Time\n$(date)",
"title": "${alerttitle}", "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\nServer Time\n$(date)",
"priority": 5
} }
EOF EOF
) )
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
fn_print_dots "Sending Gotify alert" 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 .)") gotifysend=$(curl --connect-timeout 3 -sSL "${gotifywebhook}/message"?token="${gotifytoken}" -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)")

38
lgsm/modules/alert_ifttt.sh

@ -7,32 +7,38 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsoninfo=$( json=$(
cat << EOF cat << EOF
{ {
"value1": "${selfname}", "value1": "${selfname}",
"value2": "${alerttitle}", "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 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 cat << EOF
{ Server Time\n$(date)"
"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)"
} }
EOF EOF
) )
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
fn_print_dots "Sending IFTTT alert" 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") 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")

41
lgsm/modules/alert_pushbullet.sh

@ -7,34 +7,39 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsoninfo=$( json=$(
cat << EOF cat << EOF
{ {
"channel_tag": "${channeltag}", "channel_tag": "${channeltag}",
"type": "note", "type": "note",
"title": "${alerttitle}", "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 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 cat << EOF
{ Server Time\n$(date)"
"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)"
} }
EOF EOF
) )
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
fn_print_dots "Sending Pushbullet alert" 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") 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")

24
lgsm/modules/alert_pushover.sh

@ -22,12 +22,28 @@ else
alertpriority="0" alertpriority="0"
fi fi
if [ -z "${alerturl}" ]; then 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>"
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 if [ -n "${querytype}" ]; 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><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>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 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 if [ -n "${pushoversend}" ]; then
fn_print_fail_nl "Sending Pushover alert: ${pushoversend}" fn_print_fail_nl "Sending Pushover alert: ${pushoversend}"
fn_script_log_fail "Sending Pushover alert: ${pushoversend}" fn_script_log_fail "Sending Pushover alert: ${pushoversend}"

176
lgsm/modules/alert_rocketchat.sh

@ -7,121 +7,87 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsoninfo=$( json=$(
cat << EOF cat << EOF
{ {
"alias": "LinuxGSM", "alias": "LinuxGSM",
"text": "*${alerttitle}*", "text": "*${alerttitle}*",
"attachments": [ "attachments": [
{ {
"title": "", "title": "",
"color": "${alertcolourhex}", "color": "${alertcolourhex}",
"author_name": "LinuxGSM Alert", "author_name": "LinuxGSM Alert",
"author_link": "https://linuxgsm.com", "author_link": "https://linuxgsm.com",
"author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg", "author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"thumb_url": "${alerticon}", "thumb_url": "${alerticon}",
"text": "", "text": "",
"fields": [ "fields": [
{ {
"short": false, "short": false,
"title": "Server Name", "title": "Server Name",
"value": "${servername}" "value": "${servername}"
}, },
{ {
"short": false, "short": false,
"title": "Information", "title": "Information",
"value": "${alertmessage}" "value": "${alertmessage}"
}, },
{ {
"short": false, "short": false,
"title": "Game", "title": "Game",
"value": "${gamename}" "value": "${gamename}"
}, },
{ {
"short": false, "short": false,
"title": "Server IP", "title": "Server IP",
"value": "${alertip}:${port}" "value": "${alertip}:${port}"
}, },
{ {
"short": false, "short": false,
"title": "Hostname", "title": "Hostname",
"value": "${HOSTNAME}" "value": "${HOSTNAME}"
}, },
{
"short": false,
"title": "More info",
"value": "${alerturl}"
},
{
"short": false,
"title": "Server Time",
"value": "$(date)"
}
]
}
]
}
EOF 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 cat << EOF
{ {
"alias": "LinuxGSM", "short": false,
"text": "*${alerttitle}*", "title": "Server Time",
"attachments": [ "value": "$(date)"
{ }
"title": "", ]
"color": "${alertcolourhex}", }
"author_name": "LinuxGSM Alert", ]
"author_link": "https://linuxgsm.com",
"author_icon": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"thumb_url": "${alerticon}",
"text": "",
"fields": [
{
"short": false,
"title": "Server Name",
"value": "${servername}"
},
{
"short": false,
"title": "Information",
"value": "${alertmessage}"
},
{
"short": false,
"title": "Game",
"value": "${gamename}"
},
{
"short": false,
"title": "Server IP",
"value": "${alertip}:${port}"
},
{
"short": false,
"title": "Hostname",
"value": "${HOSTNAME}"
},
{
"short": false,
"title": "Server Time",
"value": "$(date)"
}
]
}
]
} }
EOF EOF
) )
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
fn_print_dots "Sending Rocketchat alert" 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}") rocketchatsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${rocketchatwebhook}")

266
lgsm/modules/alert_slack.sh

@ -7,179 +7,119 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsonnoinfo=$( json=$(
cat << EOF cat << EOF
{ {
"attachments": [ "attachments": [
{ {
"color": "${alertcolourhex}", "color": "${alertcolourhex}",
"blocks": [ "blocks": [
{ {
"type": "header", "type": "header",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "${alerttitle}", "text": "${alerttitle}",
"emoji": true "emoji": true
} }
}, },
{ {
"type": "divider" "type": "divider"
}, },
{ {
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Server Name*\n${servername}" "text": "*Server Name*\n${servername}"
} }
}, },
{ {
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Information*\n${alertmessage}" "text": "*Information*\n${alertmessage}"
} }
}, },
{ {
"type": "section", "type": "section",
"fields": [ "fields": [
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Game*\n${gamename}" "text": "*Game*\n${gamename}"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Server IP*\n\`${alertip}:${port}\`" "text": "*Server IP*\n\`${alertip}:${port}\`"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Hostname*\n${HOSTNAME}" "text": "*Hostname*\n${HOSTNAME}"
}, },
{ {
"type": "mrkdwn", "type": "mrkdwn",
"text": "*Server Time*\n$(date)" "text": "*Server Time*\n$(date)"
} }
], ],
"accessory": { "accessory": {
"type": "image", "type": "image",
"image_url": "${alerticon}", "image_url": "${alerticon}",
"alt_text": "cute cat" "alt_text": "cute cat"
} }
}, },
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"alt_text": "LinuxGSM icon"
},
{
"type": "plain_text",
"text": "Sent by LinuxGSM ${version}",
"emoji": true
}
]
}
]
}
]
}
EOF EOF
) )
jsoninfo=$( if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Is my Game Server Online?*\n<https://ismygameserver.online/${querytype}/${alertip}:${queryport}|Check here>"
}
},
EOF
)
fi
if [ -n "${alerturl}" ]; then
json+=$(
cat << EOF
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*More info*\n<${alerturl}|${alerturl}>"
}
},
EOF
)
fi
json+=$(
cat << EOF cat << EOF
{ {
"attachments": [ "type": "context",
{ "elements": [
"color": "${alertcolourhex}", {
"blocks": [ "type": "image",
{ "image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"type": "header", "alt_text": "LinuxGSM icon"
"text": { },
"type": "mrkdwn", {
"text": "${alerttitle}", "type": "plain_text",
"emoji": true "text": "Sent by LinuxGSM ${version}",
} "emoji": true
}, }
{ ]
"type": "divider" }
}, ]
{ }
"type": "section", ]
"text": {
"type": "mrkdwn",
"text": "*Server Name*\n${servername}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Information*\n${alertmessage}"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Game*\n${gamename}"
},
{
"type": "mrkdwn",
"text": "*Server IP*\n\`${alertip}:${port}\`"
},
{
"type": "mrkdwn",
"text": "*Hostname*\n${HOSTNAME}"
},
{
"type": "mrkdwn",
"text": "*Server Time*\n$(date)"
}
],
"accessory": {
"type": "image",
"image_url": "${alerticon}",
"alt_text": "cute cat"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Server Time*\n${alertmessage}"
}
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/lgsm/data/alert_discord_logo.jpg",
"alt_text": "LinuxGSM icon"
},
{
"type": "plain_text",
"text": "Sent by LinuxGSM ${version}",
"emoji": true
}
]
}
]
}
]
} }
EOF EOF
) )
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
fn_print_dots "Sending Slack alert" fn_print_dots "Sending Slack alert"
slacksend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${slackwebhook}") slacksend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" "${slackwebhook}")

47
lgsm/modules/alert_telegram.sh

@ -7,38 +7,41 @@
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
jsoninfo=$( json=$(
cat << EOF cat << EOF
{ {
"chat_id": "${telegramchatid}", "chat_id": "${telegramchatid}",
"message_thread_id": "${telegramthreadid}", "message_thread_id": "${telegramthreadid}",
"parse_mode": "HTML", "parse_mode": "HTML",
"disable_notification": "${telegramdisablenotification}", "disable_notification": "${telegramdisablenotification}",
"text": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>\n\n<b>Server Time</b>\n$(date)", "text": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n
"disable_web_page_preview": "yes"
}
EOF EOF
) )
jsonnoinfo=$( if [ -n "${querytype}" ]; then
json+=$(
cat << EOF
<b>Is my Game Server Online?</b>\n<a href='https://ismygameserver.online/${querytype}/${alertip}:${queryport}'>Check here</a>\n\n
EOF
)
fi
if [ -n "${alerturl}" ]; then
json+=$(
cat << EOF
<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>\n\n
EOF
)
fi
json+=$(
cat << EOF cat << EOF
{ <b>Server Time</b>\n$(date)",
"chat_id": "${telegramchatid}", "disable_web_page_preview": "yes"
"message_thread_id": "${telegramthreadid}",
"parse_mode": "HTML",
"disable_notification": "${telegramdisablenotification}",
"text": "<b>${alerttitle}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Information</b>\n${alertmessage}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n${alertip}:${port}\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>Server Time</b>\n$(date)",
"disable_web_page_preview": "yes"
} }
EOF EOF
) )
if [ -z "${alerturl}" ]; then
json="${jsonnoinfo}"
else
json="${jsoninfo}"
fi
fn_print_dots "Sending Telegram alert" fn_print_dots "Sending Telegram alert"
telegramsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code") telegramsend=$(curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")

5
lgsm/modules/info_messages.sh

@ -66,6 +66,11 @@ fn_info_messages_head() {
echo -e "Hostname" echo -e "Hostname"
echo -e "${HOSTNAME}" echo -e "${HOSTNAME}"
echo -e "" echo -e ""
if [ -n "${querytype}" ]; then
echo -e "Is my Game Server Online?"
echo -e "https://ismygameserver.online/${querytype}/${alertip}:${queryport}"
echo -e ""
fi
echo -e "Server Time" echo -e "Server Time"
echo -e "$(date)" echo -e "$(date)"
} }

Loading…
Cancel
Save