aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts
diff options
context:
space:
mode:
authorGravatar PH-KDX <[email protected]>2022-05-30 10:18:04 +0200
committerGravatar GitHub <[email protected]>2022-05-30 10:18:04 +0200
commitdb1e80d2661a81c5bb2cee07e543bf96998d9245 (patch)
tree9792ae06e1d72f321670c730c419516cb05eb404 /bot/exts
parentAdd amssymb package (diff)
parentMerge pull request #1059 from python-discord/allow-latex-in-data-science (diff)
Merge branch 'main' into patch-1
Diffstat (limited to 'bot/exts')
-rw-r--r--bot/exts/fun/latex.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/exts/fun/latex.py b/bot/exts/fun/latex.py
index d43ec8c4..f0f2f8c0 100644
--- a/bot/exts/fun/latex.py
+++ b/bot/exts/fun/latex.py
@@ -10,6 +10,8 @@ from PIL import Image
from discord.ext import commands
from bot.bot import Bot
+from bot.constants import Channels, WHITELISTED_CHANNELS
+from bot.utils.decorators import whitelist_override
FORMATTED_CODE_REGEX = re.compile(
r"(?P<delim>(?P<block>```)|``?)" # code delimiter: 1-3 backticks; (?P=block) only matches if it's a block
@@ -31,6 +33,10 @@ TEMPLATE = string.Template(Path("bot/resources/fun/latex_template.txt").read_tex
PAD = 10
+LATEX_ALLOWED_CHANNNELS = WHITELISTED_CHANNELS + (
+ Channels.data_science_and_ai,
+)
+
def _prepare_input(text: str) -> str:
"""Extract latex from a codeblock, if it is in one."""
@@ -97,6 +103,7 @@ class Latex(commands.Cog):
@commands.command()
@commands.max_concurrency(1, commands.BucketType.guild, wait=True)
+ @whitelist_override(channels=LATEX_ALLOWED_CHANNNELS)
async def latex(self, ctx: commands.Context, *, query: str) -> None:
"""Renders the text in latex and sends the image."""
query = _prepare_input(query)