diff options
| author | 2018-06-27 23:01:56 +0100 | |
|---|---|---|
| committer | 2018-06-27 23:01:56 +0100 | |
| commit | 5b54e9a426143ae7ef16a313fca6fde8ac02eec7 (patch) | |
| tree | eed330ac9cf2ad8fc2f4ad286cecb8634783eefb | |
| parent | [Snekbox] Fix up message consuming (diff) | |
[Snekbox] Improve output
| -rw-r--r-- | bot/cogs/snekbox.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 67bdd5a6e..22dbde89e 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -13,6 +13,13 @@ RMQ_ARGS = { "auto_delete": True } +CODE_TEMPLATE = """ +try: + {CODE} +except Exception as e: + print(e) +""" + class Snekbox: """ @@ -46,6 +53,9 @@ 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")] + code = CODE_TEMPLATE.replace("{CODE}", "\n".join(code)) + try: await self.rmq.send_json( "input", @@ -67,7 +77,7 @@ class Snekbox: output = f"{output[:1900]}... (truncated)" await ctx.send( - f"{ctx.author.mention} Your eval job has completed.\n\n```{output}```" + f"{ctx.author.mention} Your eval job has completed.\n\n```\n{output}\n```" ) del self.jobs[ctx.author.id] |