Why is nothing happening at the specified time using the apscheduler module?

46 Views Asked by At

Good afternoon, I am using the apscheduler module to send out messages at a certain time

from aiogram import Bot, Dispatcher, executor
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from datetime import datetime

from config import TELEGRAM_BOT_TOKEN
from config import CHANNEL_ID

bot = Bot(TELEGRAM_BOT_TOKEN)
dp = Dispatcher(bot)

from handlers.base_com_hand import *

async def sending_messages():
    all_users = getAllUsersForSend()
    print(1)
    for user in all_users:
        await bot.send_message(chat_id=user["tg_id"], text='est')

scheduler = AsyncIOScheduler(timezone='Etc/GMT+3')

scheduler.add_job(sending_messages, 'cron', day_of_week='mon-wed', hour=16, minute=16, end_date='2025-10-13')

async def on_startup(_):
    print('Bot started')

scheduler.start()

if __name__ == "__main__":
    executor.start_polling(dispatcher=dp, skip_updates=True, on_startup=on_startup)

But when the specified time comes, nothing happens. Nothing at all, no error at all, including

0

There are 0 best solutions below