from aiogram.dispatcher.middlewares.base import BaseMiddleware
from aiogram.types import TelegramObject

class ContextMiddleware(BaseMiddleware):
    def __init__(self, db, user_model, admin_model):
        super().__init__()
        self.db = db
        self.user_model = user_model
        self.admin_model = admin_model

    async def __call__(self, handler, event: TelegramObject, data: dict):
        data["db"] = self.db
        data["user_model"] = self.user_model
        data["admin_model"] = self.admin_model
        return await handler(event, data)