aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-27 14:26:38 +0100
committerGravatar Gareth Coles <[email protected]>2018-06-27 14:26:38 +0100
commit78bec89d4458833156fcc63f7e4d206d95b96d5c (patch)
treebd7d6414a7fd576fe0168afbcbae2b8e4b51cfdc
parent[Snekbox] Detect codeblock escaping (diff)
[Snekbox] Add line numbers and truncation
-rw-r--r--bot/cogs/snekbox.py8
1 files changed, 7 insertions, 1 deletions
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)