Telegram-bot-sdk: Can't escape markdown.

Created on 5 Jan 2016  路  8Comments  路  Source: irazasyed/telegram-bot-sdk

I'm not quite sure what's happening, but I'm sending messages with backslashes in front of Markdown special characters in https://github.com/TheReverend403/AsukaTG/blob/90ba0221370e9a6e44ea295c1c887e0fc80bfc49/commands/QuoteCommand.php#L120 to fix Can't parse message text: Can't find end of the entity, but this escaping doesn't seem to be working. Something seems to be modifying my escaping after I call replyWithMessage().

Sample message:

2016/01/05 08:48:23 [error] 4539#4539: *352659 FastCGI sent in stderr: "PHP message: Quote #1 added at Tue, 05 Jan 2016 13:24:29 +0000

*No such quote!*
_-- Asuka  (@Asuka\_Bot)_

Source: Telegram
PHP message: PHP Fatal error:  Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: `POST https://api.telegram.org/botREDACTED/sendMessage` resulted in a `400 Bad Request` response:
{"ok":false,"error_code":400,"description":"[Error]: Bad Request: Can't parse message text: Can't find end of the entity (truncated...)

Most helpful comment

The only workaround is to use HTML in the parse_mode

https://core.telegram.org/bots/api#html-style

All 8 comments

I think that's from Telegram's end and their markdown parser doesn't support such kinda escaping.

How about you try something like this:

*No such quote!*
_-- Asuka  ([@Asuka_Bot](https://telegram.me/Asuka_Bot))_

Or

*No such quote!*
_-- Asuka_  (@Asuka_Bot)

That doesn't work for what I'm trying to do unfortunately. I'm trying to escape markdown special characters in user input, but if Telegram doesn't support it, this issue isn't needed.

You should consider messaging Telegram Bot Support and report this issue. They'll look into it and possibly push a fix if its a bug from their end and or if they want to support it.

It appears to be supported to some extent.

test.

Strange.

Isn't that inline bot query? That's totally different from this one.

i used this topic in stack overflow:
http://meta.stackexchange.com/questions/82718/how-do-i-escape-a-backtick-in-markdown
the only isssue is just some of these mark are supported, so i escape what the bot said, and i didn't escape others, i'm afraid of tommorow maybe they add something else :-s and again the system crash

i found out when i actually using mark down, for example i say *..* _.._ x.escapeMarkdown() it doesn't work. and only when there is no markdown, it escape the things in there, like x.escapemarkdown() which in my test x was mimosh_pisholack turned to mimosh\_pisholack

The only workaround is to use HTML in the parse_mode

https://core.telegram.org/bots/api#html-style

Was this page helpful?
0 / 5 - 0 ratings

Related issues

corneyl picture corneyl  路  3Comments

khalilst picture khalilst  路  3Comments

YaroslavStrigun picture YaroslavStrigun  路  4Comments

wlinh picture wlinh  路  3Comments

behnamazimi picture behnamazimi  路  3Comments