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
60 changes: 31 additions & 29 deletions techsupport_bot/commands/forum.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,36 +418,38 @@ async def on_thread_create(self: Self, thread: discord.Thread) -> None:
return

# Check if the thread body is disallowed
messages = [message async for message in thread.history(limit=5)]
if messages:
body = messages[-1].content
disallowed_body_patterns = create_regex_list(
configuration.get_config_entry(thread.guild.id, "forum_body_regex_list")
message = await thread.fetch_message(thread.id)
body = message.clean_content
if not body:
body = ""

disallowed_body_patterns = create_regex_list(
configuration.get_config_entry(thread.guild.id, "forum_body_regex_list")
)
if any(pattern.search(body) for pattern in disallowed_body_patterns):
await mark_thread(
thread,
self.thread_ID_closed,
"rejected",
reason=(
"Your thread doesn't meet our posting requirements. "
"Please make sure you have a well written title and a detailed body."
),
)
if any(pattern.search(body) for pattern in disallowed_body_patterns):
await mark_thread(
thread,
self.thread_ID_closed,
"rejected",
reason=(
"Your thread doesn't meet our posting requirements. "
"Please make sure you have a well written title and a detailed body."
),
)
return
if body.lower() == thread.name.lower() or len(body.lower()) < len(
thread.name.lower()
):
await mark_thread(
thread,
self.thread_ID_closed,
"rejected",
reason=(
"Your thread doesn't meet our posting requirements. "
"Please make sure you have a well written title and a detailed body."
),
)
return
return
if body.lower() == thread.name.lower() or len(body.lower()) < len(
thread.name.lower()
):
await mark_thread(
thread,
self.thread_ID_closed,
"rejected",
reason=(
"Your thread doesn't meet our posting requirements. "
"Please make sure you have a well written title and a detailed body."
),
)
return

# Check if the thread creator has an existing open thread
for existing_thread in channel.threads:
Expand Down
Loading