Skip to content
Advertisement

Telegram API MarkdownV2 Escape Characters Bug

I am new to this. I am writing a telegram bot that interacts with Google Sheets in Google App Script. I am having an issue with MarkdownV2.

My code has one before the ‘!’ as Telegram said in their document:

‘!’ must be escaped with the preceding character

JavaScript

However, it says I need to use two \ instead.

JavaScript

But when I use two \ I still have a problem running.

JavaScript

When I run the link https://api.telegram.org/botxyz:abc/sendMessage?chat_id=xyz&text=Hey!%20New%20item&parse_mode=MarkdownV2 in the error, it connects to Telegram normally.

Thank you.

Advertisement

Answer

In your script, how about the following modification?

Modified script:

JavaScript
  • I thought that in your situation ! might be \!.

  • When this script is run, https://api.telegram.org/botxyz:abc/sendMessage?chat_id=xyz&text=Hey%5C!%20New%20item&parse_mode=MarkdownV2 can be seen in the log. This value is the same as the URL you tested at the bottom of your question.

Reference:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement