async def listjobs(self, ctx): """Lists timed robocronp jobs, staff only.""" ctab = get_crontab() embed = discord.Embed(title=f"Active robocronp jobs") for jobtype in ctab: for jobtimestamp in ctab[jobtype]: for job_name in ctab[jobtype][jobtimestamp]: job_details = repr(ctab[jobtype][jobtimestamp][job_name]) embed.add_field(name=f"{jobtype} for {job_name}", value=f"Timestamp: {jobtimestamp}, " f"Details: {job_details}", inline=False) await ctx.send(embed=embed)
async def minutely(self): await self.bot.wait_until_ready() while not self.bot.is_closed(): try: ctab = get_crontab() timestamp = time.time() for jobtype in ctab: for jobtimestamp in ctab[jobtype]: if timestamp > int(jobtimestamp): await self.do_jobs(ctab, jobtype, jobtimestamp) except: # Don't kill cronjobs if something goes wrong. pass await asyncio.sleep(60)
async def remindlist(self, ctx): """Lists your reminders.""" ctab = get_crontab() uid = str(ctx.author.id) embed = discord.Embed(title=f"Active robocronp jobs") for jobtimestamp in ctab["remind"]: if uid not in ctab["remind"][jobtimestamp]: continue job_details = ctab["remind"][jobtimestamp][uid] expiry_timestr = datetime.utcfromtimestamp(int(jobtimestamp))\ .strftime('%Y-%m-%d %H:%M:%S (UTC)') embed.add_field(name=f"Reminder for {expiry_timestr}", value=f"Added on: {job_details['added']}, " f"Text: {job_details['text']}", inline=False) await ctx.send(embed=embed)
async def minutely(self): await self.bot.wait_until_ready() log_channel = self.bot.get_channel(config.botlog_channel) while not self.bot.is_closed(): try: ctab = get_crontab() timestamp = time.time() for jobtype in ctab: for jobtimestamp in ctab[jobtype]: if timestamp > int(jobtimestamp): await self.do_jobs(ctab, jobtype, jobtimestamp) # Handle clean channels for clean_channel in config.minutely_clean_channels: await self.clean_channel(clean_channel) except: # Don't kill cronjobs if something goes wrong. await log_channel.send("Cron-minutely has errored: ```" f"{traceback.format_exc()}```") await asyncio.sleep(60)