Skip to content

Commit 5a5241d

Browse files
authored
Replaces the PC joke config with a better filter (#1266)
This replaces the old pc_jokes filter and replaces it with a blacklisted_filters config, which allows a set of filters to apply in non NSFW channels, no matter what. Additionally apply_in_nsfw_channels is added, to allow the filter to apply in all channels.
1 parent 5300e31 commit 5a5241d

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

techsupport_bot/commands/joke.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ async def setup(bot: bot.TechSupportBot) -> None:
1919
Args:
2020
bot (bot.TechSupportBot): The bot object to register the cogs to
2121
"""
22+
2223
config = extensionconfig.ExtensionConfig()
2324
config.add(
24-
key="pc_jokes",
25-
datatype="bool",
26-
title="Politically correct jokes only",
25+
key="blacklisted_filters",
26+
datatype="list[str]",
27+
title="Enable filter",
2728
description=(
28-
"True only politically correct jokes should be shown"
29-
" (non-racist/non-sexist)"
29+
"Filters all categories listed"
30+
"(nsfw,religious,political,racist,sexist,explicit)"
3031
),
31-
default=True,
32+
default=["nsfw", "explicit"],
33+
)
34+
config.add(
35+
key="apply_in_nsfw_channels",
36+
datatype="bool",
37+
title="Apply in NSFW Channels",
38+
description=("Toggles whether or not filters are applies in NSFW channels"),
39+
default=False,
3240
)
3341
await bot.add_cog(Joker(bot=bot))
3442
bot.add_extension_config("joke", config)
@@ -75,10 +83,11 @@ def build_url(self: Self, ctx: commands.Context, config: munch.Munch) -> str:
7583
str: The URL, properly formatted and ready to be called
7684
"""
7785
blacklist_flags = []
78-
if not ctx.channel.is_nsfw():
79-
blacklist_flags.extend(["explicit", "nsfw"])
80-
if config.extensions.joke.pc_jokes.value:
81-
blacklist_flags.extend(["sexist", "racist", "religious"])
86+
if (
87+
config.extensions.joke.apply_in_nsfw_channels.value
88+
or not ctx.channel.is_nsfw()
89+
):
90+
blacklist_flags = config.extensions.joke.blacklisted_filters.value
8291
blacklists = ",".join(blacklist_flags)
8392

8493
url = f"{self.API_URL}?blacklistFlags={blacklists}&format=txt"

0 commit comments

Comments
 (0)