Merge pull request #3479 from mjbnz/dev

Update Telegram notification
This commit is contained in:
neil 2021-04-09 10:08:48 +08:00 committed by GitHub
commit 64ad8b1dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,15 +27,18 @@ telegram_send() {
fi fi
_saveaccountconf_mutable TELEGRAM_BOT_CHATID "$TELEGRAM_BOT_CHATID" _saveaccountconf_mutable TELEGRAM_BOT_CHATID "$TELEGRAM_BOT_CHATID"
_content="$(printf "%s" "$_content" | sed -e 's/*/\\\\*/')"
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)" _content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
_data="{\"text\": \"$_content\", " _data="{\"text\": \"$_content\", "
_data="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", " _data="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", "
_data="$_data\"parse_mode\": \"markdown\", " _data="$_data\"parse_mode\": \"markdown\", "
_data="$_data\"disable_web_page_preview\": \"1\"}" _data="$_data\"disable_web_page_preview\": \"1\"}"
_debug "$_data"
export _H1="Content-Type: application/json" export _H1="Content-Type: application/json"
_telegram_bot_url="https://api.telegram.org/bot${TELEGRAM_BOT_APITOKEN}/sendMessage" _telegram_bot_url="https://api.telegram.org/bot${TELEGRAM_BOT_APITOKEN}/sendMessage"
if _post "$_data" "$_telegram_bot_url"; then if _post "$_data" "$_telegram_bot_url" >/dev/null; then
# shellcheck disable=SC2154 # shellcheck disable=SC2154
_message=$(printf "%s\n" "$response" | sed -n 's/.*"ok":\([^,]*\).*/\1/p') _message=$(printf "%s\n" "$response" | sed -n 's/.*"ok":\([^,]*\).*/\1/p')
if [ "$_message" = "true" ]; then if [ "$_message" = "true" ]; then