Skip to content

Commit 44daf20

Browse files
authored
fix(telegram): resolve alert sending invalid json (#3605)
The telegram alert was using invalid json (though telegram did accept it). JSON has been corrected and is now valid
1 parent 0fee00e commit 44daf20

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lgsm/functions/alert_telegram.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ json=$(cat <<EOF
1212
"chat_id": "${telegramchatid}",
1313
"parse_mode": "HTML",
1414
"text": "<b>${alertemoji} ${alertsubject} ${alertemoji}</b>\n\n<b>Server name</b>\n${servername}\n\n<b>Message</b>\n${alertbody}\n\n<b>Game</b>\n${gamename}\n\n<b>Server IP</b>\n<a href='https://www.gametracker.com/server_info/${alertip}:${port}'>${alertip}:${port}</a>\n\n<b>Hostname</b>\n${HOSTNAME}\n\n<b>More info</b>\n<a href='${alerturl}'>${alerturl}</a>",
15-
"disable_web_page_preview": "yes",
15+
"disable_web_page_preview": "yes"
16+
}
1617
EOF
1718
)
1819

1920
fn_print_dots "Sending Telegram alert"
20-
telegramsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d """${json}""" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")
21+
telegramsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d "$(echo -n "${json}" | jq -c .)" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")
2122

2223
if [ -n "${telegramsend}" ]; then
2324
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"

0 commit comments

Comments
 (0)