Browse Source
refactor: improve alert message formatting
- Refactored the code in `alert_pushover.sh` and `alert_telegram.sh` to improve the formatting of the alert messages.
- Updated the message structure to include the server name before other information.
- Added line breaks for better readability.
- Made sure that all variables are properly interpolated within the messages.
pull/4345/head
Daniel Gibbs
2 years ago
No known key found for this signature in database
GPG Key ID: 2076B128385E8C55
2 changed files with
4 additions and
4 deletions
lgsm/modules/alert_pushover.sh
lgsm/modules/alert_telegram.sh
@ -23,9 +23,9 @@ else
fi
fi
if [ -z " ${ alerturl } " ] ; then
if [ -z " ${ alerturl } " ] ; then
pushoversend = $( curl --connect-timeout 10 -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 } " "https://api.pushover.net/1/messages.json" | grep errors)
pushoversend = $( curl --connect-timeout 10 -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 } " "https://api.pushover.net/1/messages.json" | grep errors)
else
else
pushoversend = $( curl --connect-timeout 10 -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> " "https://api.pushover.net/1/messages.json" | grep errors)
pushoversend = $( curl --connect-timeout 10 -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> " "https://api.pushover.net/1/messages.json" | grep errors)
fi
fi
if [ -n " ${ pushoversend } " ] ; then
if [ -n " ${ pushoversend } " ] ; then
@ -12,7 +12,7 @@ jsoninfo=$(
{
{
"chat_id" : " ${ telegramchatid } " ,
"chat_id" : " ${ telegramchatid } " ,
"parse_mode" : "HTML" ,
"parse_mode" : "HTML" ,
"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> " ,
"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> " ,
"disable_web_page_preview" : "yes"
"disable_web_page_preview" : "yes"
}
}
EOF
EOF
@ -23,7 +23,7 @@ jsonnoinfo=$(
{
{
"chat_id" : " ${ telegramchatid } " ,
"chat_id" : " ${ telegramchatid } " ,
"parse_mode" : "HTML" ,
"parse_mode" : "HTML" ,
"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 } " ,
"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 } " ,
"disable_web_page_preview" : "yes"
"disable_web_page_preview" : "yes"
}
}
EOF
EOF