Browse Source
feat: add server name and information fields to Discord alert
The code changes in the `alert_discord.sh` file include adding new fields for server name and information to the JSON payload sent in a Discord alert. This allows for more detailed information about the server to be included in the alert message.
refactor: improve conditional logic for Gotify alerts
In the `alert_gotify.sh` file, the code changes involve improving the conditional logic for determining which JSON payload to use when sending a Gotify alert. The updated logic checks if an alert URL is provided and selects the appropriate JSON payload accordingly.
chore: update field names in IFTTT alerts
The changes made in `alert_ifttt.sh` involve updating field names in the JSON payloads used for IFTTT alerts. The field names have been modified to match a consistent format across all fields.
fix: correct body formatting in Pushbullet alerts
The code changes made in `alert_pushbullet.sh` address an issue with incorrect body formatting in Pushbullet alerts. The body of the alert now includes separate lines for each piece of information, such as server name, information, game, server IP, hostname, and more info.
refactor: improve attachment structure in RocketChat alerts
In `alert_rocketchat.sh`, the code changes involve improving the attachment structure of RocketChat alerts. The updated structure includes separate sections for server name, information, game, server IP, hostname, and more info.
feat: add additional sections to Slack alerts
The changes made in `alert_slack.sh` include adding additional sections to Slack alerts. These sections provide separate blocks of text for server name and information within each message.
feat: add HTML formatting to Telegram alerts
In `alert_telegram.sh`, HTML formatting has been added to Telegram alerts. This allows for bold text styling and clickable links within each message sent via Telegram.
pull/4345/head
Daniel Gibbs
2 years ago
No known key found for this signature in database
GPG Key ID: 2076B128385E8C55
7 changed files with
94 additions and
33 deletions
lgsm/modules/alert_discord.sh
lgsm/modules/alert_gotify.sh
lgsm/modules/alert_ifttt.sh
lgsm/modules/alert_pushbullet.sh
lgsm/modules/alert_rocketchat.sh
lgsm/modules/alert_slack.sh
lgsm/modules/alert_telegram.sh
@ -29,6 +29,14 @@ jsoninfo=$(
"url" : " ${ alerticon } "
} ,
"fields" : [
{
"name" : "Server Name" ,
"value" : " ${ servername } "
} ,
{
"name" : "Information" ,
"value" : " ${ alertmessage } "
} ,
{
"name" : "Game" ,
"value" : " ${ gamename } " ,
@ -43,15 +51,7 @@ jsoninfo=$(
"name" : "Hostname" ,
"value" : " ${ HOSTNAME } " ,
"inline" : true
} ,
{
"name" : "Information" ,
"value" : " ${ alertmessage } "
} ,
{
"name" : "More Information" ,
"value" : " ${ alerturl } "
}
}
] ,
"footer" : {
"icon_url" : " https://raw.githubusercontent.com/ ${ githubuser } / ${ githubrepo } / ${ githubbranch } /lgsm/data/alert_discord_logo.jpg " ,
@ -85,6 +85,14 @@ jsonnoinfo=$(
"url" : " ${ alerticon } "
} ,
"fields" : [
{
"name" : "Server Name" ,
"value" : " ${ servername } "
} ,
{
"name" : "Information" ,
"value" : " ${ alertmessage } "
} ,
{
"name" : "Game" ,
"value" : " ${ gamename } " ,
@ -99,11 +107,7 @@ jsonnoinfo=$(
"name" : "Hostname" ,
"value" : " ${ HOSTNAME } " ,
"inline" : true
} ,
{
"name" : "Information" ,
"value" : " ${ alertmessage } "
}
}
] ,
"footer" : {
"icon_url" : " https://raw.githubusercontent.com/ ${ githubuser } / ${ githubrepo } / ${ githubbranch } /lgsm/data/alert_discord_logo.jpg " ,
@ -7,18 +7,33 @@
module_selfname = " $( basename " $( readlink -f " ${ BASH_SOURCE [0] } " ) " ) "
json = $(
jsoninfo = $(
cat << EOF
{
"title" : " ${ alerttitle } " ,
"message" : " Server n ame\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 } " ,
"message" : " Server N ame\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 } " ,
"priority" : 5
}
EOF
)
fn_print_dots "Sending Gotify alert"
jsonnoinfo = $(
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 } " ,
"priority" : 5
}
EOF
)
if [ -z " ${ alerturl } " ] ; then
json = " ${ jsonnoinfo } "
else
json = " ${ jsoninfo } "
fi
fn_print_dots "Sending Gotify alert"
gotifysend = $( curl --connect-timeout 10 -sSL " ${ gotifywebhook } /message " ?token= " ${ gotifytoken } " -H "Content-Type: application/json" -X POST -d " $( echo -n " ${ json } " | jq -c .) " )
if [ -n " ${ gotifysend } " ] ; then
@ -12,7 +12,7 @@ jsoninfo=$(
{
"value1" : " ${ selfname } " ,
"value2" : " ${ alerttitle } " ,
"value3" : " Information \n ${ alertmessage } \n\nGame: \n ${ gamename } \n\nServer name \n ${ servername } \n\nHostname \n ${ HOSTNAME } \n\nServer IP \n${ alertip } : ${ port } \n\nMore info \n ${ alerturl } "
"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 More info\n ${ alerturl } "
}
EOF
)
@ -22,7 +22,7 @@ jsonnoinfo=$(
{
"value1" : " ${ selfname } " ,
"value2" : " ${ alerttitle } " ,
"value3" : " Information \n ${ alertmessage } \n\nGame: \n ${ gamename } \n\nServer name \n ${ server name} \n\nHostname \n ${ HOSTNAME } \n\n Server IP \n ${ alertip } : ${ port } "
"value3" : " Server Name\n ${ servername } \n\nInformation\n ${ alertmessage } \n\nGame\n ${ game name} \n\nServer IP\n ${ alertip } : ${ port } \n\nHostname\n ${ HOSTNAME } "
}
EOF
)
@ -13,7 +13,7 @@ jsoninfo=$(
"channel_tag" : " ${ channeltag } " ,
"type" : "note" ,
"title" : " ${ alerttitle } " ,
"body" : " Information\n ${ alertmessage } \n\nGame\n ${ gamename } \n\nServer IP\n ${ alertip } : ${ port } \n\nHostname\n ${ HOSTNAME } \n\nMore info\n ${ alerturl } "
"body" : " Server Name\n ${ servername } \n\n Information\n${ alertmessage } \n\nGame\n ${ gamename } \n\nServer IP\n ${ alertip } : ${ port } \n\nHostname\n ${ HOSTNAME } \n\nMore info\n ${ alerturl } "
}
EOF
)
@ -24,7 +24,7 @@ jsonnoinfo=$(
"channel_tag" : " ${ channeltag } " ,
"type" : "note" ,
"title" : " ${ alerttitle } " ,
"body" : " Information\n ${ alertmessage } \n\nGame\n ${ gamename } \n\nServer IP\n ${ alertip } : ${ port } \n\nHostname\n ${ HOSTNAME } "
"body" : " Server Name\n ${ servername } \n\n Information\n${ alertmessage } \n\nGame\n ${ gamename } \n\nServer IP\n ${ alertip } : ${ port } \n\nHostname\n ${ HOSTNAME } "
}
EOF
)
@ -7,11 +7,11 @@
moduleselfname = " $( basename " $( readlink -f " ${ BASH_SOURCE [0] } " ) " ) "
json = $(
jsoninfo = $(
cat << EOF
{
"alias" : "LinuxGSM" ,
"text" : " * ${ alerttitle } * \n ${ alertmessage } \n More info: ${ alerturl } " ,
"text" : " * ${ alerttitle } *\n ${ alertmessage } \nMore info: ${ alerturl } " ,
"attachments" : [
{
"fields" : [
@ -37,8 +37,43 @@ json=$(
EOF
)
fn_print_dots "Sending Rocketchat alert"
jsonnoinfo = $(
cat << EOF
{
"alias" : "LinuxGSM" ,
"text" : " * ${ alerttitle } *\n ${ alertmessage } " ,
"attachments" : [
{
"fields" : [
{
"short" : true,
"title" : "Game" ,
"value" : " ${ gamename } "
} ,
{
"short" : true,
"title" : "Server IP" ,
"value" : " ${ alertip } : ${ port } "
} ,
{
"short" : true,
"title" : "Hostname" ,
"value" : " ${ HOSTNAME } "
}
]
}
]
}
EOF
)
if [ -z " ${ alerturl } " ] ; then
json = " ${ jsonnoinfo } "
else
json = " ${ jsoninfo } "
fi
fn_print_dots "Sending Rocketchat alert"
rocketchatsend = $( curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d " $( echo -n " ${ json } " | jq -c .) " " ${ rocketchatwebhook } " )
if [ -n " ${ rocketchatsend } " ] ; then
@ -25,6 +25,20 @@ json=$(
{
"type" : "divider"
} ,
{
"type" : "section" ,
"text" : {
"type" : "mrkdwn" ,
"text" : " *Server Name*\n ${ servername } "
}
} ,
{
"type" : "section" ,
"text" : {
"type" : "mrkdwn" ,
"text" : " *Information*\n ${ alertmessage } "
}
} ,
{
"type" : "section" ,
"fields" : [
@ -47,13 +61,6 @@ json=$(
"alt_text" : "cute cat"
}
} ,
{
"type" : "section" ,
"text" : {
"type" : "mrkdwn" ,
"text" : " *Information*\n ${ alertmessage } "
}
} ,
{
"type" : "context" ,
"elements" : [
@ -12,7 +12,7 @@ jsoninfo=$(
{
"chat_id" : " ${ telegramchatid } " ,
"parse_mode" : "HTML" ,
"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> " ,
"text" : " <b> ${ alerttitle } </b>\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> " ,
"disable_web_page_preview" : "yes"
}
EOF
@ -23,7 +23,7 @@ jsonnoinfo=$(
{
"chat_id" : " ${ telegramchatid } " ,
"parse_mode" : "HTML" ,
"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> " ,
"text" : " <b> ${ alerttitle } </b>\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 } " ,
"disable_web_page_preview" : "yes"
}
EOF