Answer the question
In order to leave comments, you need to log in
Sending big telegram bot messages?
Hello.
Please tell me how can I bypass the limit on the length of messages, which is set at 4096 characters?
I use the TeleBot library and when a long message is formed in response to the user, it crashes with the error Bad Request: message is too long.
Is it possible to somehow split this message into several, so that it comes in parts?
Answer the question
In order to leave comments, you need to log in
Resolved via:
if len(info) > 4096:
for x in range(0, len(info), 4096):
bot.send_message(message.chat.id, info[x:x+4096])
else:
bot.send_message(message.chat.id, info)
This is the limit per message. You can only divide into several different messages and it will not work out by one. Limits were invented for a reason
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question