Browse Source
Standardizes alert messages across platforms
Ensures consistency in alert messages across Discord, NTFY,
Pushover, Rocketchat, Slack, and Telegram.
Updates Discord alerts to include server hostname and time,
removes redundant formatting.
Standardizes plain-text alert formatting for NTFY.
Refactors Pushover messages to use consistent HTML formatting.
Streamlines Rocketchat and Slack messages by removing duplicate
server info and adding optional link support.
pull/4854/head
Daniel Gibbs
5 months ago
Failed to extract signature
6 changed files with
46 additions and
154 deletions
lgsm/modules/alert_discord.sh
lgsm/modules/alert_ntfy.sh
lgsm/modules/alert_pushover.sh
lgsm/modules/alert_rocketchat.sh
lgsm/modules/alert_slack.sh
lgsm/modules/alert_telegram.sh
@ -43,9 +43,19 @@ json=$(
"inline" : true
} ,
{
"name" : "Address:Port " ,
"name" : "Server IP " ,
"value" : " \` ${ alertip } : ${ port } \` " ,
"inline" : true
} ,
{
"name" : "Hostname" ,
"value" : " ${ HOSTNAME } " ,
"inline" : true
} ,
{
"name" : "Server Time" ,
"value" : " $( date) " ,
"inline" : true
}
EOF
)
@ -35,23 +35,34 @@ else
tags = " ${ alertemoji } "
fi
# Construct the message body
message = " Server Name: ${ servername }
Information: ${ alertmessage }
Game: ${ gamename }
Server IP: ${ alertip } :${ port }
Hostname: ${ HOSTNAME }
Server Time: $( date) "
# Construct the message body (keep formatting consistent with other plain-text alerts)
message = " Server Name
${ servername }
Information
${ alertmessage }
Game
${ gamename }
Server IP
${ alertip } :${ port }
Hostname
${ HOSTNAME }
Server Time
$( date) "
# Add optional links if available
if [ -n " ${ querytype } " ] ; then
message += " \nIs my Game Server Online?: https://ismygameserver.online/ ${ imgsoquerytype } / ${ alertip } : ${ queryport } "
message += " \n\nIs my Game Server Online?\n https://ismygameserver.online/ ${ imgsoquerytype } / ${ alertip } : ${ queryport } "
fi
# Use alerturl for the click action if available
clickurl = ""
if [ -n " ${ alerturl } " ] ; then
message += " \nMore info: ${ alerturl } "
message += " \n\nMore info\n ${ alerturl } "
clickurl = " ${ alerturl } "
fi
@ -22,7 +22,7 @@ else
alertpriority = "0"
fi
message = " <b>Server n ame</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> "
message = " <b>Server N ame</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/ ${ imgsoquerytype } / ${ alertip } : ${ queryport } '>Check here</a><br><br> "
@ -32,7 +32,7 @@ if [ -n "${alerturl}" ]; then
message += " <b>More info</b><br><a href=' ${ alerturl } '> ${ alerturl } </a><br><br> "
fi
message += " Server Time<br> $( date) "
message += " <b> Server Time</b> <br>$( date) "
pushoversend = $( curl --connect-timeout 3 -sS \
-F token = " ${ pushovertoken } " \
@ -40,38 +40,25 @@ json=$(
{
"short" : false,
"title" : "Server IP" ,
"value" : " ${ alertip } : ${ port } "
"value" : " \` ${ alertip } : ${ port } \` "
} ,
{
"short" : false,
"title" : "Hostname" ,
"value" : " ${ HOSTNAME } "
} ,
{
"short" : false,
"title" : "More info" ,
"value" : " ${ alerturl } "
} ,
{
"short" : false,
"title" : "Server Time" ,
"value" : " $( date) "
}
]
}
]
}
EOF
)
if [ -n " ${ querytype } " ] ; then
json += $(
cat << EOF
,
{
"short" : false,
"title" : "Is my Game Server Online?" ,
"value" : " <https://ismygameserver.online/ ${ imgsoquerytype } / ${ alertip } : ${ queryport } |Check here> "
} ,
}
EOF
)
fi
@ -79,55 +66,19 @@ fi
if [ -n " ${ alerturl } " ] ; then
json += $(
cat << EOF
,
{
"short" : false,
"title" : "More info" ,
"value" : " ${ alerturl } "
} ,
}
EOF
)
fi
json += $(
cat << EOF
{
"alias" : "LinuxGSM" ,
"text" : " * ${ alerttitle } * " ,
"attachments" : [
{
"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" ,
@ -62,41 +62,22 @@ json=$(
"accessory" : {
"type" : "image" ,
"image_url" : " ${ alerticon } " ,
"alt_text" : "cute cat "
"alt_text" : "LinuxGSM game icon "
}
} ,
{
"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
)
if [ -n " ${ querytype } " ] ; then
json += $(
cat << EOF
,
{
"type" : "section" ,
"text" : {
"type" : "mrkdwn" ,
"text" : " *Is my Game Server Online?*\n<https://ismygameserver.online/ ${ imgsoquerytype } / ${ alertip } : ${ queryport } |Check here> "
}
} ,
}
EOF
)
fi
@ -104,82 +85,21 @@ fi
if [ -n " ${ alerturl } " ] ; then
json += $(
cat << EOF
,
{
"type" : "section" ,
"text" : {
"type" : "mrkdwn" ,
"text" : " *More info*\n< ${ alerturl } | ${ alerturl } > "
}
} ,
}
EOF
)
fi
json += $(
cat << EOF
{
"attachments" : [
{
"color" : " ${ alertcolourhex } " ,
"blocks" : [
{
"type" : "header" ,
"text" : {
"type" : "mrkdwn" ,
"text" : " ${ alerttitle } " ,
"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" : [
@ -14,7 +14,7 @@ json=$(
"message_thread_id" : " ${ telegramthreadid } " ,
"parse_mode" : "HTML" ,
"disable_notification" : " ${ telegramdisablenotification } " ,
"text" : " <b> ${ alerttitle } </b>\n\n<b>Server n ame</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
"text" : " <b> ${ alerttitle } </b>\n\n<b>Server N ame</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
EOF
)