Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions techsupport_bot/commands/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ async def on_member_join(self: Self, member: discord.Member) -> None:
MODMAIL_FORUM_ID = None
MODMAIL_LOG_CHANNEL_ID = None
AUTOMATIC_RESPONSES = None
AUTOMATIC_REJECTIONS = None
ROLES_TO_PING = None
THREAD_CREATION_MESSAGE = None

Expand Down Expand Up @@ -344,6 +345,15 @@ async def handle_dm(message: discord.Message) -> None:

# - No thread was found, create one -

for regex in AUTOMATIC_REJECTIONS:
if re.match(regex, message.content):
await auxiliary.send_deny_embed(
message="This message cannot be used to start a "
+ f"thread: {AUTOMATIC_REJECTIONS[regex]}",
channel=message.channel,
)
return

if message.author.id in awaiting_confirmation:
await auxiliary.send_deny_embed(
message="Please respond to the existing prompt before trying to open a new modmail"
Expand Down Expand Up @@ -842,6 +852,14 @@ async def setup(bot: bot.TechSupportBot) -> None:
default={},
)

config.add(
key="automatic_rejections",
datatype="dict",
title="Modmail auto-rejections",
description="If someone sends a message matching regex, blocks thread creation",
default={},
)

config.add(
key="modmail_roles",
datatype="list",
Expand Down Expand Up @@ -910,6 +928,10 @@ def __init__(self: Self, bot: bot.TechSupportBot) -> None:
global AUTOMATIC_RESPONSES
AUTOMATIC_RESPONSES = config.extensions.modmail.automatic_responses.value

# pylint: disable=W0603
global AUTOMATIC_REJECTIONS
AUTOMATIC_REJECTIONS = config.extensions.modmail.automatic_rejections.value

# pylint: disable=W0603
global ROLES_TO_PING
# dict.fromkeys() to deduplicate the list
Expand Down