BaileysEx.Feature.Group (baileys_ex v0.1.0-alpha.7)

Copy Markdown View Source

Group-management helpers mapped from Baileys' groups.ts.

Summary

Functions

Accept a legacy invite code and return the joined group JID.

Accept a v4 invite and emit the same post-join side effects Baileys performs when callback options are provided.

Add participants to a group.

Create a new group and return the parsed group metadata.

Demote participants from admins.

Extract Baileys-aligned group metadata from a group IQ result node.

Fetch all participating groups and optionally emit groups_update.

Resolve invite metadata for a code without joining.

Fetch interactive metadata for a group.

Handle a dirty group/community update by refetching groups and cleaning the bucket.

Fetch the current invite code for a group.

Toggle join-approval mode for a group.

Leave a group.

Switch whether only admins or all members can add participants.

Promote participants to admins.

Remove participants from a group.

Fetch the pending join-request list for a group.

Approve or reject pending join requests.

Revoke the current invite code and return the new one.

Revoke a v4 invite for a specific invited user.

Update announcement or locked settings for a group.

Enable or disable disappearing messages for a group.

Update or clear the group description.

Set a custom label on a group member via the GROUP_MEMBER_LABEL_CHANGE protocol message.

Update the subject for an existing group.

Types

participant_result()

@type participant_result() :: %{
  :jid => String.t(),
  :status => String.t(),
  optional(:content) => BaileysEx.BinaryNode.t()
}

Functions

accept_invite(conn, code)

@spec accept_invite(term(), String.t()) :: {:ok, String.t() | nil} | {:error, term()}

Accept a legacy invite code and return the joined group JID.

accept_invite_v4(conn, key, invite_message, opts \\ [])

@spec accept_invite_v4(term(), String.t() | map(), map(), keyword()) ::
  {:ok, String.t() | nil} | {:error, term()}

Accept a v4 invite and emit the same post-join side effects Baileys performs when callback options are provided.

add_participants(conn, group_jid, jids)

@spec add_participants(term(), String.t(), [String.t()]) ::
  {:ok, [participant_result()]} | {:error, term()}

Add participants to a group.

create(conn, subject, participants, opts \\ [])

@spec create(term(), String.t(), [String.t()], keyword()) ::
  {:ok, map()} | {:error, term()}

Create a new group and return the parsed group metadata.

demote_participants(conn, group_jid, jids)

@spec demote_participants(term(), String.t(), [String.t()]) ::
  {:ok, [participant_result()]} | {:error, term()}

Demote participants from admins.

extract_group_metadata(result)

@spec extract_group_metadata(BaileysEx.BinaryNode.t()) :: map()

Extract Baileys-aligned group metadata from a group IQ result node.

fetch_all_participating(conn, opts \\ [])

@spec fetch_all_participating(
  term(),
  keyword()
) :: {:ok, %{required(String.t()) => map()}} | {:error, term()}

Fetch all participating groups and optionally emit groups_update.

get_invite_info(conn, code)

@spec get_invite_info(term(), String.t()) :: {:ok, map()} | {:error, term()}

Resolve invite metadata for a code without joining.

get_metadata(conn, group_jid, opts \\ [])

@spec get_metadata(term(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}

Fetch interactive metadata for a group.

handle_dirty_update(conn, dirty_update, opts \\ [])

@spec handle_dirty_update(term(), %{type: String.t()}, keyword()) ::
  {:ok, %{required(String.t()) => map()}} | :ignore | {:error, term()}

Handle a dirty group/community update by refetching groups and cleaning the bucket.

invite_code(conn, group_jid)

@spec invite_code(term(), String.t()) :: {:ok, String.t() | nil} | {:error, term()}

Fetch the current invite code for a group.

join_approval_mode(conn, group_jid, mode)

@spec join_approval_mode(term(), String.t(), :on | :off) :: :ok | {:error, term()}

Toggle join-approval mode for a group.

leave(conn, group_jid)

@spec leave(term(), String.t()) :: :ok | {:error, term()}

Leave a group.

member_add_mode(conn, group_jid, mode)

@spec member_add_mode(term(), String.t(), :admin_add | :all_member_add) ::
  :ok | {:error, term()}

Switch whether only admins or all members can add participants.

promote_participants(conn, group_jid, jids)

@spec promote_participants(term(), String.t(), [String.t()]) ::
  {:ok, [participant_result()]} | {:error, term()}

Promote participants to admins.

remove_participants(conn, group_jid, jids)

@spec remove_participants(term(), String.t(), [String.t()]) ::
  {:ok, [participant_result()]} | {:error, term()}

Remove participants from a group.

request_participants_list(conn, group_jid)

@spec request_participants_list(term(), String.t()) ::
  {:ok, [map()]} | {:error, term()}

Fetch the pending join-request list for a group.

request_participants_update(conn, group_jid, jids, action)

@spec request_participants_update(
  term(),
  String.t(),
  [String.t()],
  :approve | :reject
) ::
  {:ok, [participant_result()]} | {:error, term()}

Approve or reject pending join requests.

revoke_invite(conn, group_jid)

@spec revoke_invite(term(), String.t()) :: {:ok, String.t() | nil} | {:error, term()}

Revoke the current invite code and return the new one.

revoke_invite_v4(conn, group_jid, invited_jid)

@spec revoke_invite_v4(term(), String.t(), String.t()) :: :ok | {:error, term()}

Revoke a v4 invite for a specific invited user.

setting_update(conn, group_jid, setting)

@spec setting_update(
  term(),
  String.t(),
  :announcement | :not_announcement | :locked | :unlocked
) :: :ok | {:error, term()}

Update announcement or locked settings for a group.

toggle_ephemeral(conn, group_jid, expiration)

@spec toggle_ephemeral(term(), String.t(), non_neg_integer()) ::
  :ok | {:error, term()}

Enable or disable disappearing messages for a group.

update_description(conn, group_jid, description, opts \\ [])

@spec update_description(term(), String.t(), String.t() | nil, keyword()) ::
  :ok | {:error, term()}

Update or clear the group description.

update_member_label(context, group_jid, member_label, opts \\ [])

@spec update_member_label(map(), String.t(), String.t(), keyword()) ::
  {:ok, BaileysEx.Message.Sender.send_result(),
   BaileysEx.Message.Sender.context()}
  | {:error, term()}

Set a custom label on a group member via the GROUP_MEMBER_LABEL_CHANGE protocol message.

update_subject(conn, group_jid, subject)

@spec update_subject(term(), String.t(), String.t()) :: :ok | {:error, term()}

Update the subject for an existing group.