grammyjs / grammY

The Telegram Bot Framework.
https://grammy.dev
MIT License
2.04k stars 106 forks source link

Bot - Better way of sending multiple message with array of objects. #606

Closed cvmabilin closed 1 month ago

cvmabilin commented 1 month ago

Good day!

I would like to know if there is much more alternative way of sending multiple message with inline keyboard? Currently I am using loop for sending message with a interval in each loop to avoid the error "Too Many Request". My bot is sending message to a group every hour like 15-20 automated message.

Currently I am using .map loop.

Screenshot 2024-06-25 at 4 12 47 PM

I would like to know if there is a better way other than this? Because sometimes the bot is not sending all the message, like it still return an error such as "Too Many Request" or the image path is not accepted.

Thank you so much.

KnorpelSenf commented 1 month ago

The better way is to use the auto-retry plugin. Then you can safely drop your artificial delay. This will make your bot faster and avoid HTTP 429 entirely. https://grammy.dev/plugins/auto-retry

KnorpelSenf commented 1 month ago

By the way:

the image path is not accepted

If this happens, then that is an unrelated error and you need to fix the image or use a different path.

cvmabilin commented 1 month ago

@KnorpelSenf Understood. Thank you for the information.