Skip to content

Commit 6891b3c

Browse files
committed
fix(main): close bot (#21)
1 parent 8f3e2af commit 6891b3c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/ttt/main/aiogram/di.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import AsyncIterator
12
from dataclasses import dataclass
23
from typing import cast
34

@@ -122,11 +123,12 @@ def provide_dp(self, storage: BaseStorage) -> Dispatcher:
122123
return dp
123124

124125
@provide(scope=Scope.APP)
125-
async def provide_bot(self, secrets: Secrets) -> Bot:
126+
async def provide_bot(self, secrets: Secrets) -> AsyncIterator[Bot]:
126127
bot = Bot(secrets.bot_token)
127-
await ttt_bot(bot)
128128

129-
return bot
129+
async with bot:
130+
await ttt_bot(bot)
131+
yield bot
130132

131133
provide_emoji = provide(
132134
PictographsAsEmojis,

src/ttt/main/common/di.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def provide_waiting_locations(
236236
scope=Scope.APP,
237237
)
238238

239-
provide__game_log = provide(
239+
provide_game_log = provide(
240240
StructlogGameLog,
241241
provides=GameLog,
242242
scope=Scope.REQUEST,

0 commit comments

Comments
 (0)