Skip to content

Commit

Permalink
🐛 fix scheduler bug
Browse files Browse the repository at this point in the history
  • Loading branch information
makcimerrr committed Sep 6, 2024
1 parent 3a50985 commit a316b91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions utils/scheduler.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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():
Expand Down

0 comments on commit a316b91

Please sign in to comment.