diff options
| author | Fuwn <[email protected]> | 2025-09-25 18:49:58 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-25 18:49:58 -0700 |
| commit | bc5701e1be99c4e72843c389660230f8c415460e (patch) | |
| tree | f38337b27069194ddb8e6c45a112c6fdedd7f38a | |
| parent | feat(gateway:aiModeration): Add action skip toggle (diff) | |
| download | umabotdiscord-bc5701e1be99c4e72843c389660230f8c415460e.tar.xz umabotdiscord-bc5701e1be99c4e72843c389660230f8c415460e.zip | |
feat(gateway:aiModeration): Ignore simple message patterns
| -rw-r--r-- | packages/gateway/src/listeners/aiModeration.ts | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/packages/gateway/src/listeners/aiModeration.ts b/packages/gateway/src/listeners/aiModeration.ts index 03087aa..6abc63b 100644 --- a/packages/gateway/src/listeners/aiModeration.ts +++ b/packages/gateway/src/listeners/aiModeration.ts @@ -269,6 +269,57 @@ export const handleAIModeration = (client: Client) => { if (!message.content && message.attachments.size === 0) return; + if (message.content) { + const content = message.content.trim(); + + if (!content) { + console.log(`AI Moderation: Skipping empty/whitespace message`); + + return; + } + + const shortWhitelist = + /^(ok|okay|yes|no|hi|hey|yo|lol|thanks|thx|np|cool)$/i; + + if (content.length < 10 && !shortWhitelist.test(content)) { + console.log( + `AI Moderation: Skipping short message (${content.length} chars): "${content}"`, + ); + + return; + } + + const emojiRegExp = + /^(?:\p{Emoji_Presentation}|\p{Extended_Pictographic}|\s)+$/u; + + if (emojiRegExp.test(content)) { + console.log(`AI Moderation: Skipping emoji-only message: "${content}"`); + + return; + } + + const symbolRegExp = /^[^\p{L}\p{N}\s]+$/u; + + if (symbolRegExp.test(content)) { + console.log( + `AI Moderation: Skipping symbol-only message: "${content}"`, + ); + + return; + } + + const symbolDensity = + content.replace(/[\p{L}\p{N}\s]/gu, "").length / content.length; + + if (symbolDensity > 0.6 && content.length > 3) { + console.log( + `AI Moderation: Skipping textmoji-like message: "${content}"`, + ); + + return; + } + } + if (message.channel.isThread()) { const parentChannel = message.channel.parent; @@ -330,7 +381,10 @@ export const handleAIModeration = (client: Client) => { try { await notificationMessage.delete(); } catch (error) { - console.error("Failed to delete notification message:", error); + console.error( + "Failed to delete notification message:", + error, + ); } }, 10000); } catch (error) { |