checked the string in pep command is a number, and escape input
This commit is contained in:
parent
0e68e0efe7
commit
86a2049807
14
bot.py
14
bot.py
|
|
@ -297,11 +297,19 @@ def cmd_uptime(match: Match[str]) -> Response:
|
||||||
|
|
||||||
@handle_message('!pep')
|
@handle_message('!pep')
|
||||||
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))
|
||||||
|
|
||||||
|
if not pep.isdigit():
|
||||||
return MessageResponse(
|
return MessageResponse(
|
||||||
match,
|
match,
|
||||||
f'https://www.python.org/dev/peps/pep-{rest.zfill(4)}/',
|
'Please make sure you gave me a number!',
|
||||||
|
)
|
||||||
|
|
||||||
|
return MessageResponse(
|
||||||
|
match,
|
||||||
|
f'https://www.python.org/dev/peps/pep-{pep}/',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue