S
S
serhiops2022-03-02 17:42:19
Python
serhiops, 2022-03-02 17:42:19

I can't figure out what the error is: TypeError: on_startup() missing 1 required positional argument: 'message'?

I'm trying to make it so that a message is sent to the chat every day at a certain time.

async def on_startup(_):
    print('Бот в онлайне')
    asyncio.create_task(scheduler())

@dp.message_handler()
async def choose_your_dinner(message:types.Message):
    await message.answer("Доброе утро!")


async def scheduler(message:types.Message):
    aioschedule.every().day.at("09:00").do(choose_your_dinner())
    while True:
        await aioschedule.run_pending()
        await asyncio.sleep(1)

executor.start_polling(dp, skip_updates=True, on_startup=on_startup)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-03-02
@Vindicar

on_startup(_)
You say that the on_startup() function expects 1 parameter (named _).
Obviously, it is called without parameters.
Or at what point does the error occur? Are there decorators on this function?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question