# импорты
async def check_time():
utc = datetime.now(timezone.utc)
print(utc)
# код отправки
await asyncio.sleep(60)
await check_time()
loop = asyncio.get_event_loop()
# https://qna.habr.com/answer?answer_id=1656961#answers_list_answer
asyncio.ensure_future(check_time())
loop.run_forever()
import asyncio
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor
DELAY = 7200
bot = Bot(token='BOT TOKEN HERE')
dp = Dispatcher(bot)
@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message: types.Message):
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
async def update_price():
...
def repeat(coro, loop):
asyncio.ensure_future(coro(), loop=loop)
loop.call_later(DELAY, repeat, coro, loop)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.call_later(DELAY, repeat, update_price, loop)
executor.start_polling(dp, loop=loop)
asyncio.ensure_future(check_time())
пишем loop.ensure_future(check_time()) import asyncio
from datetime import datetime
async def check_time():
utc = datetime.now()
print(utc)
async def checker(timeout):
while(True):
await asyncio.sleep(timeout)
await check_time()
loop = asyncio.get_event_loop()
task = loop.create_task(checker(60))
loop.run_forever()