Adding more control on sending requests to BotAPI
Is your feature request related to a problem? Please describe. Sometimes it's useful to modify, cancel or delay sending request to BotAPI.
Describe the solution you'd like Adding 2 new middleware triggers, before and after making request.
@Forden, I don't quite understand why do we need request feature. Could you please provide use cases?
@uwinx, for me the most important case is creating of "smart" outcoming queue as middleware.
Delay is a bad thing! VERY BAD! You can't receive update via webhook and postpone the answer. Telegram will repeat webhook and u'll get doubled update.
If you mean delay for outcoming request, why don't you use aio.sleep()?
@Olegt0rr I think he meant something like anti-flood queue. We're not allowed to send more than 30 requests per second, so this kind of "smart queue" can help us avoid these limits by throttling outgoing requests.
@evgfilim1 First of all, 30 rps is not a fixed limit. If your bot size doesn't fit the limit, you can ask botsupport to increase the limits.
Antiflood shoud be implemented as inbound filter so as not to damage the business logic of your application. Throttling / delaying outgoing requests can make application behavior unpredictable.
@JrooTJunior, It's up to you, but I think that it's not a good thing to make global solutions for such a private case. If some bots require a solution with throttling of outgoing requests, we can add the feature with setting custom host instead of api.telegram.org. It'll add the ability to create post-processing proxy app outside the aiogram
Implemented in v3: https://docs.aiogram.dev/en/dev-3.x/api/session/middleware.html