D
D
demegorych2022-04-05 11:53:22
Python
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:
624c0283a6f73138615216.png
624c02c4e9d4a650852050.png

How I tried to implement it:

class Mydialog(StatesGroup):
    answer = State()


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


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


@dp.message_handler(state=Mydialog.answer)
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']
        print(data['text'])
        await message.edit_text(
            f"Ссылка на пост - {user_links[message.from_user.id]}\nКоличество просмотров - {user_local[message.from_user.id]}",
            reply_markup=get_keyboard())

    await state.finish()

Answer the question

In order to leave comments, you need to log in

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

https://surik00.gitbooks.io/aiogram-lessons/conten...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question