Refactor cross-channel tracking and spam detection

Replace per-case trackers with a unified key-based tracker and tighten detection logic. Introduces buildMessageTrackingKeys/collectTrackableText to canonicalize text, extract invite codes, include image fingerprints and dedupe keys; replaces trackCrossChannelMessage/trackImageOnlySpam with trackCrossChannelKeys that tracks multiple normalized keys. Simplifies detectSpam to use trackable content and invite-aware link handling, updates message preview/attachment embedding, and adjusts command/help text to reflect the new "same content across channels" rule. Overall reduces duplicate-prior merging and streamlines cross-channel spam handling.
This commit is contained in:
2026-06-21 21:38:22 +12:00
parent ef4d2aeb40
commit 024f1082ef
4 changed files with 114 additions and 64 deletions
+8 -7
View File
@@ -63,15 +63,16 @@ export function trackCrossChannelMessage(guildId, userId, channelId, messageId,
return trackCrossChannelPost(guildId, userId, channelId, messageId, normalizeKey(text));
}
export function trackImageOnlySpam(guildId, userId, channelId, messageId, fingerprint) {
const trackers = [trackCrossChannelPost(guildId, userId, channelId, messageId, "imgonly")];
if (fingerprint) {
trackers.push(
trackCrossChannelPost(guildId, userId, channelId, messageId, `imgfp:${fingerprint}`)
);
export function trackCrossChannelKeys(guildId, userId, channelId, messageId, keys) {
const uniqueKeys = [...new Set(keys.map((key) => normalizeKey(key)).filter(Boolean))];
if (uniqueKeys.length === 0) {
return { duplicateAcrossChannels: false, priorMessages: [] };
}
const trackers = uniqueKeys.map((key) =>
trackCrossChannelPost(guildId, userId, channelId, messageId, key)
);
const duplicateAcrossChannels = trackers.some((tracker) => tracker.duplicateAcrossChannels);
const priorMessages = duplicateAcrossChannels
? dedupePriorMessages(trackers.flatMap((tracker) => tracker.priorMessages))