Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing data from middlewares via AiogramProvider #341

Merged
merged 5 commits into from
Jan 15, 2025

Conversation

K1rL3s
Copy link
Contributor

@K1rL3s K1rL3s commented Jan 14, 2025

Passing data from middlewares via AiogramProvider for other providers. Useful if your classes need a bot instance or something other from middlewares

Example:

class MyProvider(Provider):
    scope = Scope.REQUEST

    @provide
    def bot(self, middleware_data: AiogramMiddlewareData) -> Bot:
        return middleware_data["bot"]

    @provide
    def event_context(self, middleware_data: AiogramMiddlewareData) -> EventContext:
        # aiogram>=3.5.0
        return middleware_data["event_context"]

@Tishka17
Copy link
Member

Let's add something to docs

@Tishka17 Tishka17 merged commit 81f5b81 into reagento:develop Jan 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants