yagop / node-telegram-bot-api

Telegram Bot API for NodeJS
MIT License
8.35k stars 1.52k forks source link

add sendLongMessage function to telegram.js #1052

Open shahabhm opened 1 year ago

shahabhm commented 1 year ago

Description

I have added a method to handle sending long messages. this method splits the text into smaller parts and sends them. I also can add a test if you agree with this idea.

References

this resolves the following issue: Sending long messages

kamikazechaser commented 1 year ago

Well tbh, such a feature alongside #997 should not live in this library. It could either be a util or live outside the library.

One reason is that a quick fire of very long messages e,g, 50k characters+ can easily lead to 429's which can break the correct sequence.

shahabhm commented 1 year ago

that's right. do you think adding a limit to the text size is enough? like 8k or 12k characters?

ArtToledo commented 9 months ago

any solution about this? I have the same problem

ArtToledo commented 9 months ago
image image

I found an error in the implementation when using Math.Max, considering text.length as the second value, so the first time you run chunck, the idea is to cut the message into 4000 characters, with math.max in messages above this an X value, in my case 7741 characters, it gets the wrong chunck_end considering the total size of the message instead of considering where it should break the string