From 0095cfa18ec7ede434ce130c47e6c0cdd873fea5 Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Fri, 27 Jul 2018 12:03:54 +0100 Subject: Fix eval and add codeblock support --- bot/cogs/snekbox.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 7115e3ae5..167e0aed6 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -79,7 +79,15 @@ class Snekbox: log.info(f"Received code from {ctx.author.name}#{ctx.author.discriminator} for evaluation:\n{code}") self.jobs[ctx.author.id] = datetime.datetime.now() - code = [f" {line}" for line in code.split("\n")] + if code.startswith("```") and code.endswith("```"): + code = code[3:-3] + + if code.startswith("python"): + code = code[6:] + elif code.startswith("py"): + code = code[2:] + + code = [f" {line.strip()}" for line in code.split("\n")] code = CODE_TEMPLATE.replace("{CODE}", "\n".join(code)) try: -- cgit v1.2.3