From 80407ccdaec262c3f120c50fe10d3f29fef240d8 Mon Sep 17 00:00:00 2001 From: cameron brown <52760912+cbrxyz@users.noreply.github.com> Date: Wed, 26 Jun 2024 01:44:14 -0400 Subject: [PATCH] Add prefixes for uf-mil-electrical/SubjuGator8 and uf-mil-electrical/SubjuGator9 repos (closes #51) (#52) --- src/github.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/github.py b/src/github.py index 990ec9a..157a141 100644 --- a/src/github.py +++ b/src/github.py @@ -407,9 +407,11 @@ def get_issue_or_pull(self, issue: Issue): icon_url=issue["user"]["avatar_url"], ) res.set_thumbnail(url=issue["user"]["avatar_url"]) + url_segments = issue["repository_url"].split("/") + repository_name = f"{url_segments[-2]}/{url_segments[-1]}" res.add_field( name="Repository", - value=f"[`uf-mil/mil`]({issue['repository_url']})", + value=f"[`{repository_name}`]({issue['repository_url']})", inline=True, ) iso_date = issue["created_at"] @@ -480,6 +482,34 @@ async def on_message(self, message: discord.Message): issue = await self.github.get_issue("uf-mil/mil", int(match)) await message.reply(embed=self.get_issue_or_pull(issue)) + ELECTRICAL_SUB8_REGEX = r"\bs8\#(\d+)\b" + matches = re.findall( + ELECTRICAL_SUB8_REGEX, + message.content, + re.IGNORECASE | re.MULTILINE, + ) + if matches: + for match in matches: + issue = await self.github.get_issue( + "uf-mil-electrical/SubjuGator8", + int(match), + ) + await message.reply(embed=self.get_issue_or_pull(issue)) + + ELECTRICAL_SUB9_REGEX = r"\bs9\#(\d+)\b" + matches = re.findall( + ELECTRICAL_SUB9_REGEX, + message.content, + re.IGNORECASE | re.MULTILINE, + ) + if matches: + for match in matches: + issue = await self.github.get_issue( + "uf-mil-electrical/SubjuGator9", + int(match), + ) + await message.reply(embed=self.get_issue_or_pull(issue)) + async def setup(bot: MILBot): await bot.add_cog(GitHubCog(bot))