diff options
author | 2018-08-30 12:06:13 +0100 | |
---|---|---|
committer | 2018-08-30 12:06:13 +0100 | |
commit | a9124b6fe4033613e8d90df0bb3ca71acaf9656c (patch) | |
tree | 590b6ddcd3768e50d278a479a8ee8ae98a0fb55e | |
parent | [Security] Prevent commands in DM - Fixes #60 (diff) |
[Utils] Pep command outputs help on non-number. Fixes #59
-rw-r--r-- | bot/cogs/utils.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index 22e0cfbe7..b101b8816 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -30,11 +30,16 @@ class Utils: Fetches information about a PEP and sends it to the channel. """ + if pep_number.isdigit(): + pep_number = int(pep_number) + else: + return await ctx.invoke(self.bot.get_command("help"), "pep") + # Newer PEPs are written in RST instead of txt - if int(pep_number) > 542: - pep_url = f"{self.base_github_pep_url}{pep_number.zfill(4)}.rst" + if pep_number > 542: + pep_url = f"{self.base_github_pep_url}{pep_number:04}.rst" else: - pep_url = f"{self.base_github_pep_url}{pep_number.zfill(4)}.txt" + pep_url = f"{self.base_github_pep_url}{pep_number:04}.txt" # Attempt to fetch the PEP log.trace(f"Requesting PEP {pep_number} with {pep_url}") @@ -51,7 +56,7 @@ class Utils: # Assemble the embed pep_embed = Embed( title=f"**PEP {pep_number} - {pep_header['Title']}**", - description=f"[Link]({self.base_pep_url}{pep_number.zfill(4)})", + description=f"[Link]({self.base_pep_url}{pep_number:04})", ) pep_embed.set_thumbnail(url="https://www.python.org/static/opengraph-icon-200x200.png") |