V
V
VladRF4R4R2021-12-29 15:09:21
Python
VladRF4R4R, 2021-12-29 15:09:21

How to pull certain text from an inline button and pass it to the state proxy?

How to pull out a certain text from an inline button and transfer it to the state proxy, moreover, there is a text like a bot there, and not just in an inline button.

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

@dp.callback_query_handler(lambda c: c.data == 'spel', state=FSMClient.specialist)
async def handle_a(callback_query: types.CallbackQuery, state: FSMContext):
    await FSMClient.next()
    async with state.proxy() as data:
        data["specialist"] = callback_query.message.text
    await callback_query.message.answer('Виберіть послугу:', reply_markup=keyboard_inline_buttons)



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



@dp.callback_query_handler(simple_cal_callback.filter(), state=FSMClient.data)
async def process_simple_calendar(callback_query: CallbackQuery, callback_data: dict, state: FSMContext):
    selected, date = await SimpleCalendar().process_selection(callback_query, callback_data)
    if selected:
        await FSMClient.next()
        async with state.proxy() as data:
            data["data"] = callback_query.message.text
    await callback_query.message.answer(f'Ви вибрали {date.strftime("%d/%m/%Y")}', reply_markup=time)


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


FSMContextProxy state = 'FSMClient:email', data = {'specialist': 'Choose a specialist:', 'service': 'Choose a service:', 'data': 'Choose a friendly date for you', 'time ': 'You chose 29/12/2021', 'description': 'R', 'phone': '+3', 'email': 'A'}
So fsm chooses this way, and I want to choose a specialist, choose a service, Choose be-weasel, I’ll hand over the date for you, We chose 12/29/2021 that the user selected from the inline buttons.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kadabrov, 2021-12-29
@Kadabrov

data["specialist"] = callback_query.message.text
you write the text of the message, but you need to write the callback_data of the button
callback_data = callback_query.data

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question