From a316b91f33b33dd18ea2eb78cc7813bda7aaa4ef Mon Sep 17 00:00:00 2001 From: makcimerrr Date: Fri, 6 Sep 2024 11:34:06 +0200 Subject: [PATCH] :bug: fix scheduler bug --- bot.py | 2 +- utils/scheduler.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bot.py b/bot.py index 2823cc0..26aaf7a 100644 --- a/bot.py +++ b/bot.py @@ -40,7 +40,7 @@ async def on_ready(): print(f"Synced {len(synced)} command(s)") except Exception as e: print(e) - # Start the scheduler to run the send_joblist function twice a day + # Start the scheduler to run the send_joblist and send_cdilist function twice a day start_scheduler(bot) first_ready = False diff --git a/utils/scheduler.py b/utils/scheduler.py index 28423b9..6ce464f 100644 --- a/utils/scheduler.py +++ b/utils/scheduler.py @@ -1,4 +1,5 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler +from datetime import datetime from cogs.gestion_jobs import JobCog from cogs.gestion_cdi import CDICog @@ -8,29 +9,31 @@ async def joblist_morning(bot): job_cog = JobCog(bot) # Instanciez votre cog - await job_cog.send_joblist() # Appelez la méthode send_joblist - print("Updated jobs list auto 1!") + await job_cog.send_jobslist() # Appelez la méthode send_joblist + print("Updated list internship auto 1!") async def joblist_evening(bot): job_cog = JobCog(bot) # Instanciez votre cog - await job_cog.send_joblist() # Appelez la méthode send_joblist - print("Updated jobs list alternants auto 2!") + await job_cog.send_jobslist() # Appelez la méthode send_joblist + print("Updated list internship auto 2!") async def cdi_morning(bot): cdi_cog = CDICog(bot) # Instanciez votre cog await cdi_cog.send_cdilist() # Appelez la méthode send_joblist - print("Updated jobs list auto 1!") + print("Updated list full-time auto 1!") async def cdi_evening(bot): cdi_cog = CDICog(bot) # Instanciez votre cog await cdi_cog.send_cdilist() # Appelez la méthode send_joblist - print("Updated jobs list cdi auto 2!") + print("Updated list full-time auto 2!") def start_scheduler(bot): + # Print the time of the scheduler start + print(f"Scheduler started at: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") # Scheduler jobs with bot parameter @scheduler.scheduled_job("cron", hour=9, minute=0) # Run at 9 AM async def schedule_joblist_morning():