From d1c97376b7b7a6f298ddb03b21dd265cdd152f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Wed, 9 Sep 2020 10:08:06 +0200 Subject: [PATCH] Avoid scheduling reminders from reminders --- bot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 1a9c351..c3554ce 100644 --- a/bot.py +++ b/bot.py @@ -142,7 +142,8 @@ class Bot(discord.Client): except YouTubeError as e: return published = entry.get('published') - if published and not entry.get('reminder'): + reminder = entry.get('reminder') + if published and not reminder: if [v for v, p in self.yt_videos if v == video_id and p == published]: return self.yt_videos.append((video_id, published)) @@ -153,11 +154,12 @@ class Bot(discord.Client): scheduled_start = video.get('scheduled_start') if scheduled_start: remaining = (scheduled_start - datetime.datetime.now(datetime.timezone.utc)).total_seconds() - for minutes in COUNTDOWN: - if remaining > minutes * 60: - payload = data.copy() - payload['feed']['entry']['reminder'] = '{0}m'.format(minutes) - Timer.schedule(scheduled_start - datetime.timedelta(minutes=minutes), payload) + if not reminder: + for minutes in COUNTDOWN: + if remaining > minutes * 60: + payload = data.copy() + payload['feed']['entry']['reminder'] = '{0}m'.format(minutes) + Timer.schedule(scheduled_start - datetime.timedelta(minutes=minutes), payload) note = 'Live in {0} minutes!\n'.format(int(remaining / 60)) mention = channel.guild.default_role.mention await channel.send('{mention} {note}**{title}**\n{link}'.format(mention=mention, note=note, **video))