'How to make Autosending Telegram bot aiogram

How to make automatic sending of messages in the telegram bot daily at a certain time (10:00), as well as weekly on Sundays at 20:00

Aiogram

I tried to implement it through the schedule module, but it gives an error when sending a message



Solution 1:[1]

import asyncio
import aioschedule

async def noon_print():
    print("It's noon!")

async def scheduler():
    aioschedule.every().day.at("12:00").do(noon_print)
    while True:
        await aioschedule.run_pending()
        await asyncio.sleep(1)

async def on_startup(_):
    asyncio.create_task(scheduler())

if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=False, on_startup=on_startup)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PM 77-1