diff --git a/src/ttt/main/aiogram/di.py b/src/ttt/main/aiogram/di.py index ff547fd..2951e6a 100755 --- a/src/ttt/main/aiogram/di.py +++ b/src/ttt/main/aiogram/di.py @@ -1,3 +1,4 @@ +from collections.abc import AsyncIterator from dataclasses import dataclass from typing import cast @@ -122,11 +123,12 @@ def provide_dp(self, storage: BaseStorage) -> Dispatcher: return dp @provide(scope=Scope.APP) - async def provide_bot(self, secrets: Secrets) -> Bot: + async def provide_bot(self, secrets: Secrets) -> AsyncIterator[Bot]: bot = Bot(secrets.bot_token) - await ttt_bot(bot) - return bot + async with bot: + await ttt_bot(bot) + yield bot provide_emoji = provide( PictographsAsEmojis, diff --git a/src/ttt/main/common/di.py b/src/ttt/main/common/di.py index ac6833a..fc51c1f 100644 --- a/src/ttt/main/common/di.py +++ b/src/ttt/main/common/di.py @@ -236,7 +236,7 @@ def provide_waiting_locations( scope=Scope.APP, ) - provide__game_log = provide( + provide_game_log = provide( StructlogGameLog, provides=GameLog, scope=Scope.REQUEST,