B
B
bilachayka2022-03-17 11:09:25
Python
bilachayka, 2022-03-17 11:09:25

How to send a message with a delay (after a few seconds) using aiogram?

It is necessary that the bot send a message to the user with a delay, for example, 10 seconds after pressing the button, and asynchronously, so that it would send to the user who pressed the button and not send it to the one who did not. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bilachayka, 2022-03-17
@bilachayka

@iggor-markin

@dp.callback_query_handler(lambda c: c.data == 'test')
async def callback(message: Message):
    await asyncio.sleep(10) bot.send_message(
        chat_id=message.from_user.id,
        reply_markup=test,
        text="какой то текст"

So, right? but for some reason the console gives SyntaxError: invalid syntax

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question