From ce16d0df6c10121f761899daea07d3656c4e7537 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 8 Jan 2022 22:27:48 +0000 Subject: Change single quote to double quote. This trivial change is actually to try and reproduce a bug we had with our GitHub actions. --- bot/monkey_patches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/monkey_patches.py b/bot/monkey_patches.py index 19965c19..36708415 100644 --- a/bot/monkey_patches.py +++ b/bot/monkey_patches.py @@ -6,7 +6,7 @@ from discord import Forbidden, http from discord.ext import commands log = logging.getLogger(__name__) -MESSAGE_ID_RE = re.compile(r'(?P[0-9]{15,20})$') +MESSAGE_ID_RE = re.compile(r"(?P[0-9]{15,20})$") class Command(commands.Command): -- cgit v1.2.3 From 4f823346d56929964a092bd8119ec54f1458701e Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 8 Jan 2022 22:44:28 +0000 Subject: Remove trailing whitespace Like the previous commit, this trivial change is actually to try and reproduce a bug we had with our GitHub actions. --- bot/monkey_patches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/monkey_patches.py b/bot/monkey_patches.py index 36708415..925d3206 100644 --- a/bot/monkey_patches.py +++ b/bot/monkey_patches.py @@ -6,7 +6,7 @@ from discord import Forbidden, http from discord.ext import commands log = logging.getLogger(__name__) -MESSAGE_ID_RE = re.compile(r"(?P[0-9]{15,20})$") +MESSAGE_ID_RE = re.compile(r"(?P[0-9]{15,20})$") class Command(commands.Command): -- cgit v1.2.3 From 5276045e3594c8851b83dd8b8fd8e7ba014ac3b2 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sun, 9 Jan 2022 19:06:36 +0000 Subject: Fix aoc join in date logic --- bot/exts/events/advent_of_code/_cog.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bot') diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py index a5410871..01161f26 100644 --- a/bot/exts/events/advent_of_code/_cog.py +++ b/bot/exts/events/advent_of_code/_cog.py @@ -187,9 +187,10 @@ class AdventOfCode(commands.Cog): async def join_leaderboard(self, ctx: commands.Context) -> None: """DM the user the information for joining the Python Discord leaderboard.""" current_date = datetime.now() - if ( - current_date.month not in (Month.NOVEMBER, Month.DECEMBER) and current_date.year != AocConfig.year or - current_date.month != Month.JANUARY and current_date.year != AocConfig.year + 1 + allowed_months = (Month.NOVEMBER.value, Month.DECEMBER.value) + if not ( + current_date.month in allowed_months and current_date.year == AocConfig.year or + current_date.month == Month.JANUARY.value and current_date.year == AocConfig.year + 1 ): # Only allow joining the leaderboard in the run up to AOC and the January following. await ctx.send(f"The Python Discord leaderboard for {current_date.year} is not yet available!") -- cgit v1.2.3 From 5ef4b73a9d6f3d15d6fb22874e7de3af7d2928e3 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Wed, 12 Jan 2022 14:06:50 +0000 Subject: Fix AoC name lookup for anon users When a user doesn't set a name, the AoC API doesn't return a name key at all, so we need to make use of the ID field instead, to build the name based on a similar tempalte that AoC uses for it's leaderboard. Co-authored-by: ToxicKidz <78174417+ToxicKidz@users.noreply.github.com> --- bot/exts/events/advent_of_code/_cog.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py index 01161f26..3acfef39 100644 --- a/bot/exts/events/advent_of_code/_cog.py +++ b/bot/exts/events/advent_of_code/_cog.py @@ -96,7 +96,9 @@ class AdventOfCode(commands.Cog): # Only give the role to people who have completed all 50 stars continue - member_id = aoc_name_to_member_id.get(member_aoc_info["name"], None) + aoc_name = member_aoc_info["name"] or f"Anonymous #{member_aoc_info['id']}" + + member_id = aoc_name_to_member_id.get(aoc_name) if not member_id: log.debug(f"Could not find member_id for {member_aoc_info['name']}, not giving role.") continue -- cgit v1.2.3