Example #1
0
 async def background_task_rotation_hype(self) -> None:
     rotation_hype_channel_id = configuration.get_int(
         'rotation_hype_channel_id')
     if not rotation_hype_channel_id:
         logging.warning('rotation hype channel is not configured')
         return
     channel = self.get_channel(rotation_hype_channel_id)
     if not isinstance(channel, discord.abc.Messageable):
         logging.warning('rotation hype channel is not a text channel')
         return
     while self.is_ready():
         until_rotation = rotation.next_rotation() - dtutil.now()
         last_run_time = rotation.last_run_time()
         if until_rotation < datetime.timedelta(
                 7) and last_run_time is not None:
             if dtutil.now() - last_run_time < datetime.timedelta(
                     minutes=5):
                 hype = await rotation_hype_message()
                 if hype:
                     await channel.send(hype)
             timer = 5 * 60
         else:
             timer = int(
                 (until_rotation - datetime.timedelta(7)).total_seconds())
         await asyncio.sleep(timer)
Example #2
0
async def hype(ctx: MtgContext) -> None:
    """Display the latest rotation hype message."""
    until_rotation = seasons.next_rotation() - dtutil.now()
    last_run_time = rotation.last_run_time()
    msg = None
    if until_rotation < datetime.timedelta(7) and last_run_time is not None:
        msg = await bot.rotation_hype_message()
    if msg:
        await ctx.send(msg)
    else:
        await ctx.send(f'{ctx.author.mention}: No rotation hype message.')