2025-03-29 01:13:50 +03:00
|
|
|
import aiogram
|
|
|
|
|
|
|
|
from aiogram import Bot
|
|
|
|
from aiogram.fsm.context import FSMContext
|
|
|
|
from aiogram.filters import Command
|
|
|
|
|
2025-03-29 01:46:56 +03:00
|
|
|
from data.keyboards.inline import ibmain
|
|
|
|
from data import factory, states
|
2025-03-29 01:13:50 +03:00
|
|
|
from loader import custom_logger
|
|
|
|
|
|
|
|
|
|
|
|
async def mainstart(
|
|
|
|
message: aiogram.types.Message,
|
|
|
|
state: FSMContext,
|
|
|
|
command: Command,
|
|
|
|
bot: Bot,
|
|
|
|
):
|
|
|
|
await state.clear()
|
|
|
|
custom_logger.debug("Hello!")
|
2025-03-29 01:46:56 +03:00
|
|
|
return await message.answer(text="hello!", reply_markup=ibmain.example_callback())
|
|
|
|
|
|
|
|
|
|
|
|
async def example_callback(
|
|
|
|
message: aiogram.types.CallbackQuery,
|
|
|
|
state: FSMContext,
|
|
|
|
bot: Bot,
|
|
|
|
):
|
|
|
|
await state.clear()
|
|
|
|
return await message.answer(text="hello callback!")
|
|
|
|
|
|
|
|
|
|
|
|
async def example_callback_factory(
|
|
|
|
message: aiogram.types.CallbackQuery,
|
|
|
|
state: FSMContext,
|
|
|
|
bot: Bot,
|
|
|
|
callback_data: factory.ExampleFactory = None,
|
|
|
|
):
|
|
|
|
await state.clear()
|
|
|
|
await state.set_state(states.ExampleState.input_user)
|
2025-03-29 17:10:57 +03:00
|
|
|
await message.answer()
|
2025-03-29 01:46:56 +03:00
|
|
|
return await bot.send_message(
|
|
|
|
chat_id=message.message.chat.id,
|
|
|
|
text=f'CallbackData: {callback_data.example} | Set state, wait input...'
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def example_state(
|
|
|
|
message: aiogram.types.Message,
|
|
|
|
state: FSMContext,
|
|
|
|
bot: Bot,
|
|
|
|
):
|
|
|
|
await state.clear()
|
|
|
|
return await message.answer(
|
2025-03-29 17:10:57 +03:00
|
|
|
text=f"hello! Your text: \n\n{message.text}\n\nState Off!"
|
2025-03-29 01:46:56 +03:00
|
|
|
)
|