skip to Main Content

This is the error i get when i try to send a long markdown message which has a ton of formatted hyperlinks in it:

context.bot.send_message(chat_id=update.effective_chat.id, text=longmsg, parse_mode="MARKDOWN")

#Output:
telegram.error.BadRequest: Entities_too_long

The actual message is hardly 500 characters long, but almost every word is hyperlinked which is making the string longmsg very long (>12k string length)

Now, I know that for normal messages 4096 characters is the limit, but when sending markdown messages, the Telegram API seems to be allowing > 4096 string length. So what is the exact string length limit for markdown messages? I’m using the python-telegram-bot library.

2

Answers


  1. Chosen as BEST ANSWER

    9500 characters is the string length limit for sending markdown messages via send_message, found out using a brute force test.


  2. This limit seems to be undocumented. I only know that TG only parses 100 entities per message and just drops any further entities (which is also undocumented). You can try to contact TG about it via one of the following channels:

    Just to clarify: This is not an issue of the library you’re using (here python-telegram-bot) – you’d get the same error when making the request manually

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search