aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/codeblock/parsing.py
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-05-08 17:32:34 -0700
committerGravatar MarkKoz <[email protected]>2020-06-13 11:22:03 -0700
commita2cac1da6ae309fc8c77a019336348fb236f1bdb (patch)
tree5368059f59331115ed23e4b9b18cf30870c35fd0 /bot/cogs/codeblock/parsing.py
parentCode block: adjust logging levels (diff)
Create a utility function to count lines in a string
Diffstat (limited to '')
-rw-r--r--bot/cogs/codeblock/parsing.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/cogs/codeblock/parsing.py b/bot/cogs/codeblock/parsing.py
index 1bdb3b492..332a1deb0 100644
--- a/bot/cogs/codeblock/parsing.py
+++ b/bot/cogs/codeblock/parsing.py
@@ -5,6 +5,8 @@ import logging
import re
from typing import NamedTuple, Optional, Sequence
+from bot.utils import has_lines
+
log = logging.getLogger(__name__)
BACKTICK = "`"
@@ -82,7 +84,7 @@ def find_code_blocks(message: str) -> Optional[Sequence[CodeBlock]]:
if groups["tick"] == BACKTICK and language:
log.trace("Message has a valid code block with a language; returning None.")
return None
- elif len(groups["code"].split("\n", 3)) > 3:
+ elif has_lines(groups["code"], 4):
code_block = CodeBlock(groups["code"], language, groups["tick"])
code_blocks.append(code_block)
else: