20 lines
502 B
Python
20 lines
502 B
Python
from collections.abc import Awaitable, Callable
|
|
from typing import Any
|
|
|
|
from aiogram import BaseMiddleware
|
|
from aiogram.types import TelegramObject
|
|
|
|
|
|
class ThrottleMiddleware(BaseMiddleware):
|
|
def __init__(self, limit: int):
|
|
self.limit = limit
|
|
|
|
async def __call__(
|
|
self,
|
|
handler: Callable[[TelegramObject, dict[str, Any]], Awaitable[Any]],
|
|
event: TelegramObject,
|
|
data: dict[str, Any],
|
|
) -> Any:
|
|
#todo
|
|
return await handler(event, data)
|