From 78bec89d4458833156fcc63f7e4d206d95b96d5c Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 27 Jun 2018 14:26:38 +0100 Subject: [Snekbox] Add line numbers and truncation --- bot/cogs/snekbox.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 4edba3539..7526c8bb7 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -56,11 +56,17 @@ class Snekbox: async def callback(message: Message): output = message.body.decode() - colour = Colour.red() + colour = Colour.blurple() if "```" in output: output = "Code block escape attempt detected; will not output result" colour = Colour.red() + else: + output = [f"{i} | {line}" for i, line in enumerate(output.split("\n"), start=1)] + output = "\n".join(output) + + if len(output) >= 2048: + output = f"{output[:2000]}... (truncated)" embed = Embed(description=f"```{output}```", title="Code evaluation", colour=colour) -- cgit v1.2.3