Не работает schedule в aiogram
Пытаюсь запустить код, но выдает это:
TypeError: public() missing 1 required positional argument: 'message'
Весь код:
import config
import json
from aiogram import Bot, Dispatcher, executor, types
import sqlite3 as sq
import asyncio
import aioschedule
bot = Bot(token=config.TOKEN)
dp = Dispatcher(bot)
global base, cur
base = sq.connect('ochered.db')
cur = base.cursor()
async def on_startup(_):
asyncio.create_task(scheduler())
async def scheduler():
aioschedule.every(1).minutes.do(public)
while True:
await aioschedule.run_pending()
await asyncio.sleep(1)
@dp.message_handler(content_types=['photo', 'video'])
async def dobavlenie(message: types.Message):
base.execute('CREATE TABLE IF NOT EXISTS ochered(id, type)')
if message.photo:
params = ( message.photo[0].file_id, 'photo')
elif message.video:
params = ( message.video.file_id, 'video')
cur.execute('INSERT INTO ochered VALUES (?, ?)', params)
base.commit()
@dp.message_handler()
async def public(message: types.Message):
try:
post = cur.execute("""SELECT id FROM ochered""")
lol = post.fetchall()[0][0]
await bot.send_photo( chat_id = config.chat_id, photo = lol)
cur.execute('DELETE FROM ochered WHERE id IN (SELECT id FROM ochered LIMIT 1)')
base.commit()
except:
print('БД пустая')
executor.start_polling(dp, skip_updates=True, on_startup=on_startup)