slightly improve pep command
This commit is contained in:
parent
06c052a077
commit
885872db0d
14
bot.py
14
bot.py
|
|
@ -299,19 +299,15 @@ def cmd_uptime(match: Match[str]) -> Response:
|
||||||
def cmd_pep(match: Match[str]) -> Response:
|
def cmd_pep(match: Match[str]) -> Response:
|
||||||
*_, msg = match.groups()
|
*_, msg = match.groups()
|
||||||
*_, rest = msg.partition(' ')
|
*_, 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(
|
return MessageResponse(
|
||||||
match,
|
match, f'https://www.python.org/dev/peps/pep-{pep.zfill(4)}/',
|
||||||
'Please make sure you gave me a number!',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return MessageResponse(
|
|
||||||
match,
|
|
||||||
f'https://www.python.org/dev/peps/pep-{pep}/',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
COMMAND_RE = re.compile(r'!\w+')
|
COMMAND_RE = re.compile(r'!\w+')
|
||||||
SECRET_CMDS = frozenset(('!settoday',))
|
SECRET_CMDS = frozenset(('!settoday',))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue