diff options
| author | 2022-01-09 17:35:18 +0000 | |
|---|---|---|
| committer | 2022-01-09 17:35:18 +0000 | |
| commit | 8845e5bdbe195f2612b3652775378129383c1d6b (patch) | |
| tree | 32d470cd51fd44315f2dec3172a55fc766017258 | |
| parent | Move single-use message ID regex to inside file that uses it (diff) | |
Use codeblock regex from bot-core in snekbox cog
| -rw-r--r-- | bot/exts/utils/snekbox.py | 16 | 
1 files changed, 1 insertions, 15 deletions
| diff --git a/bot/exts/utils/snekbox.py b/bot/exts/utils/snekbox.py index ef24cbd77..cc3a2e1d7 100644 --- a/bot/exts/utils/snekbox.py +++ b/bot/exts/utils/snekbox.py @@ -7,6 +7,7 @@ from functools import partial  from signal import Signals  from typing import Optional, Tuple +from botcore.regex import FORMATTED_CODE_REGEX, RAW_CODE_REGEX  from discord import AllowedMentions, HTTPException, Message, NotFound, Reaction, User  from discord.ext.commands import Cog, Context, command, guild_only @@ -20,21 +21,6 @@ from bot.utils.messages import wait_for_deletion  log = get_logger(__name__)  ESCAPE_REGEX = re.compile("[`\u202E\u200B]{3,}") -FORMATTED_CODE_REGEX = re.compile( -    r"(?P<delim>(?P<block>```)|``?)"        # code delimiter: 1-3 backticks; (?P=block) only matches if it's a block -    r"(?(block)(?:(?P<lang>[a-z]+)\n)?)"    # if we're in a block, match optional language (only letters plus newline) -    r"(?:[ \t]*\n)*"                        # any blank (empty or tabs/spaces only) lines before the code -    r"(?P<code>.*?)"                        # extract all code inside the markup -    r"\s*"                                  # any more whitespace before the end of the code markup -    r"(?P=delim)",                          # match the exact same delimiter from the start again -    re.DOTALL | re.IGNORECASE               # "." also matches newlines, case insensitive -) -RAW_CODE_REGEX = re.compile( -    r"^(?:[ \t]*\n)*"                       # any blank (empty or tabs/spaces only) lines before the code -    r"(?P<code>.*?)"                        # extract all the rest as code -    r"\s*$",                                # any trailing whitespace until the end of the string -    re.DOTALL                               # "." also matches newlines -)  MAX_PASTE_LEN = 10000 | 
