From 455f202364036be03b104955cde479282e991f31 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 22 Sep 2024 15:47:28 +0100 Subject: [PATCH 1/2] Add placeholder code for getting previous runs --- matchy/cogs/matcher.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index aa911c4..4a4e15d 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -210,15 +210,23 @@ class MatcherCog(commands.Cog): async def run_hourly_tasks(self): """Run any hourly tasks we have""" + # Send a reminder for anything that will be active in 1 day + for (channel, _) in state.State.get_active_match_tasks(datetime.now() + timedelta(days=1)): + logger.info("Reminding about scheduled task in %s", channel) + msg_channel = self.bot.get_channel(int(channel)) + await msg_channel.send(strings.reminder()) + + # Match groups for anything active right now for (channel, min) in state.State.get_active_match_tasks(): logger.info("Scheduled match task triggered in %s", channel) msg_channel = self.bot.get_channel(int(channel)) await match_groups_in_channel(msg_channel, min) - for (channel, _) in state.State.get_active_match_tasks(datetime.now() + timedelta(days=1)): - logger.info("Reminding about scheduled task in %s", channel) + # Send a reminder to threads for a match that happened two days ago + for (channel, min) in state.State.get_active_match_tasks(datetime.now() - timedelta(days=2)): + logger.info("Sending reminders to threads in %s", channel) msg_channel = self.bot.get_channel(int(channel)) - await msg_channel.send(strings.reminder()) + # TODO: Send a reminder per thread # Increment when adjusting the custom_id so we don't confuse old users -- 2.43.0 From f7898892e6f59a183465db41956948333923119d Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sun, 22 Sep 2024 16:30:49 +0100 Subject: [PATCH 2/2] Send a reminder to innactive threads This sends a reminder message to any thread with 1 or less messages This picks up only active threads too --- matchy/cogs/matcher.py | 9 +++++++-- matchy/cogs/strings.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index 4a4e15d..f62ee6a 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -223,10 +223,15 @@ class MatcherCog(commands.Cog): await match_groups_in_channel(msg_channel, min) # Send a reminder to threads for a match that happened two days ago - for (channel, min) in state.State.get_active_match_tasks(datetime.now() - timedelta(days=2)): + for (channel, _) in state.State.get_active_match_tasks(datetime.now() - timedelta(days=2)): logger.info("Sending reminders to threads in %s", channel) msg_channel = self.bot.get_channel(int(channel)) - # TODO: Send a reminder per thread + # Find any threads that need + for thread in msg_channel.threads: + # Only regard threads the bot created + # And that have no additional messages + if thread.owner.id == self.bot.user.id and thread.message_count <= 1: + await thread.send(strings.thread_reminder()) # Increment when adjusting the custom_id so we don't confuse old users diff --git a/matchy/cogs/strings.py b/matchy/cogs/strings.py index a617194..c31ae06 100644 --- a/matchy/cogs/strings.py +++ b/matchy/cogs/strings.py @@ -145,6 +145,16 @@ Make sure you're /pause'd if you need to be, or /join in ASAP!""", ] +@randomised +def thread_reminder(): return [ + "Hey friends, just checking in! No worries if you're too busy this week", + "Bork bork, quick reminder in case y'all forgot!", + "Hey matchees, how's your week going?", + "Hey everyone, don't forget to check in with eachother!", + "Quick friendly nudge, how're you all doing?", +] + + @randomised def matching(): return [ "Matchy is matching matchees...", -- 2.43.0