Skip to content

Commit 26c2fc2

Browse files
authored
Moving to MarkdownV2 as the old Markdown is obsolete
- Implemented MarkdownV2 with escape of all necessary characters. - Ref: https://core.telegram.org/bots/api#markdownv2-style
1 parent fef74c3 commit 26c2fc2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

notify/telegram.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ telegram_send() {
2727
fi
2828
_saveaccountconf_mutable TELEGRAM_BOT_CHATID "$TELEGRAM_BOT_CHATID"
2929

30-
_subject="$(printf "%s" "$_subject" | sed 's/\*/\*\\\\*\*/g')"
31-
_content="$(printf "%s" "$_content" | sed 's/\([_*`\[]\)/\\\\\1/g')"
30+
_subject="$(printf "%s" "$_subject" | sed 's/\\/\\\\\\\\/g' | sed 's/\]/\\\\\]/g' | sed 's/\([_*[()~`>#+--=|{}.!]\)/\\\\\1/g')"
31+
_content="$(printf "%s" "$_content" | sed 's/\\/\\\\\\\\/g' | sed 's/\]/\\\\\]/g' | sed 's/\([_*[()~`>#+--=|{}.!]\)/\\\\\1/g')"
3232
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
3333
_data="{\"text\": \"$_content\", "
3434
_data="$_data\"chat_id\": \"$TELEGRAM_BOT_CHATID\", "
35-
_data="$_data\"parse_mode\": \"markdown\", "
35+
_data="$_data\"parse_mode\": \"MarkdownV2\", "
3636
_data="$_data\"disable_web_page_preview\": \"1\"}"
3737

3838
_debug "$_data"

0 commit comments

Comments
 (0)