V
V
VladRF4R4R2021-12-24 14:42:17
Python
VladRF4R4R, 2021-12-24 14:42:17

How to make machine state in callback_query_handler?

Good day everyone!!!
I am writing a bot on aiogram, and I don’t know how to push the state machine into callback_query_handler
I would be grateful for help where to read

#@dp.message_handler(lambda message: message.text == "Записатися на прийом ", state=None)
async def specialist(message: types.Message, state: FSMContext):
    read = await bot_db.sql_read2()
    for ret in read:
        await FSMClient.specialist.set()
        await message.answer('Виберіть спеціаліста:', reply_markup=InlineKeyboardMarkup().add(InlineKeyboardButton(f'{ret[0]}', callback_data='spel')))

#@dp.callback_query_handler(text_contains='spel', state=FSMClient.service)
async def callback_run(callback_query: CallbackQuery, state: FSMContext):
    async with state.proxy() as data:
        data['service'] = callback_query.message.text
    await FSMClient.next()
    await callback_query.message.answer(text=f"Виберіть спеціаліста",reply_markup=keyboard_inline_buttons)

#@dp.callback_query_handler(text_contains='calendar', state=FSMClient.data)
async def callback_run(callback_query: CallbackQuery, state: FSMContext):
    async with state.proxy() as data:
        data['data'] = callback_query.message.text
    await FSMClient.next()
    await callback_query.message.answer(text=f"виберіть будь-ласка,зручну для вас дату",reply_markup=await SimpleCalendar().start_calendar())

@dp.callback_query_handler(simple_cal_callback.filter())
async def process_simple_calendar(callback_query: CallbackQuery, callback_data: dict):
    selected, date = await SimpleCalendar().process_selection(callback_query, callback_data)
    if selected:
        await callback_query.message.answer(
            f'Ви вибрали {date.strftime("%Y-/%m-%d")}',reply_markup=time)

#@dp.callback_query_handler(text_contains='time', state=FSMClient.time)
async def callback_run(callback_query: CallbackQuery, state: FSMContext):
    async with state.proxy() as data:
        data['time'] = callback_query.message.text
    await FSMClient.next()
    await callback_query.message.answer(text=f"Напишити юридичне питання")

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question