Started fixing bugs in daily task
This commit is contained in:
parent
8a467c6152
commit
86fa1cd1cc
1 changed files with 3 additions and 5 deletions
|
|
@ -300,30 +300,28 @@ async def delete_all_files(path):
|
||||||
elif os.path.isfile(path+filename):
|
elif os.path.isfile(path+filename):
|
||||||
os.remove(path+filename)
|
os.remove(path+filename)
|
||||||
|
|
||||||
@tasks.loop(seconds=30) # Run the task every 5 seconds
|
@tasks.loop(seconds=1) # Run the task every 5 seconds
|
||||||
async def task_loop():
|
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
|
#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 == 12 and current_time.tm_min == 0 and last_daily_run != current_time.tm_yday:
|
||||||
failed_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("<@242018983241318410> The current time is 5pm. Running daily tasks!")
|
await bot_stuff.send("<@242018983241318410> The current time is 5pm. Running daily tasks!")
|
||||||
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:
|
||||||
failed_tasks.append("Blogpost failed!")
|
failed_tasks.append("Blogpost failed!")
|
||||||
await bot_stuff.send(output)
|
|
||||||
try:
|
try:
|
||||||
await delete_all_files("tmp/")
|
await delete_all_files("tmp/")
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
failed_tasks.append("Delete tmp/ failed!")
|
failed_tasks.append("Delete tmp/ failed!")
|
||||||
if failed_tasks != []:
|
if failed_tasks != []:
|
||||||
for failed_task in failed_tasks:
|
for failed_task in failed_tasks:
|
||||||
bot_stuff.send(failed_task)
|
await bot_stuff.send(failed_task)
|
||||||
else:
|
else:
|
||||||
await bot_stuff.send("All daily tasks successfully ran!")
|
await bot_stuff.send("All daily tasks successfully ran!")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue