-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Telegram sendMessage limit handling #4
Comments
Hi, This module does not feature a rate-limiting feature yet. That means you will have to implemement it yourself for now. Telegram claims a max of 30 calls/sec however you can get 429 errors below or above that value. In the meanwhile we can wait to see if @GochoMugo will add a new rate-limiting fanciness! |
@iMasoud: Thanks for your interest in this library. Hope it helps you build better bots. We can add this new fanciness: rate-limiting:On rate-limit errors, we receive Currently, node-telegram-bot-api does passes us a generic Error object in the My approach in implementing this feature:
You (@kamikazechaser) might realize that I have decided not to use a rate-limiting library, like node-rate-limiter or pothole. I feel that would add too much complexity in the implementation. However, after the above suggested implementation has been worked out, we will consider including such capabilities within! I will work on this asap! |
@kamikazechaser: Thanks for your reply. @GochoMugo: Your concept sounds great. I can't wait to see it implemented! |
@iMasoud The findings were made by the writer of GroupButler, who also was among the first to unofficially document the various error codes not found in the official docs. C.C @RememberTheAir |
So, in the mean time, you might use pothole, in this way: const pothole = require("pothole");
// creating a rate-limiter to use for the Telegram Bot API
pothole.add("TelegramBotAPI", {
window: {
size: 30, // 30 requests...
length: 1000, // ...in 1 second (1000 ms)
},
});
// the function that you will use instead of 'TelegramBot#sendMessage()'
function sendMessage(chatId, text) {
return new Promise(function(resolve, reject) {
pothole.enqueue("TelegramBotAPI", function() {
bot.sendMessage(chatId, text).then(resolve).catch(reject);
});
});
}
// sending a message
sendMessage(chatId, text); Note that the above solution does not take into account any other |
Feature: Please read the README.md for documentation on this feature. References: * Feature request: #4
Rate-limiting fanciness added in v0.7.0. See the docs. |
Hi,
This module is very interesting to me. But I'm wondering if it's able to handle sendMessage limits of telegram?
I mean if I call sendMessage 31 times in a second, will it manage to execute first 30 in same second and execute the 31st in next?
I have the same question about two other limits of telegram which are; sending only one message per second to same chat id and sending 20 messages per second (at most) to same group.
The text was updated successfully, but these errors were encountered: