A
A
Alikhan2021-12-14 08:39:59
Python
Alikhan, 2021-12-14 08:39:59

How to do checks in Aiogram bot?

We need to add checks to the aiogram bot, which would be done always, and not just when receiving messages.
Let's send a message at a certain time. Well, you probably understand such global checks.
PS Sorry for the very badly worded question

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-12-14
Mulaev @AlikhanPython

Through loop.create_task() you create a long-lived coroutine that spins in the view loop

async def my_long_task():
  while True:
    await do_stuff() # выполняешь нужные действия, например, проверяешь очередь сообщений для отправки
    await asyncio.sleep(60) # спишь минуту

Details, such as the specific actions to perform, the conditions for performing them, the duration of sleep, or the condition for terminating the loop, depend on your task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question