-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
Self-chat mode: bot triggers on @mentions of user's own number in groups #34
Description
Hi again,
Clawdis is SO much fun as are the hue & spotify tools. Funny bug: I use self-chat mode for now, and when someone @mentions me in a whatsapp group chat, Clawd responds in my place:
Incredibly Clawd resists various requests and jailbreak attempts by my friends (!), though this does mean that anyone @mentioning me in any group chat I am part of has a direct line to Clawd regardless of config or them knowing about Clawd, so thought I'd raise!
Happens because isBotMentioned() checks if selfE164 is in mentionedJids, but in self-chat mode selfE164 is my own phone number. Fix tested and implemented locally on self-phone mode is to detect self-chat mode (when selfE164 is in allowFrom) and skip JID-based mention detection (see below).
This should preserve two-phone behaviour while fixing this issue for self-chat. Happy to submit a small PR if this looks right!
Thomas
Issue writeup
- Expected: Bot only responds to configured mentionPatterns (e.g., @Clawd), and
- Actual: Bot responds to any @mention of me in whatsapp group chats
- Cause: In two-phone mode, selfE164 is the bot's dedicated number, so this check makes sense. In self-chat mode, selfE164 equals the user's number, so any @mention of the user triggers the bot.
- Proposed fix: Detect self-chat mode (when selfE164 is in allowFrom) and skip JID-based mention detection:
const isSelfChatMode =
msg.selfE164 && allowFrom.some((n) => normalizeE164(n) === msg.selfE164);
if (msg.mentionedJids?.length && !isSelfChatMode) {
// Only check JID mentions in two-phone mode
// ...
}- Notes:
- This should preserve two-phone mode behaviour while fixing self-chat mode.
- Same fix as Self-chat mode: all incoming whatsapps from any sender are marked as read instantly #35 -> if both accepted, could extract into helper
- With this fix, self-chat mode users can still invoke the bot by typing
clawdor@clawdliterally in the message (matched bymentionPatternsregex), just not via WhatsApp's @mention autocomplete.