5 #TELEGRAM_BOT_APITOKEN=""
6 #TELEGRAM_BOT_CHATID=""
11 _statusCode
="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
12 _debug
"_statusCode" "$_statusCode"
14 TELEGRAM_BOT_APITOKEN
="${TELEGRAM_BOT_APITOKEN:-$(_readaccountconf_mutable TELEGRAM_BOT_APITOKEN)}"
15 if [ -z "$TELEGRAM_BOT_APITOKEN" ]; then
16 TELEGRAM_BOT_APITOKEN
=""
17 _err
"You didn't specify a Telegram BOT API Token TELEGRAM_BOT_APITOKEN yet."
20 _saveaccountconf_mutable TELEGRAM_BOT_APITOKEN
"$TELEGRAM_BOT_APITOKEN"
22 TELEGRAM_BOT_CHATID
="${TELEGRAM_BOT_CHATID:-$(_readaccountconf_mutable TELEGRAM_BOT_CHATID)}"
23 if [ -z "$TELEGRAM_BOT_CHATID" ]; then
24 TELEGRAM_BOT_CHATID
=""
25 _err
"You didn't specify a Telegram Chat id TELEGRAM_BOT_CHATID yet."
28 _saveaccountconf_mutable TELEGRAM_BOT_CHATID
"$TELEGRAM_BOT_CHATID"
30 _content
="$(printf "%s
" "$_content" | sed -e 's/\([_*`\[]\)/\\\\\1/g')"
31 _content
="$(printf "*%s
*\n%s
" "$_subject" "$_content" | _json_encode)"
32 _data
="{\"text\": \"$_content\", "
33 _data
="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", "
34 _data
="$_data\"parse_mode\": \"markdown\", "
35 _data
="$_data\"disable_web_page_preview\": \"1\"}"
39 export _H1
="Content-Type: application/json"
40 _telegram_bot_url
="https://api.telegram.org/bot${TELEGRAM_BOT_APITOKEN}/sendMessage"
41 if _post
"$_data" "$_telegram_bot_url" >/dev
/null
; then
42 # shellcheck disable=SC2154
43 _message
=$
(printf "%s\n" "$response" |
sed -n 's/.*"ok":\([^,]*\).*/\1/p')
44 if [ "$_message" = "true" ]; then
45 _info
"telegram send success."
49 _err
"telegram send error."