Skip to content

Commit

Permalink
Add prefixes for uf-mil-electrical/SubjuGator8 and uf-mil-electrical/…
Browse files Browse the repository at this point in the history
…SubjuGator9 repos (closes #51) (#52)
  • Loading branch information
cbrxyz authored Jun 26, 2024
1 parent 5c5f52a commit 80407cc
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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))

0 comments on commit 80407cc

Please sign in to comment.