add common dialogs

This commit is contained in:
2025-09-25 21:13:04 +03:00
parent cbe1919343
commit 250a349209
7 changed files with 30 additions and 18 deletions

View File

@@ -1,8 +1,10 @@
from aiogram import Router from aiogram import Router
from .admin import admin_router from .admin import admin_router
from .common import common_router
from .user import user_router from .user import user_router
dialogs_router = Router(name="dialogs") dialogs_router = Router(name="dialogs")
dialogs_router.include_router(admin_router) dialogs_router.include_router(admin_router)
dialogs_router.include_router(user_router) dialogs_router.include_router(user_router)
dialogs_router.include_router(common_router)

View File

@@ -1,13 +1,18 @@
from aiogram_dialog import Dialog, Window from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.text import Format from aiogram_dialog.widgets.kbd import Button, Start
from aiogram_dialog.widgets.text import Const, Format
from app.bot.dialogs.flows.common.profile.dialogs import ProfileSG
from app.bot.dialogs.widgets.getters import username_getter from app.bot.dialogs.widgets.getters import username_getter
from .states import AdminStartSG from .states import AdminStartSG
admin_start_dialog = Dialog( admin_start_dialog = Dialog(
Window( Window(
Format("Hello, {username}"), Format("Привет, {username}"),
Button(Const("события"), id="events"),
Button(Const("создать событие"), when="is_admin"),
Start(Const("профиль"), id="profile", state=ProfileSG.profile),
getter=username_getter, getter=username_getter,
state=AdminStartSG.start, state=AdminStartSG.start,
) )

View File

@@ -0,0 +1,7 @@
from aiogram import Router
from .profile.dialogs import user_profile_dialog
common_router = Router(name="common dialogs")
common_router.include_router(user_profile_dialog)

View File

@@ -1,9 +1,9 @@
from aiogram_dialog import Dialog, Window from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.input import TextInput from aiogram_dialog.widgets.input import TextInput
from aiogram_dialog.widgets.kbd import Back, Cancel, SwitchTo from aiogram_dialog.widgets.kbd import Cancel, SwitchTo
from aiogram_dialog.widgets.text import Const, Format from aiogram_dialog.widgets.text import Const, Format
from .states import UserProfileSG from .states import ProfileSG
user_profile_dialog = Dialog( user_profile_dialog = Dialog(
Window( Window(
@@ -13,26 +13,26 @@ user_profile_dialog = Dialog(
SwitchTo( SwitchTo(
Const("изменить имя"), Const("изменить имя"),
id="change_name", id="change_name",
state=UserProfileSG.change_name, state=ProfileSG.change_name,
), ),
SwitchTo( SwitchTo(
Const("изменить телефон"), Const("изменить телефон"),
id="change_phone", id="change_phone",
state=UserProfileSG.change_phone, state=ProfileSG.change_phone,
), ),
Cancel(Const("назад")), Cancel(Const("назад")),
state=UserProfileSG.profile, state=ProfileSG.profile,
), ),
Window( Window(
Const("Введите имя"), Const("Введите имя"),
SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile), SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
TextInput(id="name_input"), TextInput(id="name_input"),
state=UserProfileSG.change_name, state=ProfileSG.change_name,
), ),
Window( Window(
Const("Введите телефон"), Const("Введите телефон"),
SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile), SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
TextInput(id="phone_input"), TextInput(id="phone_input"),
state=UserProfileSG.change_phone, state=ProfileSG.change_phone,
), ),
) )

View File

@@ -1,7 +1,7 @@
from aiogram.fsm.state import State, StatesGroup from aiogram.fsm.state import State, StatesGroup
class UserProfileSG(StatesGroup): class ProfileSG(StatesGroup):
profile = State() profile = State()
change_name = State() change_name = State()
input_name = State() input_name = State()

View File

@@ -1,8 +1,6 @@
from aiogram import Router from aiogram import Router
from .profile.dialogs import user_profile_dialog
from .start.dialogs import user_start_dialog from .start.dialogs import user_start_dialog
user_router = Router(name="user dialogs") user_router = Router(name="user dialogs")
user_router.include_router(user_start_dialog) user_router.include_router(user_start_dialog)
user_router.include_router(user_profile_dialog)

View File

@@ -2,16 +2,16 @@ from aiogram_dialog import Dialog, Window
from aiogram_dialog.widgets.kbd import Button, Start from aiogram_dialog.widgets.kbd import Button, Start
from aiogram_dialog.widgets.text import Const, Format from aiogram_dialog.widgets.text import Const, Format
from app.bot.dialogs.flows.user.profile.dialogs import UserProfileSG from app.bot.dialogs.flows.common.profile.dialogs import ProfileSG
from app.bot.dialogs.widgets.getters import username_getter from app.bot.dialogs.widgets.getters import username_getter
from .states import UserStartSG from .states import UserStartSG
user_start_dialog = Dialog( user_start_dialog = Dialog(
Window( Window(
Format("Hello, {username}"), Format("Привет, {username}"),
Button(Const("События"), id="events"), Button(Const("события"), id="events"),
Start(Const("Профиль"), id="profile", state=UserProfileSG.profile), Start(Const("профиль"), id="profile", state=ProfileSG.profile),
getter=username_getter, getter=username_getter,
state=UserStartSG.start, state=UserStartSG.start,
) )