E
E
enabl32018-11-05 13:26:55
Python
enabl3, 2018-11-05 13:26:55

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

2 answer(s)
E
enabl3, 2018-11-06
@enabl3

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)

I
Ivan Shumov, 2018-11-05
@inoise

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 question

Ask a Question

731 491 924 answers to any question