Fix metadata leaking and skip sentiment for bot-directed messages

1. Broader regex to strip leaked metadata even when the LLM drops
   the "Server context:" prefix but keeps the content.

2. Skip sentiment analysis for messages that mention or reply to
   the bot. Users interacting with the bot in roast/chat modes
   shouldn't have those messages inflate their drama score.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 10:52:33 -05:00
parent 7743b22795
commit 431d63da72
2 changed files with 14 additions and 0 deletions

View File

@@ -165,6 +165,8 @@ class ChatCog(commands.Cog):
if response:
response = re.sub(r"\[Server context:[^\]]*\]\n?", "", response)
response = re.sub(r"\[Replying to bot's message:[^\]]*\]\n?", "", response)
# Catch reformatted metadata (LLM drops prefix but keeps content)
response = re.sub(r"\[[^\]]*#[a-z-]+[^\]]*(?:drama score|offense)[^\]]*\]\n?", "", response, flags=re.IGNORECASE)
response = response.strip()
if not response:
@@ -274,6 +276,7 @@ class ChatCog(commands.Cog):
response = re.sub(r"\[Server context:[^\]]*\]\n?", "", response)
response = re.sub(r"\[.*?reacted to your message.*?\]\n?", "", response)
response = re.sub(r"\[Your message was:.*?\]\n?", "", response)
response = re.sub(r"\[[^\]]*#[a-z-]+[^\]]*(?:drama score|offense)[^\]]*\]\n?", "", response, flags=re.IGNORECASE)
response = response.strip()
if not response: