Add game channel redirect feature and sexual_vulgar detection

Detect when users discuss a game in the wrong channel (e.g. GTA talk
in #warzone) and send a friendly redirect to the correct channel.
Also add sexual_vulgar category and scoring rules so crude sexual
remarks directed at someone aren't softened by "lmao".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 17:02:59 -05:00
parent e41845de02
commit fee3e3e1bd
5 changed files with 150 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ ANALYSIS_TOOL = {
"instigating",
"hostile",
"manipulative",
"sexual_vulgar",
"none",
],
},
@@ -84,6 +85,10 @@ ANALYSIS_TOOL = {
"type": ["string", "null"],
"description": "Brief new observation about this user's style/behavior for future reference, or null if nothing new.",
},
"detected_game": {
"type": ["string", "null"],
"description": "The game channel name this message is about (e.g. 'gta-online', 'warzone'), or null if not game-specific.",
},
},
"required": ["toxicity_score", "categories", "reasoning", "off_topic", "topic_category", "topic_reasoning", "coherence_score", "coherence_flag"],
},
@@ -106,11 +111,14 @@ class LLMClient:
await self._client.close()
async def analyze_message(
self, message: str, context: str = "", user_notes: str = ""
self, message: str, context: str = "", user_notes: str = "",
channel_context: str = "",
) -> dict | None:
user_content = f"=== CONTEXT (other users' recent messages, for background only) ===\n{context}\n\n"
if user_notes:
user_content += f"=== NOTES ABOUT THIS USER (from prior analysis) ===\n{user_notes}\n\n"
if channel_context:
user_content += f"=== CHANNEL INFO ===\n{channel_context}\n\n"
user_content += f"=== TARGET MESSAGE (analyze THIS message only) ===\n{message}"
async with self._semaphore:
@@ -165,6 +173,7 @@ class LLMClient:
result.setdefault("coherence_flag", "normal")
result.setdefault("note_update", None)
result.setdefault("detected_game", None)
return result
@@ -288,11 +297,16 @@ class LLMClient:
logger.error("LLM image analysis error: %s", e)
return None
async def raw_analyze(self, message: str, context: str = "", user_notes: str = "") -> tuple[str, dict | None]:
async def raw_analyze(
self, message: str, context: str = "", user_notes: str = "",
channel_context: str = "",
) -> tuple[str, dict | None]:
"""Return the raw LLM response string AND parsed result for /bcs-test (single LLM call)."""
user_content = f"=== CONTEXT (other users' recent messages, for background only) ===\n{context}\n\n"
if user_notes:
user_content += f"=== NOTES ABOUT THIS USER (from prior analysis) ===\n{user_notes}\n\n"
if channel_context:
user_content += f"=== CHANNEL INFO ===\n{channel_context}\n\n"
user_content += f"=== TARGET MESSAGE (analyze THIS message only) ===\n{message}"
async with self._semaphore: