From 125105469a79a889dcc0f8a94f26d2e225fdac61 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 17 Aug 2024 21:57:27 +0100 Subject: [PATCH 1/6] Pull out all strings the bot says to a class Also implement a randomised wrapper --- matchy/cogs/matcher.py | 74 ++++++++++++++++++++++--------------- matchy/cogs/owner.py | 2 +- matchy/cogs/strings.py | 83 ++++++++++++++++++++++++++++++++++++++++++ matchy/matching.py | 23 ------------ matchy/util.py | 9 +++++ tests/util_test.py | 12 ++++++ 6 files changed, 150 insertions(+), 53 deletions(-) create mode 100644 matchy/cogs/strings.py diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index dd6a91a..a10dc00 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -12,6 +12,7 @@ import matchy.matching as matching from matchy.state import State, AuthScope import matchy.util as util import matchy.state as state +import matchy.cogs.strings as strings logger = logging.getLogger("cog") @@ -41,8 +42,8 @@ class MatcherCog(commands.Cog): self.state.set_user_active_in_channel( interaction.user.id, interaction.channel.id) await interaction.response.send_message( - f"Roger roger {interaction.user.mention}!\n" - + f"Added you to {interaction.channel.mention}!", + strings.acknowledgement(interaction.user.mention) + "\n" + + strings.user_added(interaction.channel.mention), ephemeral=True, silent=True) @app_commands.command(description="Leave the matchees for this channel") @@ -54,7 +55,7 @@ class MatcherCog(commands.Cog): self.state.set_user_active_in_channel( interaction.user.id, interaction.channel.id, False) await interaction.response.send_message( - f"No worries {interaction.user.mention}. Come back soon :)", ephemeral=True, silent=True) + strings.user_leave(interaction.user.mention), ephemeral=True, silent=True) @app_commands.command(description="Pause your matching in this channel for a number of days") @commands.guild_only() @@ -69,8 +70,8 @@ class MatcherCog(commands.Cog): self.state.set_user_paused_in_channel( interaction.user.id, interaction.channel.id, until) await interaction.response.send_message( - f"Sure thing {interaction.user.mention}!\n" - + f"Paused you until {util.datetime_as_discord_time(until)}!", + strings.acknowledgement(interaction.user.mention) + "\n" + + strings.paused(until), ephemeral=True, silent=True) @app_commands.command(description="List the matchees for this channel") @@ -86,23 +87,19 @@ class MatcherCog(commands.Cog): if matchees: mentions = [m.mention for m in matchees] - msg += f"There are {len(matchees)} active matchees:\n" - msg += f"{util.format_list(mentions)}\n" + msg += strings.active_matchees(mentions) + "\n" if paused: mentions = [m.mention for m in paused] - msg += f"\nThere are {len(mentions)} paused matchees:\n" - msg += f"{util.format_list([m.mention for m in paused])}\n" + msg += "\n" + strings.paused_matchees(mentions) + "\n" tasks = self.state.get_channel_match_tasks(interaction.channel.id) for (day, hour, min) in tasks: next_run = util.get_next_datetime(day, hour) - date_str = util.datetime_as_discord_time(next_run) - msg += f"\nA match is scheduled at {date_str}" - msg += f" with {min} members per group\n" + msg += "\n" + strings.scheduled(next_run, min) + "\n" if not msg: - msg = "There are no matchees in this channel and no scheduled matches :(" + msg = strings.no_scheduled() await interaction.response.send_message(msg, ephemeral=True, silent=True) @@ -129,7 +126,7 @@ class MatcherCog(commands.Cog): # Bail if not a matcher if not self.state.get_user_has_scope(interaction.user.id, AuthScope.MATCHER): - await interaction.response.send_message("You'll need the 'matcher' scope to schedule a match", + await interaction.response.send_message(strings.need_matcher_scope(), ephemeral=True, silent=True) return @@ -141,10 +138,9 @@ class MatcherCog(commands.Cog): logger.info("Scheduled new match task in %s with min %s weekday %s hour %s", channel_id, members_min, weekday, hour) next_run = util.get_next_datetime(weekday, hour) - date_str = util.datetime_as_discord_time(next_run) await interaction.response.send_message( - f"Done :) Next run will be at {date_str}", + strings.scheduled_success(next_run), ephemeral=True, silent=True) @app_commands.command(description="Cancel all scheduled matches in this channel") @@ -153,7 +149,7 @@ class MatcherCog(commands.Cog): """Cancel scheduled matches in this channel""" # Bail if not a matcher if not self.state.get_user_has_scope(interaction.user.id, AuthScope.MATCHER): - await interaction.response.send_message("You'll need the 'matcher' scope to remove scheduled matches", + await interaction.response.send_message(strings.need_matcher_scope(), ephemeral=True, silent=True) return @@ -162,8 +158,7 @@ class MatcherCog(commands.Cog): self.state.remove_channel_match_tasks(channel_id) await interaction.response.send_message( - "Done, all scheduled matches cleared in this channel!", - ephemeral=True, silent=True) + strings.cancelled(), ephemeral=True, silent=True) @app_commands.command(description="Match up matchees") @commands.guild_only() @@ -185,24 +180,23 @@ class MatcherCog(commands.Cog): # Let the user know when there's nobody to match if not groups: - await interaction.response.send_message("Nobody to match up :(", ephemeral=True, silent=True) + await interaction.response.send_message(strings.nobody_to_match(), ephemeral=True, silent=True) return # Post about all the groups with a button to send to the channel groups_list = '\n'.join( ", ".join([m.mention for m in g]) for g in groups) - msg = f"Roger! I've generated example groups for ya:\n\n{groups_list}" + msg = strings.generated_groups(groups_list) view = discord.utils.MISSING if self.state.get_user_has_scope(interaction.user.id, AuthScope.MATCHER): # Otherwise set up the button - msg += "\n\nClick the button to match up groups and send them to the channel.\n" + msg += "\n\n" + strings.click_to_match() + "\n" view = discord.ui.View(timeout=None) view.add_item(DynamicGroupButton(members_min)) else: # Let a non-matcher know why they don't have the button - msg += f"\n\nYou'll need the {AuthScope.MATCHER}" - msg += " scope to post this to the channel, sorry!" + msg += "\n\n" + strings.need_matcher_to_post() await interaction.response.send_message(msg, ephemeral=True, silent=True, view=view) @@ -215,13 +209,12 @@ class MatcherCog(commands.Cog): for (channel, min) in self.state.get_active_match_tasks(): logger.info("Scheduled match task triggered in %s", channel) msg_channel = self.bot.get_channel(int(channel)) - await matching.match_groups_in_channel(self.state, msg_channel, min) + await match_groups_in_channel(self.state, msg_channel, min) for (channel, _) in self.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("Arf arf! just a reminder I'll be doin a matcherino in here in T-24hrs!" - + "\nUse /join if you haven't already, or /pause if you want to skip a week :)") + await msg_channel.send(strings.reminder()) # Increment when adjusting the custom_id so we don't confuse old users @@ -260,7 +253,30 @@ class DynamicGroupButton(discord.ui.DynamicItem[discord.ui.Button], intrctn.guild.name, intrctn.channel.name) # Let the user know we've recieved the message - await intrctn.response.send_message(content="Matchy is matching matchees...", ephemeral=True) + await intrctn.response.send_message(content=strings.matching(), ephemeral=True) # Perform the match - await matching.match_groups_in_channel(self.state, intrctn.channel, self.min) + await match_groups_in_channel(self.state, intrctn.channel, self.min) + + +async def match_groups_in_channel(state: State, channel: discord.channel, min: int): + """Match up the groups in a given channel""" + groups = matching.active_members_to_groups(state, channel, min) + + # Send the groups + for group in groups: + message = await channel.send( + f"Matched up {util.format_list([m.mention for m in group])}!") + # Set up a thread for this match if the bot has permissions to do so + if channel.permissions_for(channel.guild.me).create_public_threads: + await channel.create_thread( + name=util.format_list([m.display_name for m in group]), + message=message, + reason="Creating a matching thread") + + # Close off with a message + await channel.send(strings.matching_done()) + # Save the groups to the history + state.log_groups(groups) + + logger.info("Done! Matched into %s groups.", len(groups)) diff --git a/matchy/cogs/owner.py b/matchy/cogs/owner.py index 2893631..d421251 100644 --- a/matchy/cogs/owner.py +++ b/matchy/cogs/owner.py @@ -52,4 +52,4 @@ class OwnerCog(commands.Cog): logger.info("Granting user %s matcher scope", user) await ctx.reply("Done!", ephemeral=True) else: - await ctx.reply("Likely not a user...", ephemeral=True) + await ctx.reply(f"{user} is not a user?", ephemeral=True) diff --git a/matchy/cogs/strings.py b/matchy/cogs/strings.py new file mode 100644 index 0000000..7c0b72d --- /dev/null +++ b/matchy/cogs/strings.py @@ -0,0 +1,83 @@ +""" +All the possible strings for things that matchy can say +Some can be selected randomly to give the bot some flavor +""" +from matchy.util import randomised, datetime_as_discord_time, format_list +from matchy.state import AuthScope + + +# Acknowledge something +@randomised +def acknowledgement(m): return [ + f"Roger roger {m}!", + f"Sure thing {m}!" +] + + +def user_added(c): + return f"Added you to {c}!" + + +def user_leave(m): + return f"No worries {m}. Come back soon :)" + + +def paused(t): + return f"Paused you until {datetime_as_discord_time(t)}!" + + +def active_matchees(ms): + return f"There are {len(ms)} active matchees:\n{format_list(ms)}" + + +def paused_matchees(ms): + return f"There are {len(ms)} paused matchees:\n{format_list(ms)}" + + +def scheduled(next, n): + return f"A match is scheduled at {datetime_as_discord_time(next)} with {n} members per group\n" + + +def no_scheduled(): + return "There are no matchees in this channel and no scheduled matches :(" + + +def need_matcher_scope(): + return "You'll need the 'matcher' scope to do this" + + +def scheduled_success(d): + return f"Done :) Next run will be at {datetime_as_discord_time(d)}" + + +def cancelled(): + return "Done, all scheduled matches cleared in this channel!" + + +def nobody_to_match(): + return "Nobody to match up :(" + + +def generated_groups(g): + return "Roger! I've generated example groups for ya:\n\n{g}" + + +def click_to_match(): + return "Click the button to match up groups and send them to the channel." + + +def need_matcher_to_post(): + return f"You'll need the {AuthScope.MATCHER} scope to post this to the channel, sorry!" + + +def reminder(): + return """Arf arf! just a reminder I'll be doin a matcherino in here in T-24hrs! +Use /join if you haven't already, or /pause if you want to skip a week :)""" + + +def matching(): + return "Matchy is matching matchees..." + + +def matching_done(): + return "That's all folks, happy matching and remember - DFTBA!" diff --git a/matchy/matching.py b/matchy/matching.py index 5c2403b..25292d4 100644 --- a/matchy/matching.py +++ b/matchy/matching.py @@ -179,29 +179,6 @@ def members_to_groups(matchees: list[Member], assert False -async def match_groups_in_channel(state: State, channel: discord.channel, min: int): - """Match up the groups in a given channel""" - groups = active_members_to_groups(state, channel, min) - - # Send the groups - for group in groups: - message = await channel.send( - f"Matched up {util.format_list([m.mention for m in group])}!") - # Set up a thread for this match if the bot has permissions to do so - if channel.permissions_for(channel.guild.me).create_public_threads: - await channel.create_thread( - name=util.format_list([m.display_name for m in group]), - message=message, - reason="Creating a matching thread") - - # Close off with a message - await channel.send("That's all folks, happy matching and remember - DFTBA!") - # Save the groups to the history - state.log_groups(groups) - - logger.info("Done! Matched into %s groups.", len(groups)) - - def get_matchees_in_channel(state: State, channel: discord.channel): """Fetches the matchees in a channel""" # Reactivate any unpaused users diff --git a/matchy/util.py b/matchy/util.py index 1f484dc..95274e3 100644 --- a/matchy/util.py +++ b/matchy/util.py @@ -1,5 +1,6 @@ from datetime import datetime, timedelta from functools import reduce +import random def get_day_with_suffix(day): @@ -59,3 +60,11 @@ def set_nested_value(d, *keys, value=None): d[leaf] = value elif leaf in d: del d[leaf] + + +def randomised(func): + "Randomise which in a list we actually return" + def wrapper(*args, **kwargs): + vals = func(*args, **kwargs) + return random.choice(vals) if isinstance(vals, list) else vals + return wrapper diff --git a/tests/util_test.py b/tests/util_test.py index 7b9db78..9bda465 100644 --- a/tests/util_test.py +++ b/tests/util_test.py @@ -38,3 +38,15 @@ def test_set_nested_dict_value(): } util.set_nested_value(d, "x", "y", "z", "val", value=52) assert 52 == util.get_nested_value(d, "x", "y", "z", "val") + + +def test_randomized(): + + def string(): + return "foo" + + def list(): + return ["foo", "bar"] + + assert util.randomised(string)() == "foo" + assert util.randomised(list)() in list() From 251befb1a58efe6457c9bdfdef156ae8a9c3ff27 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 17 Aug 2024 22:33:04 +0100 Subject: [PATCH 2/6] Implement a ton of string variants --- matchy/cogs/matcher.py | 6 +- matchy/cogs/strings.py | 169 ++++++++++++++++++++++++++++++++--------- 2 files changed, 136 insertions(+), 39 deletions(-) diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index a10dc00..4252f0a 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -96,7 +96,7 @@ class MatcherCog(commands.Cog): tasks = self.state.get_channel_match_tasks(interaction.channel.id) for (day, hour, min) in tasks: next_run = util.get_next_datetime(day, hour) - msg += "\n" + strings.scheduled(next_run, min) + "\n" + msg += "\n" + strings.scheduled(next_run, min) if not msg: msg = strings.no_scheduled() @@ -266,11 +266,11 @@ async def match_groups_in_channel(state: State, channel: discord.channel, min: i # Send the groups for group in groups: message = await channel.send( - f"Matched up {util.format_list([m.mention for m in group])}!") + strings.matched_up([m.mention for m in group])) # Set up a thread for this match if the bot has permissions to do so if channel.permissions_for(channel.guild.me).create_public_threads: await channel.create_thread( - name=util.format_list([m.display_name for m in group]), + name=strings.thread_title([m.display_name for m in group]), message=message, reason="Creating a matching thread") diff --git a/matchy/cogs/strings.py b/matchy/cogs/strings.py index 7c0b72d..bbf22e6 100644 --- a/matchy/cogs/strings.py +++ b/matchy/cogs/strings.py @@ -10,74 +10,171 @@ from matchy.state import AuthScope @randomised def acknowledgement(m): return [ f"Roger roger {m}!", - f"Sure thing {m}!" + f"Sure thing {m}!", + f"o7 {m}!", + f"Yessir {m}!", + f"Bork {m}!", ] -def user_added(c): - return f"Added you to {c}!" +@randomised +def user_added(c): return [ + f"Added you to {c}!", + f"You've joined the matchee list on {c}!", + f"Awesome, great to have you on board in {c}!", + f"Bark bork bork arf {c} bork!", +] -def user_leave(m): - return f"No worries {m}. Come back soon :)" +@randomised +def user_leave(m): return [ + f"No worries {m}. Come back soon :)", + f"That's cool {m}. Home you'll be back some day", + f"Cool cool {m}. Be well!", + f"Byeeee {m}!", +] -def paused(t): - return f"Paused you until {datetime_as_discord_time(t)}!" +@randomised +def paused(t): return [ + f"Paused you until {datetime_as_discord_time(t)}!", + f"You've been paused until {datetime_as_discord_time(t)}! Bork!", + f"Okie dokie you'll be unpaused at {datetime_as_discord_time(t)}!", + f"Bork bork bork arf {datetime_as_discord_time(t)}! Arf bork arf arf.", +] -def active_matchees(ms): - return f"There are {len(ms)} active matchees:\n{format_list(ms)}" +@randomised +def active_matchees(ms): return [ + f"There are {len(ms)} active matchees:\n{format_list(ms)}", + f"We've got {len(ms)} matchees here!\n{format_list(ms)}", +] -def paused_matchees(ms): - return f"There are {len(ms)} paused matchees:\n{format_list(ms)}" +@randomised +def paused_matchees(ms): return [ + f"There are {len(ms)} paused matchees:\n{format_list(ms)}", + f"Only {len(ms)} matchees are paused:\n{format_list(ms)}", +] -def scheduled(next, n): - return f"A match is scheduled at {datetime_as_discord_time(next)} with {n} members per group\n" +@randomised +def scheduled(next, n): return [ + f"""A match is scheduled at {datetime_as_discord_time(next)} \ +with {n} members per group""", + f"""There'll be a match at {datetime_as_discord_time(next)} \ +with min {n} per group""", + f"""At {datetime_as_discord_time(next)} I'll match \ +groups of minimum {n}""", +] -def no_scheduled(): - return "There are no matchees in this channel and no scheduled matches :(" +@randomised +def no_scheduled(): return [ + "There are no matchees in this channel and no scheduled matches :(", + "This channel's got nothing, bork!", + "Arf bork no matchees or schedules here bark bork", +] -def need_matcher_scope(): - return "You'll need the 'matcher' scope to do this" +@randomised +def need_matcher_scope(): return [ + f"You'll need the '{AuthScope.MATCHER}' scope to do this", + f"Only folks with the '{AuthScope.MATCHER}' scope can do this", +] -def scheduled_success(d): - return f"Done :) Next run will be at {datetime_as_discord_time(d)}" +@randomised +def scheduled_success(d): return [ + f"Done :) Next run will be at {datetime_as_discord_time(d)}", + f"Woohoo! Scheduled for {datetime_as_discord_time(d)}", + f"Yessir, will do a matcho at {datetime_as_discord_time(d)}", + f"Arf Arf! Bork bork bark {datetime_as_discord_time(d)}", +] -def cancelled(): - return "Done, all scheduled matches cleared in this channel!" +@randomised +def cancelled(): return [ + "Done, all scheduled matches cleared in this channel!", + "See ya later schedulaters", + "Okie dokey, schedule cleared", +] -def nobody_to_match(): - return "Nobody to match up :(" +@randomised +def nobody_to_match(): return [ + "Nobody to match up :(", + "Arf orf... no matchees found...", + "Couldn't find any matchees in this channel, sorry!", +] -def generated_groups(g): - return "Roger! I've generated example groups for ya:\n\n{g}" +@randomised +def generated_groups(g): return [ + f"Roger! I've generated example groups for ya:\n\n{g}", + f"Sure thing! Some example groups:\n\n{g}", + f"Yessir! The groups might look like:\n\n{g}", +] -def click_to_match(): - return "Click the button to match up groups and send them to the channel." +@randomised +def click_to_match(): return [ + "Click the button to match up groups and send them to the channel.", + "Bonk the button to do a match.", + "Arf borf bork button bark press bork", +] -def need_matcher_to_post(): - return f"You'll need the {AuthScope.MATCHER} scope to post this to the channel, sorry!" +@randomised +def need_matcher_to_post(): return [ + f"""You'll need the '{AuthScope.MATCHER}' \ +scope to post this to the channel, sorry!""", + f"""You can't send this to the channel without \ +the '{AuthScope.MATCHER}' scope.""", +] -def reminder(): - return """Arf arf! just a reminder I'll be doin a matcherino in here in T-24hrs! -Use /join if you haven't already, or /pause if you want to skip a week :)""" +@randomised +def reminder(): return [ + """Arf arf! just a reminder I'll be doin a matcherino in here in T-24hrs! +Use /join if you haven't already, or /pause if you want to skip a week :)""", + """Bork! In T-24hrs there'll be a matchy match in this channel +Use /join to get in on the fun, or /pause need to take a break!""", + """Woof! Your friendly neighbourhood matchy reminder here for tomorrow! +Make sure you're /pause'd if you need to be, or /join in ASAP!""", +] -def matching(): - return "Matchy is matching matchees..." +@randomised +def matching(): return [ + "Matchy is matching matchees...", + "Matchy is matching matchees!", + "Matchy is doin a match!", + "Matchy Match!", +] -def matching_done(): - return "That's all folks, happy matching and remember - DFTBA!" +@randomised +def matching_done(): return [ + "That's all folks, happy matching and remember - DFTBA!", + "Aaand that's it, enjoy and vibe, you've earned it!", + "Until next time frendos.", +] + + +@randomised +def matched_up(ms): return [ + f"Matched up {format_list(ms)}!", + f"Hey {format_list(ms)}, have a good match!", + f"Ahoy {format_list(ms)}, y'all be good :)", + f"Sweet! {format_list(ms)} are a group!", + f"Arf arf {format_list(ms)} bork bork arf!", + f"{format_list(ms)}, y'all are the best!", + f"{format_list(ms)}, DFTBA!", +] + + +@randomised +def thread_title(ms): return [ + f"{format_list(ms)}", +] From b5c86f51ca529f2e0fb5fc566ec6ca300f245ead Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 17 Aug 2024 22:45:20 +0100 Subject: [PATCH 3/6] Fix up merge conflicts --- matchy/cogs/matcher.py | 2 +- matchy/matching.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index 420c60e..fb33b42 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -261,7 +261,7 @@ class MatchDynamicButton(discord.ui.DynamicItem[discord.ui.Button], async def match_groups_in_channel(channel: discord.channel, min: int): """Match up the groups in a given channel""" - groups = matching.active_members_to_groups(state, channel, min) + groups = matching.active_members_to_groups(channel, min) # Send the groups for group in groups: diff --git a/matchy/matching.py b/matchy/matching.py index 465dac5..f23407f 100644 --- a/matchy/matching.py +++ b/matchy/matching.py @@ -193,6 +193,6 @@ def get_matchees_in_channel(channel: discord.channel): def active_members_to_groups(channel: discord.channel, min_members: int): """Helper to create groups from channel members""" # Gather up the prospective matchees - matchees = get_matchees_in_channel(channel) + (matchees, _) = get_matchees_in_channel(channel) # Create our groups! return members_to_groups(matchees, min_members, allow_fallback=True) From 1b9339631568bd61d0ffc358f0ae2b9c26061e2e Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 17 Aug 2024 22:53:05 +0100 Subject: [PATCH 4/6] Add string to the new schedule button sharing --- matchy/cogs/matcher.py | 12 ++++++------ matchy/cogs/strings.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index fb33b42..b4a6c8d 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -300,16 +300,16 @@ class ScheduleButton(discord.ui.Button): tasks = state.State.get_channel_match_tasks(interaction.channel.id) - msg = f"{interaction.user.mention} added a match to this channel!\n" - msg += "Current scheduled matches are:" + msg = strings.added_schedule(interaction.user.mention) + "\n" + msg += strings.scheduled_matches() if tasks: for (day, hour, min) in tasks: next_run = util.get_next_datetime(day, hour) - date_str = util.datetime_as_discord_time(next_run) - msg += f"\n{date_str} with {min} members per group\n" + msg += strings.scheduled(next_run, min) await interaction.channel.send(msg) - await interaction.response.send_message(content="Posted :)", ephemeral=True) + await interaction.response.send_message( + content=strings.acknowledgement(interaction.user.mention), ephemeral=True) else: - await interaction.response.send_message(content="No scheduled matches to post :(", ephemeral=True) + await interaction.response.send_message(content=strings.no_scheduled(), ephemeral=True) diff --git a/matchy/cogs/strings.py b/matchy/cogs/strings.py index bbf22e6..297e51b 100644 --- a/matchy/cogs/strings.py +++ b/matchy/cogs/strings.py @@ -178,3 +178,18 @@ def matched_up(ms): return [ def thread_title(ms): return [ f"{format_list(ms)}", ] + + +@randomised +def added_schedule(m): return [ + f"{m} added a match to this channel!" + f"A matchy run was scheduled by {m}." + f"{m} scheduled a match in here :)" +] + + +@randomised +def scheduled_matches(): return [ + "Current scheduled matches are:" + "I've got these scheduled matches right now:" +] From ca87b3d17e4cf1f776e9469ca5ea49e5a1a8e419 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 17 Aug 2024 22:54:38 +0100 Subject: [PATCH 5/6] Sneak in a removal of the autopep8 setting that isn't needed anymore --- .vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ecc61d3..52e3400 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,5 @@ ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, - "autopep8.interpreter": [".venv/bin/python"], "python.envFile": "${workspaceFolder}/.env", } \ No newline at end of file From 4a1c1083d0b26a15a4b575253a7a02e592327295 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Sat, 17 Aug 2024 22:55:30 +0100 Subject: [PATCH 6/6] Fix imports --- matchy/cogs/matcher.py | 2 +- matchy/matching.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/matchy/cogs/matcher.py b/matchy/cogs/matcher.py index b4a6c8d..394fb79 100644 --- a/matchy/cogs/matcher.py +++ b/matchy/cogs/matcher.py @@ -9,7 +9,7 @@ from datetime import datetime, timedelta, time import re import matchy.matching as matching -from matchy.state import State, AuthScope +from matchy.state import AuthScope import matchy.util as util import matchy.state as state import matchy.cogs.strings as strings diff --git a/matchy/matching.py b/matchy/matching.py index f23407f..406d059 100644 --- a/matchy/matching.py +++ b/matchy/matching.py @@ -3,7 +3,6 @@ import logging import discord from datetime import datetime from typing import Protocol, runtime_checkable -from matchy.state import State, ts_to_datetime import matchy.util as util import matchy.state as state