slightly improve pep command

This commit is contained in:
Anthony Sottile 2019-11-16 14:25:18 -08:00
parent 06c052a077
commit 885872db0d
1 changed files with 5 additions and 9 deletions

14
bot.py
View File

@ -299,17 +299,13 @@ def cmd_uptime(match: Match[str]) -> Response:
def cmd_pep(match: Match[str]) -> Response:
*_, msg = match.groups()
*_, rest = msg.partition(' ')
pep = esc(rest.zfill(4))
pep = rest.strip()
if not pep.isdigit():
if not pep.isdigit() or len(pep) > 4:
return MessageResponse(match, 'Please make sure you gave me a number!')
else:
return MessageResponse(
match,
'Please make sure you gave me a number!',
)
return MessageResponse(
match,
f'https://www.python.org/dev/peps/pep-{pep}/',
match, f'https://www.python.org/dev/peps/pep-{pep.zfill(4)}/',
)