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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user