Expanded on daily tasks

This commit is contained in:
phixxy 2023-07-10 11:23:05 -07:00
parent 86aaee85e2
commit 8a467c6152

View file

@ -305,17 +305,27 @@ async def task_loop():
current_time = time.localtime() current_time = time.localtime()
bot_stuff = bot.get_channel(544408659174883328) bot_stuff = bot.get_channel(544408659174883328)
last_daily_run = 0 last_daily_run = 0
#Run daily task
if current_time.tm_hour == 17 and current_time.tm_min == 0 and last_daily_run != current_time.tim_yday: if current_time.tm_hour == 17 and current_time.tm_min == 0 and last_daily_run != current_time.tim_yday:
output = "<@242018983241318410> The current time is 5pm. Running daily tasks!" failed_tasks = []
last_daily_run = current_time.tm_yday #Don't accidently run the task twice in a day. last_daily_run = current_time.tm_yday #Don't accidently run the task twice in a day.
await bot_stuff.send(output) await bot_stuff.send("<@242018983241318410> The current time is 5pm. Running daily tasks!")
await bot_stuff.send("<@142420997360975872> I love you!") await bot_stuff.send("<@142420997360975872> I love you!")
try: try:
await blog(bot_stuff) await blog(bot_stuff)
except Exception as error: except Exception as error:
output = "blogpost task failed somehow: " + str(error) failed_tasks.append("Blogpost failed!")
await bot_stuff.send(output) await bot_stuff.send(output)
await bot_stuff.send("All daily tasks ran!") try:
await delete_all_files("tmp/")
except Exception as error:
failed_tasks.append("Delete tmp/ failed!")
if failed_tasks != []:
for failed_task in failed_tasks:
bot_stuff.send(failed_task)
else:
await bot_stuff.send("All daily tasks successfully ran!")