LemonChannels.Adapters.WhatsApp.AccessControl (lemon_channels v0.1.0)

View Source

Pure functions for WhatsApp access control.

DM modes: :pairing, :allowlist, :open, :disabled Group modes: :open, :allowlist, :disabled

Summary

Functions

Main entry point. Returns true if the message from jid should be processed. event may contain :mentioned_jids for group mention gating.

Returns true if the DM from jid is allowed based on dm_mode config.

Returns true if jid ends with @s.whatsapp.net (DM JID).

Returns true if the group message from jid is allowed based on group_mode config.

Returns true if jid ends with @g.us (group JID).

Returns true if the phone number from jid is in the config allowlist.

Returns true if the bot must be @mentioned but was not. For groups with mention_gated: true, the bot JID must appear in mentioned_jids.

Extracts the phone number (or group id) from a JID by taking everything before @.

Returns true if jid matches the bot's own JID (self-chat).

Functions

allowed?(config, jid, event)

Main entry point. Returns true if the message from jid should be processed. event may contain :mentioned_jids for group mention gating.

dm_allowed?(config, jid)

Returns true if the DM from jid is allowed based on dm_mode config.

dm_jid?(jid)

Returns true if jid ends with @s.whatsapp.net (DM JID).

group_allowed?(config, jid)

Returns true if the group message from jid is allowed based on group_mode config.

group_jid?(jid)

Returns true if jid ends with @g.us (group JID).

in_allowlist?(config, jid)

Returns true if the phone number from jid is in the config allowlist.

mention_gated?(config, jid, event)

Returns true if the bot must be @mentioned but was not. For groups with mention_gated: true, the bot JID must appear in mentioned_jids.

phone_from_jid(jid)

Extracts the phone number (or group id) from a JID by taking everything before @.

self_chat?(config, jid)

Returns true if jid matches the bot's own JID (self-chat).