Compare commits

..

No commits in common. "0a48fba5c02ed835801eb45814554571f5e3a7ed" and "2697fd9b9e600775952a9214d58792f22ee22ee2" have entirely different histories.

3 changed files with 12 additions and 8 deletions

View File

@ -4,3 +4,4 @@ from dataclasses import dataclass
@dataclass
class CExample:
example: str = "ExampleCallback"
state: bool = True

View File

@ -11,17 +11,18 @@ from data import callbacks, factory
def example_callback() -> InlineKeyboardMarkup:
"""Выберите нужный тип"""
inline_builder = InlineKeyboardBuilder()
list_build: tuple[InlineKeyboardButton] = (
inline_builder.row(
InlineKeyboardButton(
text="📠 Callback",
callback_data=callbacks.CExample.example,
),
InlineKeyboardButton(
text="📠 Callback Factory | State",
text="📠 Callback Factory",
callback_data=factory.ExampleFactory(example='Example 2').pack(),
),
InlineKeyboardButton(
text="📠 State",
callback_data=callbacks.CExample.state,
),
)
for i in list_build:
inline_builder.row(i)
return inline_builder.as_markup(resize_keyboard=True)

View File

@ -23,6 +23,7 @@ async def mainstart(
async def example_callback(
message: aiogram.types.CallbackQuery,
state: FSMContext,
command: Command,
bot: Bot,
):
await state.clear()
@ -32,12 +33,12 @@ async def example_callback(
async def example_callback_factory(
message: aiogram.types.CallbackQuery,
state: FSMContext,
command: Command,
bot: Bot,
callback_data: factory.ExampleFactory = None,
):
await state.clear()
await state.set_state(states.ExampleState.input_user)
await message.answer()
return await bot.send_message(
chat_id=message.message.chat.id,
text=f'CallbackData: {callback_data.example} | Set state, wait input...'
@ -47,9 +48,10 @@ async def example_callback_factory(
async def example_state(
message: aiogram.types.Message,
state: FSMContext,
command: Command,
bot: Bot,
):
await state.clear()
return await message.answer(
text=f"hello! Your text: \n\n{message.text}\n\nState Off!"
text=f"hello! Your text: \n\n{message.text}"
)