Browse Source

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
pull/3609/head
Daniel Gibbs 4 years ago
committed by GitHub
parent
commit
44daf20083
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      lgsm/functions/alert_telegram.sh

5
lgsm/functions/alert_telegram.sh

@ -12,12 +12,13 @@ json=$(cat <<EOF
"chat_id": "${telegramchatid}",
"parse_mode": "HTML",
"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>",
"disable_web_page_preview": "yes",
"disable_web_page_preview": "yes"
}
EOF
)
fn_print_dots "Sending Telegram alert"
telegramsend=$(curl --connect-timeout 10 -sSL -H "Content-Type: application/json" -X POST -d """${json}""" ${curlcustomstring} "https://${telegramapi}/bot${telegramtoken}/sendMessage" | grep "error_code")
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")
if [ -n "${telegramsend}" ]; then
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"

Loading…
Cancel
Save