add common dialogs
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from aiogram import Router
|
||||
|
||||
from .admin import admin_router
|
||||
from .common import common_router
|
||||
from .user import user_router
|
||||
|
||||
dialogs_router = Router(name="dialogs")
|
||||
dialogs_router.include_router(admin_router)
|
||||
dialogs_router.include_router(user_router)
|
||||
dialogs_router.include_router(common_router)
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
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 .states import AdminStartSG
|
||||
|
||||
admin_start_dialog = Dialog(
|
||||
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,
|
||||
state=AdminStartSG.start,
|
||||
)
|
||||
|
||||
7
app/bot/dialogs/flows/common/__init__.py
Normal file
7
app/bot/dialogs/flows/common/__init__.py
Normal 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)
|
||||
@@ -1,9 +1,9 @@
|
||||
from aiogram_dialog import Dialog, Window
|
||||
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 .states import UserProfileSG
|
||||
from .states import ProfileSG
|
||||
|
||||
user_profile_dialog = Dialog(
|
||||
Window(
|
||||
@@ -13,26 +13,26 @@ user_profile_dialog = Dialog(
|
||||
SwitchTo(
|
||||
Const("изменить имя"),
|
||||
id="change_name",
|
||||
state=UserProfileSG.change_name,
|
||||
state=ProfileSG.change_name,
|
||||
),
|
||||
SwitchTo(
|
||||
Const("изменить телефон"),
|
||||
id="change_phone",
|
||||
state=UserProfileSG.change_phone,
|
||||
state=ProfileSG.change_phone,
|
||||
),
|
||||
Cancel(Const("назад")),
|
||||
state=UserProfileSG.profile,
|
||||
state=ProfileSG.profile,
|
||||
),
|
||||
Window(
|
||||
Const("Введите имя"),
|
||||
SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile),
|
||||
SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
|
||||
TextInput(id="name_input"),
|
||||
state=UserProfileSG.change_name,
|
||||
state=ProfileSG.change_name,
|
||||
),
|
||||
Window(
|
||||
Const("Введите телефон"),
|
||||
SwitchTo(Const("отмена"), id="go_profile", state=UserProfileSG.profile),
|
||||
SwitchTo(Const("отмена"), id="go_profile", state=ProfileSG.profile),
|
||||
TextInput(id="phone_input"),
|
||||
state=UserProfileSG.change_phone,
|
||||
state=ProfileSG.change_phone,
|
||||
),
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
from aiogram.fsm.state import State, StatesGroup
|
||||
|
||||
|
||||
class UserProfileSG(StatesGroup):
|
||||
class ProfileSG(StatesGroup):
|
||||
profile = State()
|
||||
change_name = State()
|
||||
input_name = State()
|
||||
@@ -1,8 +1,6 @@
|
||||
from aiogram import Router
|
||||
|
||||
from .profile.dialogs import user_profile_dialog
|
||||
from .start.dialogs import user_start_dialog
|
||||
|
||||
user_router = Router(name="user dialogs")
|
||||
user_router.include_router(user_start_dialog)
|
||||
user_router.include_router(user_profile_dialog)
|
||||
|
||||
@@ -2,16 +2,16 @@ from aiogram_dialog import Dialog, Window
|
||||
from aiogram_dialog.widgets.kbd import Button, Start
|
||||
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 .states import UserStartSG
|
||||
|
||||
user_start_dialog = Dialog(
|
||||
Window(
|
||||
Format("Hello, {username}"),
|
||||
Button(Const("События"), id="events"),
|
||||
Start(Const("Профиль"), id="profile", state=UserProfileSG.profile),
|
||||
Format("Привет, {username}"),
|
||||
Button(Const("события"), id="events"),
|
||||
Start(Const("профиль"), id="profile", state=ProfileSG.profile),
|
||||
getter=username_getter,
|
||||
state=UserStartSG.start,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user