chore: restructured project

This commit is contained in:
ITQ
2025-03-07 19:32:09 +03:00
parent bfb7ad901a
commit 0a35951c62
178 changed files with 304 additions and 376 deletions
@@ -0,0 +1,24 @@
from collections.abc import Awaitable, Callable
from typing import Any
from aiogram import BaseMiddleware
from aiogram.types import Message
from cachetools import TTLCache
class ThrottlingMiddleware(BaseMiddleware):
def __init__(self, time_limit: float = 2) -> None:
self.limit = TTLCache(maxsize=10_000, ttl=time_limit)
async def __call__(
self,
handler: Callable[[Message, dict[str, Any]], Awaitable[Any]],
event: Message,
data: dict[str, Any],
) -> Any | None:
if event.chat.id in self.limit:
return None
self.limit[event.chat.id] = None
return await handler(event, data)