aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/information.py5
-rw-r--r--bot/cogs/snekbox.py24
2 files changed, 18 insertions, 11 deletions
diff --git a/bot/cogs/information.py b/bot/cogs/information.py
index 129166d2f..0d31cb0d3 100644
--- a/bot/cogs/information.py
+++ b/bot/cogs/information.py
@@ -135,10 +135,13 @@ class Information:
if not with_role_check(ctx, *MODERATION_ROLES):
raise BadArgument("You do not have permission to use this command on users other than yourself.")
- # Non-moderators may only do this in #bot-commands
+ # Non-moderators may only do this in #bot-commands and can't see
+ # hidden infractions.
if not with_role_check(ctx, *MODERATION_ROLES):
if not ctx.channel.id == Channels.bot:
raise MissingPermissions("You can't do that here!")
+ # Hide hidden infractions for users without a moderation role
+ hidden = False
# Validates hidden input
hidden = str(hidden)
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index cb0454249..cfbd032cb 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -29,8 +29,9 @@ exec(open(venv_file).read(), dict(__file__=venv_file))
try:
{CODE}
-except Exception as e:
- print(e)
+except:
+ import traceback
+ print(traceback.format_exc())
"""
ESCAPE_REGEX = re.compile("[`\u202E\u200B]{3,}")
@@ -103,10 +104,16 @@ class Snekbox:
code = textwrap.dedent(RAW_CODE_REGEX.fullmatch(code).group("code"))
log.trace(f"Eval message contains not or badly formatted code, stripping whitespace only:\n{code}")
- code = textwrap.indent(code, " ")
- code = CODE_TEMPLATE.replace("{CODE}", code)
-
try:
+ stripped_lines = [ln.strip() for ln in code.split('\n')]
+ if all([line.startswith('#') for line in stripped_lines]):
+ return await ctx.send(
+ f"{ctx.author.mention} Your eval job has completed.\n\n```[No output]```"
+ )
+
+ code = textwrap.indent(code, " ")
+ code = CODE_TEMPLATE.replace("{CODE}", code)
+
await self.rmq.send_json(
"input",
snekid=str(ctx.author.id), message=code
@@ -174,13 +181,10 @@ class Snekbox:
else:
await ctx.send(
- f"{ctx.author.mention} Your eval job has completed.\n\n```py\n[No output]\n```"
+ f"{ctx.author.mention} Your eval job has completed.\n\n```[No output]```"
)
-
- del self.jobs[ctx.author.id]
- except Exception:
+ finally:
del self.jobs[ctx.author.id]
- raise
@eval_command.error
async def eval_command_error(self, ctx: Context, error: CommandError):