Repository navigation
Built-in Rate Limiter - Questions #4145
Replies: 1 comment
|
Q1 — No, it is not enabled by default. Installing the base package does not throttle anything, and installing from telegram.ext import AIORateLimiter, ApplicationBuilder
app = (
ApplicationBuilder()
.token(TOKEN)
.rate_limiter(AIORateLimiter())
.build()
)Q2 — Your throughput guess is roughly right, the mechanism is not batches. With the defaults, For your 120 different private users, the 20/minute limit for a single group is not what determines the total time — the 30/second overall limit is — so expect the sends to be spread over roughly 3–4 seconds in total (plus API/network latency), assuming you issue them concurrently; a sequential One caveat: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi to all in the community 😄
I have a few questions on the rate limiter functionality of the Python Telegram Bot!
Context
recently I've read about this wiki page on avoiding flood limits due to Telegram API usage policy. As reported in this page, PTB comes with a built-in implementation of
telegram.ext.BaseRateLimitercalledtelegram.ext.AIORateLimiterthat is calibrated on the Telegram APIs flood limits.Question 1 - Is the rate limiter enabled by default without explicit rate-limiter dependency?
It is not clear to me whether this functionality is enabled by default in the basic package installation or if the optional pip dependency (
python-telegram-bot[rate-limiter]) mentioned here must be made explicit so that the rate limiter is effective.From what I understand, the optional dependency should be added only if I plan to use it with different parameters when creating the
ApplicationBuilderobject or if I want to create a new class based onBaseRateLimiter, otherwise it works by default. Is this correct?Question 2 - How does the evaluation period works in the rate limiter?
For example, I have 120 single users that I want to notify with my Telegram Bot. When I invoke the send message function, the Bot rate-limiter prepares 4 batches of 30 messages each and then it sends one batch every second. Is this correct or does it take other logic in consideration?
Thanks in advance to anyone helping me.
All reactions