diff --git a/cogs/chat.py b/cogs/chat.py index 26151f7..ea1dc63 100644 --- a/cogs/chat.py +++ b/cogs/chat.py @@ -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: diff --git a/cogs/sentiment.py b/cogs/sentiment.py index 55e0ed5..0b836e1 100644 --- a/cogs/sentiment.py +++ b/cogs/sentiment.py @@ -80,6 +80,17 @@ class SentimentCog(commands.Cog): if self.bot.drama_tracker.is_immune(message.author.id): return + # Skip sentiment analysis for messages directed at the bot + # (mentions, replies to bot) — users interacting with the bot + # in roast/chat modes shouldn't have those messages scored as toxic + directed_at_bot = self.bot.user in message.mentions + if not directed_at_bot and message.reference and message.reference.message_id: + ref = message.reference.cached_message + if ref and ref.author.id == self.bot.user.id: + directed_at_bot = True + if directed_at_bot: + return + # Store message in channel history for context self._store_context(message)