Escaping / in Telegram message


Some of my messages contain text with is preceded by a slash. The telegram-bot parses that into a blue, clickable command :


Any idea what the best way is to escape this?

If it is html text, perhaps you could try: /

Thanks for your reply, but I'n using parsing mode MarkdownV2, not HTML

Then try to escape it with a backslash, eg. \/

.replace(///g, "\/") doesn't seem to do the trick, it still gets displayed unchanged.

Any further suggestions?

Having escaped it with backslash did the backslash appear as a character? If not did you check that the backslash was really there in the sent message?

Yes, use html instead ?

Dont think it is possible see questions around telegram + markdown + escaping (google)

Colin I don't really get what you mean. Before and after escaping doesn't make any difference. My input message contains a /slash and my output message still gets treated as a command, which it isn't. It's just like I would send a message containing "Do you like this feature yes/no" and the /no becomes clickable as if it is a command.

The only "but" in this case is that my message contains the text "berm-/ruigte" so maybe the - prior to the slash causes the issue. As workaround I could replace "-/" by "/" which probably should solve this particular case, but overall I was wondering if this command feature could be disabled somehow... If not I should probably have to deal with it...

Did you check that, having done the replace, the text you were sending was berm-\/ruigte?

[Edit] Might also be worth trying berm\-/ruigte

For now, this solves the issue for me; replace(/-//g, "/")

For those that come hereafter it might be useful if you said whether escaping the - did anything.

That character was already escaped, otherwise my payload would not be accepted by the Telegram-bot : replace(/-/g, "\-")

But that doesn't solve anything, since that line was already present before I posted my issue.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.