From 35ec9846c4f7a34f3ac83fa206f7511d50cdff50 Mon Sep 17 00:00:00 2001 From: Matias Lago Evia Date: Fri, 10 Mar 2023 09:04:52 -0500 Subject: Allow .latex in python-help channel --- bot/constants.py | 1 + bot/exts/fun/latex.py | 1 + 2 files changed, 2 insertions(+) (limited to 'bot') diff --git a/bot/constants.py b/bot/constants.py index fed41ab9..7e5fa1d9 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -57,6 +57,7 @@ class Channels(NamedTuple): off_topic_0 = 291284109232308226 off_topic_1 = 463035241142026251 off_topic_2 = 463035268514185226 + python_help = 1035199133436354600 sir_lancebot_playground = int(environ.get("CHANNEL_COMMUNITY_BOT_COMMANDS", 607247579608121354)) voice_chat_0 = 412357430186344448 voice_chat_1 = 799647045886541885 diff --git a/bot/exts/fun/latex.py b/bot/exts/fun/latex.py index 311b4ac2..8af05413 100644 --- a/bot/exts/fun/latex.py +++ b/bot/exts/fun/latex.py @@ -37,6 +37,7 @@ PAD = 10 LATEX_ALLOWED_CHANNNELS = WHITELISTED_CHANNELS + ( Channels.data_science_and_ai, Channels.algos_and_data_structs, + Channels.python_help, ) -- cgit v1.2.3 From c8de15b36590a839d9221ea0838eed23715d3d23 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Fri, 10 Mar 2023 16:22:52 +0100 Subject: whitelist a thread along with its parent --- bot/utils/checks.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bot') diff --git a/bot/utils/checks.py b/bot/utils/checks.py index 5433f436..89f11f54 100644 --- a/bot/utils/checks.py +++ b/bot/utils/checks.py @@ -3,6 +3,7 @@ import logging from collections.abc import Container, Iterable from typing import Callable, Optional +from discord import Thread from discord.ext.commands import ( BucketType, CheckFailure, Cog, Command, CommandOnCooldown, Context, Cooldown, CooldownMapping ) @@ -60,6 +61,10 @@ def in_whitelist_check( # categories, it's probably not wise to rely on its category in any case. channels = tuple(channels) + (redirect,) + # If it's a thread, and its parent is whitelisted, we whitelist the thread as well + if channels and isinstance(ctx.channel, Thread) and ctx.channel.parent_id in channels: + channels = channels + (ctx.channel.id,) + if channels and ctx.channel.id in channels: log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a whitelisted channel.") return True -- cgit v1.2.3 From d81811e2b5550701bc1c268e50db707105112119 Mon Sep 17 00:00:00 2001 From: shtlrs Date: Fri, 10 Mar 2023 17:04:13 +0100 Subject: replace a thread with its parent if present --- bot/utils/checks.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'bot') diff --git a/bot/utils/checks.py b/bot/utils/checks.py index 89f11f54..857b6746 100644 --- a/bot/utils/checks.py +++ b/bot/utils/checks.py @@ -3,7 +3,6 @@ import logging from collections.abc import Container, Iterable from typing import Callable, Optional -from discord import Thread from discord.ext.commands import ( BucketType, CheckFailure, Cog, Command, CommandOnCooldown, Context, Cooldown, CooldownMapping ) @@ -61,20 +60,20 @@ def in_whitelist_check( # categories, it's probably not wise to rely on its category in any case. channels = tuple(channels) + (redirect,) - # If it's a thread, and its parent is whitelisted, we whitelist the thread as well - if channels and isinstance(ctx.channel, Thread) and ctx.channel.parent_id in channels: - channels = channels + (ctx.channel.id,) + ctx_channel = ctx.channel + if hasattr(ctx_channel, "parent"): + ctx_channel = ctx_channel.parent - if channels and ctx.channel.id in channels: + if channels and ctx_channel.id in channels: log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a whitelisted channel.") return True # Only check the category id if we have a category whitelist and the channel has a `category_id` - if categories and hasattr(ctx.channel, "category_id") and ctx.channel.category_id in categories: + if categories and hasattr(ctx_channel, "category_id") and ctx_channel.category_id in categories: log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a whitelisted category.") return True - category = getattr(ctx.channel, "category", None) + category = getattr(ctx_channel, "category", None) if category and category.name == constants.codejam_categories_name: log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a codejam team channel.") return True -- cgit v1.2.3