This Python module is designed to simplify user management in Telegram bots, providing the necessary functionality for tasks such as user authentication, authorization and compliance with speed limits, ensuring effective management of user attributes and access rights.
MIT License
1
stars
0
forks
source link
Incorrect calculation of rate_limit if it is already applied and you need to calculate the timer for additional messages #32
Context
In a situation when a message exceeding the quota for requests is received, _ratelimit is applied with the time stamp now +1 hour'. But all subsequent messages received after the restrictions are applied receive a timestamp according to the same formulanow + 1 hour'.
The result is a situation where after 1 hour 3 will be processed at once (for example) messages, not 1, as specified in the configuration.
[x] with an already existing limit, depending on the per_hour setting, you need to add +1 hour to the already existing rate limit end time
[x] the request counter should reset to zero only during the end of the timer rate_limits in end_time
[x] when calculating the limit end timer for an incoming request (if rate limits is already applied), you need to proceed from the per_hour limit on requests if >1 request per hour is allowed
[x] add tests to check the recalculation of request counters
[x] add tests to check the end_time timestamp, namely whether the time shift in end_time is calculated correctly when the request counter limit is exceeded multiple times
Context In a situation when a message exceeding the quota for requests is received, _ratelimit is applied with the time stamp
now +1 hour'. But all subsequent messages received after the restrictions are applied receive a timestamp according to the same formula
now + 1 hour'. The result is a situation where after 1 hour 3 will be processed at once (for example) messages, not 1, as specified in the configuration.requests configuration
To-Do
+1 hour
to the already existing rate limit end timerate_limits
inend_time
[x] when calculating the limit end timer for an incoming request (if rate limits is already applied), you need to proceed from the
per_hour
limit on requests if>1
request per hour is allowedTests
end_time
timestamp, namely whether the time shift inend_time
is calculated correctly when the request counter limit is exceeded multiple times