Skip to content

Commit 4f5e3e3

Browse files
committed
ref(presentation): extract aiogram_dialog from dialogs (#28)
1 parent c822ed6 commit 4f5e3e3

32 files changed

+931
-769
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ build-backend = "hatchling.build"
4949
packages = ["src/ttt"]
5050

5151
[project.scripts]
52-
ttt = "ttt.main.aiogram_prod.__main__:main"
53-
ttt-dev = "ttt.main.aiogram_dev.__main__:main"
52+
ttt = "ttt.main.tg_bot_prod.__main__:main"
53+
ttt-dev = "ttt.main.tg_bot_dev.__main__:main"
5454

5555
[tool.uv]
5656
add-bounds = "exact"

src/ttt/application/user/emoji_selection/ports/user_views.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,3 @@ async def emoji_not_purchased_to_select_view(
1515
user_id: int,
1616
/,
1717
) -> None: ...
18-
19-
@abstractmethod
20-
async def emoji_selected_view(
21-
self,
22-
user_id: int,
23-
/,
24-
) -> None: ...
File renamed without changes.

src/ttt/main/aiogram/di.py renamed to src/ttt/main/tg_bot/di.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979
AiogramMessagesFromPostgresAsEmojiSelectionUserViews,
8080
)
8181
from ttt.presentation.aiogram.common.bots import ttt_bot
82-
from ttt.presentation.aiogram.common.dialogs import dialog
8382
from ttt.presentation.aiogram.common.routes.all import common_routers
8483
from ttt.presentation.aiogram.user.routes.all import user_routers
84+
from ttt.presentation.aiogram_dialog.main_dialog import main_dialog
8585
from ttt.presentation.result_buffer import ResultBuffer
8686
from ttt.presentation.unkillable_tasks import UnkillableTasks
8787

@@ -181,7 +181,7 @@ def provide_dp(self, storage: BaseStorage) -> Dispatcher:
181181
*user_routers,
182182
)
183183

184-
dp.include_routers(dialog)
184+
dp.include_routers(main_dialog)
185185
setup_dialogs(dp)
186186

187187
return dp
File renamed without changes.
File renamed without changes.

src/ttt/main/aiogram_dev/__main__.py renamed to src/ttt/main/tg_bot_dev/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
DevLoggerFactory,
88
LoggerFactory,
99
)
10-
from ttt.main.aiogram.di import (
10+
from ttt.main.common.di import InfrastructureProvider
11+
from ttt.main.tg_bot.di import (
1112
ApplicationProvider,
1213
PresentationProvider,
1314
)
14-
from ttt.main.aiogram.start_aiogram import start_aiogram
15-
from ttt.main.common.di import InfrastructureProvider
15+
from ttt.main.tg_bot.start_aiogram import start_aiogram
1616

1717

1818
async def amain() -> None:
File renamed without changes.

src/ttt/main/aiogram_prod/__main__.py renamed to src/ttt/main/tg_bot_prod/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from dishka.integrations.aiogram import AiogramProvider
55

66
from ttt.infrastructure.structlog.logger import LoggerFactory, ProdLoggerFactory
7-
from ttt.main.aiogram.di import (
7+
from ttt.main.common.di import InfrastructureProvider
8+
from ttt.main.tg_bot.di import (
89
ApplicationProvider,
910
PresentationProvider,
1011
)
11-
from ttt.main.aiogram.start_aiogram import start_aiogram
12-
from ttt.main.common.di import InfrastructureProvider
12+
from ttt.main.tg_bot.start_aiogram import start_aiogram
1313

1414

1515
async def amain() -> None:

src/ttt/presentation/adapters/game_views.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
from ttt.infrastructure.background_tasks import BackgroundTasks
1616
from ttt.infrastructure.sqlalchemy.tables.game import TableGame
1717
from ttt.infrastructure.sqlalchemy.tables.user import TableUser
18-
from ttt.presentation.aiogram.common.dialogs import (
18+
from ttt.presentation.aiogram.game.messages import completed_game_sticker
19+
from ttt.presentation.aiogram_dialog.main_dialog.common import MainDialogState
20+
from ttt.presentation.aiogram_dialog.main_dialog.game_window import (
1921
ActiveGameView,
2022
CompletedGameView,
21-
DialogState,
2223
)
23-
from ttt.presentation.aiogram.game.messages import completed_game_sticker
2424
from ttt.presentation.result_buffer import ResultBuffer
2525

2626

@@ -37,7 +37,7 @@ async def waiting_for_game_view(self, user_id: int, /) -> None:
3737
self._bot, user_id, user_id,
3838
)
3939
await dialog_manager.start(
40-
DialogState.game_mode_to_start_game,
40+
MainDialogState.game_mode_to_start_game,
4141
{"hint": "⚔️ Поиск игры начат"},
4242
StartMode.RESET_STACK,
4343
)
@@ -85,7 +85,7 @@ async def started_game_view_with_locations(
8585
self._bot, location.user_id, location.user_id,
8686
)
8787
await dialog_manager.start(
88-
DialogState.game,
88+
MainDialogState.game,
8989
ActiveGameView.of(game, location.user_id).window_data(),
9090
StartMode.RESET_STACK,
9191
)
@@ -97,7 +97,7 @@ async def no_game_view(self, user_id: int, /) -> None:
9797
self._bot, user_id, user_id,
9898
)
9999
await dialog_manager.start(
100-
DialogState.main, data, StartMode.RESET_STACK,
100+
MainDialogState.main, data, StartMode.RESET_STACK,
101101
)
102102

103103
async def game_already_complteted_view(
@@ -111,7 +111,7 @@ async def game_already_complteted_view(
111111
)
112112
data = {"hint": "❌ Игра уже закончилась"}
113113
await dialog_manager.start(
114-
DialogState.game, data, StartMode.RESET_STACK,
114+
MainDialogState.game, data, StartMode.RESET_STACK,
115115
)
116116

117117
async def not_current_user_view(
@@ -128,7 +128,7 @@ async def not_current_user_view(
128128
self._bot, user_id, user_id,
129129
)
130130
await dialog_manager.start(
131-
DialogState.game, data, StartMode.RESET_STACK,
131+
MainDialogState.game, data, StartMode.RESET_STACK,
132132
)
133133

134134
async def no_cell_view(
@@ -159,7 +159,7 @@ async def already_filled_cell_error(
159159
self._bot, user_id, user_id,
160160
)
161161
await dialog_manager.start(
162-
DialogState.game, data, StartMode.RESET_STACK,
162+
MainDialogState.game, data, StartMode.RESET_STACK,
163163
)
164164

165165
async def _active_game_view(
@@ -173,7 +173,7 @@ async def _active_game_view(
173173
data = view.window_data()
174174

175175
await dialog_manager.start(
176-
DialogState.game, data, StartMode.RESET_STACK,
176+
MainDialogState.game, data, StartMode.RESET_STACK,
177177
)
178178

179179
async def _completed_game_view(
@@ -193,7 +193,7 @@ async def _completed_game_view(
193193
self._bot, location.user_id, game, location.user_id,
194194
),
195195
dialog_manager.start(
196-
DialogState.game,
196+
MainDialogState.game,
197197
data,
198198
StartMode.RESET_STACK,
199199
ShowMode.DELETE_AND_SEND,

0 commit comments

Comments
 (0)