diff options
| author | 2018-07-02 19:53:58 +0100 | |
|---|---|---|
| committer | 2018-07-02 19:53:58 +0100 | |
| commit | 9b2312e2f5395ca8c3f9e7e4af53aeddc2a0f7e5 (patch) | |
| tree | c8db620e9ce6e56a13bdc9144dbe3da3203f57c2 | |
| parent | force redeploy (diff) | |
[Snekbox] Truncate output if there's too many lines
| -rw-r--r-- | bot/cogs/snekbox.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 22dbde89e..9fbebbaa0 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -73,8 +73,16 @@ class Snekbox: output = [f"{i:03d} | {line}" for i, line in enumerate(output.split("\n"), start=1)] output = "\n".join(output) - if len(output) >= 1900: - output = f"{output[:1900]}... (truncated)" + if output.count("\n") > 10: + output = "\n".join(output.split("\n")[:10]) + + if len(output) >= 1900: + output = f"{output[:1900]}\n... (truncated)" + else: + output = f"{output}\n... (truncated)" + + elif len(output) >= 1900: + output = f"{output[:1900]}\n... (truncated)" await ctx.send( f"{ctx.author.mention} Your eval job has completed.\n\n```\n{output}\n```" |