diff options
| author | 2020-05-05 19:43:41 -0700 | |
|---|---|---|
| committer | 2020-06-13 11:21:05 -0700 | |
| commit | fb6017a8a00f5c54ea4532ff035abe8f34500f6f (patch) | |
| tree | 9b92a025aedb2d2c91df4bb5a4dba5b5f11c3f4b | |
| parent | Code block: add function to check for valid Python code (diff) | |
Code block: exclude code blocks 3 lines or shorter
| -rw-r--r-- | bot/cogs/codeblock/cog.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/cogs/codeblock/cog.py b/bot/cogs/codeblock/cog.py index 92bf43feb..64f9a4cbc 100644 --- a/bot/cogs/codeblock/cog.py +++ b/bot/cogs/codeblock/cog.py @@ -206,6 +206,8 @@ class CodeBlockCog(Cog, name="Code Block"): """ Find and return all Markdown code blocks in the `message`. + Code blocks with 3 or less lines are excluded. + If the `message` contains at least one code block with valid ticks and a specified language, return an empty sequence. This is based on the assumption that if the user managed to get one code block right, they already know how to fix the rest themselves. @@ -215,7 +217,7 @@ class CodeBlockCog(Cog, name="Code Block"): language = language.strip() if tick == BACKTICK and language: return () - else: + elif len(content.split("\n", 3)) > 3: code_block = CodeBlock(content, language, tick) code_blocks.append(code_block) |