demegorych2022-04-05 11:53:22
demegorych, 2022-04-05 11:53:22

Aiogram: How to read user's message after pressing inline button?

Good afternoon,
I need that after pressing a certain inline button, the bot expects a link in the next message from the user (and it is also desirable with a check for the format). After the user submits the link, the message from the bot should update to display the link the user entered, and the user's message should be deleted.

I give an example of how it is implemented in another bot:

How I tried to implement it:

class Mydialog(StatesGroup):
    answer = State()

async def get_views_link(call: types.CallbackQuery):
    with suppress(MessageNotModified):
        await call.message.edit_text(f"Введите ссылку на пост:", reply_markup=get_keyboard_accept_link_views())

async def cmd_dialog(message: types.Message):
    await Mydialog.answer.set()

async def process_message(message: types.Message, state: FSMContext):
    async with state.proxy() as data:
        data['text'] = message.text
        user_links[message.from_user.id] = data['text']
        await message.edit_text(
            f"Ссылка на пост - {user_links[message.from_user.id]}\nКоличество просмотров - {user_local[message.from_user.id]}",

    await state.finish()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Alexander, 2022-04-05


Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question