Совместить работу aiogram и schedule?

from aiogram import Bot, Dispatcher
from aiogram.types import *
from aiogram.utils import executor
import asyncio
import schedule


bot = Bot('')
dp = Dispatcher(bot)



@dp.message_handler(commands=['start'])
async def start(message : Message):
  
    await bot.send_photo(message.chat.id, open('static/img/qq.jpg', 'rb'))


async def doSomeThing():
    await bot.send_message(chat_id, message)

async def polling():
    await executor.start_polling(dp, skip_updates=True, loop=True)


async def do_schedule():
    schedule.every(10).seconds.do(doSomeThing)

    while True:
        schedule.run_pending()
        time.sleep(1)


loop  = asyncio.get_event_loop()
tasks = [
    asyncio.ensure_future(polling()),
    asyncio.ensure_future(do_schedule())
]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()

Ответы (0 шт):