node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

add sendLongMessage function to telegram.js

Open shahabhm opened this issue 1 year ago • 4 comments

  • [ ] All tests pass
  • [ ] I have run npm run doc

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

shahabhm avatar Feb 13 '23 21:02 shahabhm

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.

kamikazechaser avatar Feb 15 '23 06:02 kamikazechaser

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

shahabhm avatar Feb 19 '23 20:02 shahabhm

any solution about this? I have the same problem

ArtToledo avatar Dec 13 '23 18:12 ArtToledo

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

ArtToledo avatar Dec 13 '23 20:12 ArtToledo