Skip to content

Self-chat mode: bot triggers on @mentions of user's own number in groups #34

@tmustier

Description

@tmustier

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:

Image

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
       // ...
     }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions