bot: more input sanitization
This commit is contained in:
@@ -126,7 +126,7 @@ async def on_message(message):
|
|||||||
if len(args) > 1 and message.author.display_name is not None:
|
if len(args) > 1 and message.author.display_name is not None:
|
||||||
left_wmark_text = f"By {message.author.display_name}"
|
left_wmark_text = f"By {message.author.display_name}"
|
||||||
logging.info(args[0])
|
logging.info(args[0])
|
||||||
meme_id = re.sub(r'[^\w ]', "", args[0])
|
meme_id = re.sub(r'[^A-Za-z0-9 _]', "", args[0]).strip()
|
||||||
args[0] = meme_id
|
args[0] = meme_id
|
||||||
img = meme_otron.compute(*args, left_wmark_text=left_wmark_text)
|
img = meme_otron.compute(*args, left_wmark_text=left_wmark_text)
|
||||||
if img is None:
|
if img is None:
|
||||||
@@ -139,6 +139,9 @@ async def on_message(message):
|
|||||||
response += f"Did you mean `{hint}`?\n"
|
response += f"Did you mean `{hint}`?\n"
|
||||||
response += f"You can find a more detailed help and a list of templates at:\n" \
|
response += f"You can find a more detailed help and a list of templates at:\n" \
|
||||||
f"<{DOC_URL}>"
|
f"<{DOC_URL}>"
|
||||||
|
if len(response) >= 2000:
|
||||||
|
await message.channel.send(f"{message.author.mention} ... really?")
|
||||||
|
else:
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
else:
|
else:
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as output:
|
with tempfile.NamedTemporaryFile(delete=False) as output:
|
||||||
|
|||||||
Reference in New Issue
Block a user