fix: use emoji allowlist instead of length check in pick_reaction
Prevents text words like "skull" from passing the filter and causing Discord HTTPException noise. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -743,6 +743,12 @@ class LLMClient:
|
||||
self._log_llm("classify_intent", elapsed, False, message_text[:200], error=str(e))
|
||||
return "chat"
|
||||
|
||||
_REACTION_EMOJIS = {
|
||||
"\U0001f480", "\U0001f602", "\U0001f440", "\U0001f525",
|
||||
"\U0001f4af", "\U0001f62d", "\U0001f921", "\u2764\ufe0f",
|
||||
"\U0001fae1", "\U0001f913", "\U0001f974", "\U0001f3af",
|
||||
}
|
||||
|
||||
async def pick_reaction(self, message_text: str, channel_name: str) -> str | None:
|
||||
"""Pick a contextual emoji reaction for a Discord message.
|
||||
|
||||
@@ -785,7 +791,7 @@ class LLMClient:
|
||||
raw = (response.choices[0].message.content or "").strip()
|
||||
token = raw.split()[0] if raw.split() else ""
|
||||
|
||||
if not token or token.lower() == "none" or len(token) > 7:
|
||||
if not token or token.lower() == "none" or token not in self._REACTION_EMOJIS:
|
||||
self._log_llm("pick_reaction", elapsed, True, message_text[:200], "NONE")
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user