telegram-support-bot icon indicating copy to clipboard operation
telegram-support-bot copied to clipboard

Symbols not escaped (Markdown/MarkdownV2)

Open Geparder opened this issue 2 years ago • 3 comments

"Thu May 25 2023 11:16:53 GMT+0000 (Coordinated Universal Time): GrammyError: Call to 'sendMessage' failed! (400: Bad Request: can't parse entities: Character '(' is reserved and must be escaped with the preceding '\')\n" + 2023-05-25T11:16:53.434547877Z ' at toGrammyError (/bot/node_modules/grammy/out/core/error.js:35:12)\n' + 2023-05-25T11:16:53.434553744Z ' at ApiClient.callApi (/bot/node_modules/grammy/out/core/client.js:86:48)'

Geparder avatar May 25 '23 11:05 Geparder

Hello there! As you are a first time Issuer please check whether your issue description is reasonable and complete. If you are having an issue always include the versions you are using (NodeJs, Typescript, ...) as well as a way to reproduce it. Thank you for reading! Now continue :)

github-actions[bot] avatar May 25 '23 11:05 github-actions[bot]

ping @bostrot

gituser avatar Jun 16 '23 11:06 gituser

There is an issue with escaping, e.g. if you try to send this text with MarkdownV2 syntax it will fail:

Test (
'elem1' => 'test123',
'elem2' => 'test345',
'elem3' => 'test444',
)

This is because of the escape rules defined here for urls - https://github.com/bostrot/telegram-support-bot/blob/master/src/middleware.ts#L41

The error in the log will look like this:

GrammyError: Call to 'sendMessage' failed! (400: Bad Request: can't parse entities: Character '=' is reserved and must be escaped with the preceding '\')

Easiest fix is to comment this block of code, but then again for URL markdown won't work.

Also noticed that MarkdownV2 strips all tags like code tags ``` and send to the user as a plaintext message.

Maybe you could take a look at this issue @bostrot.

It seems forwarding messages with MarkDownV2 e.g. with code blocks or using some other elements will not work for your users, guess it's something that should be added as a feature.

Thanks.

gituser avatar Oct 16 '23 11:10 gituser