Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion bot/cogs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
Namespaces are one honking great idea -- let's do more of those!
"""

ICON_URL = "https://www.python.org/static/opengraph-icon-200x200.png"


class Utils(Cog):
"""A selection of utilities which don't have a clear category."""
Expand All @@ -59,6 +61,10 @@ async def pep_command(self, ctx: Context, pep_number: str) -> None:
await ctx.invoke(self.bot.get_command("help"), "pep")
return

# Handle PEP 0 directly because it's not in .rst or .txt so it can't be accessed like other PEPs.
if pep_number == 0:
return await self.send_pep_zero(ctx)

possible_extensions = ['.txt', '.rst']
found_pep = False
for extension in possible_extensions:
Expand All @@ -82,7 +88,7 @@ async def pep_command(self, ctx: Context, pep_number: str) -> None:
description=f"[Link]({self.base_pep_url}{pep_number:04})",
)

pep_embed.set_thumbnail(url="https://www.python.org/static/opengraph-icon-200x200.png")
pep_embed.set_thumbnail(url=ICON_URL)

# Add the interesting information
fields_to_check = ("Status", "Python-Version", "Created", "Type")
Expand Down Expand Up @@ -278,6 +284,19 @@ async def vote(self, ctx: Context, title: str, *options: str) -> None:
for reaction in options:
await message.add_reaction(reaction)

async def send_pep_zero(self, ctx: Context) -> None:
"""Send information about PEP 0."""
pep_embed = Embed(
title=f"**PEP 0 - Index of Python Enhancement Proposals (PEPs)**",
description=f"[Link](https://www.python.org/dev/peps/)"
)
pep_embed.set_thumbnail(url=ICON_URL)
pep_embed.add_field(name="Status", value="Active")
pep_embed.add_field(name="Created", value="13-Jul-2000")
pep_embed.add_field(name="Type", value="Informational")

await ctx.send(embed=pep_embed)


def setup(bot: Bot) -> None:
"""Load the Utils cog."""
Expand Down