A
A
alwaystried2022-04-05 16:41:00
Python
alwaystried, 2022-04-05 16:41:00

How to make back button from callback handler in message?

Good afternoon. There was a trick - I can not return from the callback to the message handler.

The code:

@dp.message_handler(Command('start'))
async def start(message: types.Message, state: FSMContext):
    global teled
    teled = message.from_user.id

    if message.from_user.id in a1_access or a2_access:
        print(teled)
        keyboard = InlineKeyboardMarkup(row_width=2).add(
            InlineKeyboardButton(text="Добавить билет", callback_data="info"),
            InlineKeyboardButton(text="Проверить пин-код", callback_data="filter")
        )
        await message.answer(start_text, reply_markup=keyboard)
    else:
        await message.answer(stop_text)

@dp.callback_query_handler(text="info")
async def manual(query: CallbackQuery, state: FSMContext):
    keyboard = InlineKeyboardMarkup(row_width=2).add(
        InlineKeyboardButton(text="Назад", callback_data="start"),
        InlineKeyboardButton(text="Продолжить", callback_data="name")
    )
    await query.message.edit_text("Данная функция позволяет пользователям с уровнем доступа А2 вручную прописывать билеты", reply_markup=keyboard)


Is there any way to implement this button?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
astarooss, 2022-04-05
@astarooss

@dp.callback_query_handler(text="start")
Can be added above the first function, but I don't know how to pass the state

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question