aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-08-23 13:12:59 +0000
committerGravatar Gareth Coles <[email protected]>2018-08-23 13:12:59 +0000
commit58bfd9bb1adb30cc409474cd79d5a5cab278113c (patch)
treef7f28805d8942e6702e97d712b0e37dacc2a51c9
parentMerge branch 'cleanup/remove-clickup-cog' into 'master' (diff)
parentdent :wrench: (diff)
Merge branch 'eval-indent-fix' into 'master'
Fix !eval indentation errors. See merge request python-discord/projects/bot!58
-rw-r--r--bot/cogs/snekbox.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index 5a4e46b80..b3c829d59 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -2,6 +2,7 @@ import datetime
import logging
import random
import re
+import textwrap
from discord import Colour, Embed
from discord.ext.commands import (
@@ -25,7 +26,7 @@ venv_file = "/snekbox/.venv/bin/activate_this.py"
exec(open(venv_file).read(), dict(__file__=venv_file))
try:
- {CODE}
+{CODE}
except Exception as e:
print(e)
"""
@@ -90,9 +91,9 @@ class Snekbox:
elif code.startswith("py"):
code = code[2:]
- code = code.strip()
- code = [f" {line.rstrip()}" for line in code.split("\n")]
- code = CODE_TEMPLATE.replace("{CODE}", "\n".join(code))
+ code = textwrap.dedent(code.strip())
+ code = textwrap.indent(code, " ")
+ code = CODE_TEMPLATE.replace("{CODE}", code)
try:
await self.rmq.send_json(