fix: address multiple bugs found in code review

- Fix dirty-user flush race: discard IDs individually after successful save
- Escape LIKE wildcards in LLM-generated topic keywords for DB queries
- Anonymize absent-member aliases to prevent LLM de-anonymization
- Pass correct MIME type to vision model based on image file extension
- Use enumerate instead of list.index() in bcs-scan loop
- Allow bot @mentions with non-report intent to fall through to moderation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 01:16:38 -05:00
parent eb7eb81621
commit 2ec9b16b99
6 changed files with 35 additions and 22 deletions
+8 -4
View File
@@ -145,7 +145,9 @@ class SentimentCog(commands.Cog):
mention_config = config.get("mention_scan", {})
if mention_config.get("enabled", True):
await self._maybe_start_mention_scan(message, mention_config)
return
return
# For non-report intents, fall through to buffer the message
# so it still gets scored for toxicity
# Skip if empty
if not message.content or not message.content.strip():
@@ -317,11 +319,13 @@ class SentimentCog(commands.Cog):
if aliases:
anon_key = anon_map.get(msg.author.display_name, msg.author.display_name)
lines.append(f" {anon_key} is also known as: {', '.join(aliases)}")
# Also include aliases for members NOT in the conversation (so the LLM
# can recognize name-drops of absent members)
# Include aliases for members NOT in the conversation (so the LLM
# can recognize name-drops of absent members), using anonymized keys
absent_idx = 0
for uid, aliases in all_aliases.items():
if uid not in seen_ids:
lines.append(f" (not in chat) also known as: {', '.join(aliases)}")
absent_idx += 1
lines.append(f" Absent_{absent_idx} is also known as: {', '.join(aliases)}")
return "\n".join(lines) if lines else ""
@staticmethod