Answer the question
In order to leave comments, you need to log in
Why does Telegram Bot format text incompletely?
I have a text (~2500 characters) which is dynamically calculated each time. It has HTML tags for bold text (<b>). Somewhere after about 1700-hundred characters, Telegram no longer displays the boldness of the text, but simply removes the < b > tag. At the same time, how many characters, at least 4000, at least 1800 Telegram anyway. Why is it so?
Library - PyTelegramBotAPI
bot.send_message(message.chat.id, text, parse_mode='HTML')
Answer the question
In order to leave comments, you need to log in
Sending large text messages
Sometimes you must send messages that exceed 5000 characters. The Telegram API can not handle that many characters in one request, so we need to split the message in multiples. Here is how to do that using the API:
from telebot import util
large_text = open("large_text.txt", "rb").read()
# Split the text each 3000 characters.
# split_string returns a list with the splitted text.
splitted_text = util.split_string(large_text, 3000)
for text in splitted_text:
tb.send_message(chat_id, text)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question