R
R
Rend1s2021-07-29 22:59:13
Python
Rend1s, 2021-07-29 22:59:13

Turn off message handler aiogram after some time?

I have a message handler, I want it to work only on the first "hello", and no longer respond to the rest, that is, I need to turn it off after the first processing

@dp.message_handler(regexp="привет")
async def hello(message: types.Message):
    await message.answer("Привет!")

how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stefan, 2021-07-29
@MEDIOFF

Create a table in the database, where to write down that the user has already written hello, in the handler, first add a check to see if the user wrote before, if he wrote, then simplyreturn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question