I have a telegram bot and I want to send a message
in which the error message will be returned to me
my code is :
path = 'C:\Bot\Log\aaa\*.log'
files = glob.glob(path)
nlines= 0
data = "Servers : n"
for name in files:
with open(name) as f:
for line in f :
nlines += 1
if (line.find("Total") >= 0):
data += line
for i in range(5):
data += next(f)
data += f'n{emoji.emojize(":blue_heart:")} ----------------------------------------------------{emoji.emojize(":blue_heart:")}n'
if (line.find("Source") >= 0):
data += line
query.edit_message_text(
text=f"{data}",
reply_markup=build_keyboard(number_list),
)
my error is :
telegram.error.BadRequest: Message_too_long
According to this code model, how can I send my message to the bot?
3
Answers
Since Telegram has limit of 4096 chars per message, one way to work around will be to break your message down into 4096 chars and then send it, and repeat till the end.
You can begin with something like:
This code may works :
its still an open issue, but you can split your request for 4089 chars per send
you have 2 options:
or