import {
buildMentionRegexes,
normalizeMentionText,
} from "openclaw/plugin-sdk/channel-mention-gating"; import type { loadConfig } from "openclaw/plugin-sdk/config-runtime"; import {
getComparableIdentityValues,
getMentionIdentities,
getSelfIdentity,
identitiesOverlap,
type WhatsAppIdentity,
} from "../identity.js"; import { isSelfChatMode, normalizeE164 } from "../text-runtime.js"; import type { WebInboundMsg } from "./types.js";
const hasMentions = targets.normalizedMentions.length > 0; if (hasMentions && !isSelfChat) { for (const mention of targets.normalizedMentions) { if (identitiesOverlap(targets.self, mention)) { returntrue;
}
} // If the message explicitly mentions someone else, do not fall back to regex matches. returnfalse;
} elseif (hasMentions && isSelfChat) { // Self-chat mode: ignore WhatsApp @mention JIDs, otherwise @mentioning the owner in group chats triggers the bot.
} const bodyClean = clean(msg.body); if (mentionCfg.mentionRegexes.some((re) => re.test(bodyClean))) { returntrue;
}
// Fallback: detect body containing our own number (with or without +, spacing) if (targets.self.e164) { const selfDigits = targets.self.e164.replace(/\D/g, ""); if (selfDigits) { const bodyDigits = bodyClean.replace(/[^\d]/g, ""); if (bodyDigits.includes(selfDigits)) { returntrue;
} const bodyNoSpace = msg.body.replace(/[\s-]/g, ""); const pattern = new RegExp(`\\+?${selfDigits}`, "i"); if (pattern.test(bodyNoSpace)) { returntrue;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.