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
Configuration `per_day` in RateLimit not working as expected #40
Describe the bug
Configuration per_day in RateLimit not working as expected.
According to my observations, this parameter does not work as expected and when the number of requests is exceeded, the query execution time accounting breaks down.
To Reproduce
Steps to reproduce the behavior:
Set configuration {"requests_per_day": 5, "requests_per_hour": 1, "random_shift_minutes": 360}
Generate 11-12 queries to apply daily ratelimit
The ratelimit timer will set the same processing time for all received requests for some time and will not add +1 day to it.
Expected behavior
If the daily ratelimit is exceeded, the processing time +1 day (+1 hour from the previous request) should be returned to all requests.
[2024-05-11 14:13:09,436] INFO [logger.logger:authentication:304] [class.Users] Access from user ID 123456789: allowed
[2024-05-11 14:13:09,651] INFO [logger.logger:authorization:363] [class.Users] Check role `role_list` for user `123456789`: allowed
[2024-05-11 14:13:09,862] INFO [logger.logger:authentication:304] [class.Users] Access from user ID 123456789: allowed
[2024-05-11 14:13:10,070] INFO [logger.logger:authorization:363] [class.Users] Check role `role_list` for user `123456789`: allowed
[2024-05-11 14:13:12,631] INFO [logger.logger:authentication:304] [class.Users] Access from user ID 123456789: allowed
[2024-05-11 14:13:12,849] INFO [logger.logger:authorization:363] [class.Users] Check role `role_list` for user `123456789`: allowed
[2024-05-11 14:13:13,048] INFO [logger.logger:authentication:304] [class.Users] Access from user ID 123456789: allowed
[2024-05-11 14:13:13,279] INFO [logger.logger:authorization:363] [class.Users] Check role `role` for user `123456789`: allowed
[2024-05-11 14:13:13,707] INFO [logger.logger:_update_requests_counters:520] [class.RateLimiter] Current request counters: {'requests_per_hour': 0, 'requests_per_day': 0}
[2024-05-11 14:13:13,708] WARNING [logger.logger:_active_rate_limit:378] [class.RateLimiter] A rate limit has been detected for user ID 123456789 that has already been applied and has not expired yet
[2024-05-11 14:13:14,162] INFO [logger.logger:update_status_message:307] [Bot]: Message with type `status_message` for user 123456789 has been updated
[2024-05-11 14:13:14,163] INFO [logger.logger:process_one_post:451] [Bot]: Message for user 123456789 added in queue
[2024-05-11 14:13:14,172] INFO [logger.logger:authentication:304] [class.Users] Access from user ID 123456789: allowed
[2024-05-11 14:13:14,331] INFO [logger.logger:authorization:363] [class.Users] Check role `role` for user `123456789`: allowed
[2024-05-11 14:13:14,646] INFO [logger.logger:_update_requests_counters:520] [class.RateLimiter] Current request counters: {'requests_per_hour': 1, 'requests_per_day': 1}
[2024-05-11 14:13:15,095] INFO [logger.logger:process_one_post:451] [Bot]: Message for user 123456789 added in queue
[2024-05-11 14:13:15,104] INFO [logger.logger:authentication:304] [class.Users] Access from user ID 123456789: allowed
[2024-05-11 14:13:15,250] INFO [logger.logger:authorization:363] [class.Users] Check role `role` for user `123456789`: allowed
[2024-05-11 14:13:15,530] INFO [logger.logger:_update_requests_counters:520] [class.RateLimiter] Current request counters: {'requests_per_hour': 2, 'requests_per_day': 2}
[2024-05-11 14:13:15,530] WARNING [logger.logger:_active_rate_limit:378] [class.RateLimiter] A rate limit has been detected for user ID 123456789 that has already been applied and has not expired yet
[2024-05-11 14:13:15,871] INFO [logger.logger:process_one_post:451] [Bot]: Message for user 123456789 added in queue
Check list
[ ] Add timestamp with end_time in all messages of logger about exist the rate limit A rate limit has been detected for user ID 123456789 that has already been applied and has not expired yet
Describe the bug Configuration
per_day
in RateLimit not working as expected. According to my observations, this parameter does not work as expected and when the number of requests is exceeded, the query execution time accounting breaks down.To Reproduce Steps to reproduce the behavior:
{"requests_per_day": 5, "requests_per_hour": 1, "random_shift_minutes": 360}
Expected behavior If the daily ratelimit is exceeded, the processing time +1 day (+1 hour from the previous request) should be returned to all requests.
Screenshots
Additional context Users data in Vault
Application logs
Check list
end_time
in all messages of logger about exist the rate limitA rate limit has been detected for user ID 123456789 that has already been applied and has not expired yet