playwright/browser_patches/buildbots/send_telegram_message.sh
Andrey Lushnikov a8c6bd66cd devops: properly handle double quotes in TG notifications
Since we send JSON, double quotes have to be escaped.
2020-01-11 01:39:22 +01:00

15 lines
441 B
Bash

send_telegram_message() {
if [[ -z $TELEGRAM_BOT_KEY ]]; then
return;
fi
if ! command -v curl >/dev/null; then
return;
fi
local TEXT=${1//\"/\\\"}
curl --silent \
-X POST \
-H 'Content-Type: application/json' \
-d '{"chat_id": "-1001225613794", "parse_mode": "html", "text": "'"$TEXT"'", "disable_notification": false}' \
https://api.telegram.org/bot$TELEGRAM_BOT_KEY/sendMessage >/dev/null
}