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

Copy Markdown View Source

Community-management helpers mapped from Baileys' communities.ts.

Summary

Functions

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

Accept a v4 invite and emit the same post-join side effects Baileys performs.

Create a new community and return the created metadata when the follow-up metadata fetch succeeds.

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

Fetch all participating communities and optionally emit a groups_update event.

Fetch all linked groups for a community or subgroup JID.

Fetch the metadata associated with an invite code without joining.

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

Fetch the current invite code for a community.

Toggle join-approval mode for a community.

Leave a community.

Link an existing subgroup into a community.

Switch whether only admins or all members can add participants.

Fetch interactive metadata for a community.

Add, remove, promote, or demote participants in a community.

Fetch the pending membership-approval request list for a community.

Approve or reject pending community membership 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 community.

Enable or disable disappearing messages for a community.

Unlink a subgroup from a community.

Update or clear the community description.

Update the subject for an existing community.

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 community 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.

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

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

Create a new community and return the created metadata when the follow-up metadata fetch succeeds.

create_group(conn, subject, participants, parent_community_jid, opts \\ [])

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

Create a linked subgroup inside a community.

extract_metadata(result)

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

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

fetch_all_participating(conn, opts \\ [])

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

Fetch all participating communities and optionally emit a groups_update event.

fetch_linked_groups(conn, jid)

@spec fetch_linked_groups(term(), String.t()) ::
  {:ok,
   %{community_jid: String.t(), is_community: boolean(), linked_groups: [map()]}}
  | {:error, term()}

Fetch all linked groups for a community or subgroup JID.

get_invite_info(conn, code)

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

Fetch the metadata associated with an invite code without joining.

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 community update by refetching communities and cleaning the groups dirty bucket.

invite_code(conn, community_jid)

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

Fetch the current invite code for a community.

join_approval_mode(conn, community_jid, mode)

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

Toggle join-approval mode for a community.

leave(conn, community_jid)

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

Leave a community.

member_add_mode(conn, community_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.

metadata(conn, community_jid, opts \\ [])

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

Fetch interactive metadata for a community.

participants_update(conn, community_jid, jids, action)

@spec participants_update(
  term(),
  String.t(),
  [String.t()],
  :add | :remove | :promote | :demote
) ::
  {:ok, [participant_result()]} | {:error, term()}

Add, remove, promote, or demote participants in a community.

request_participants_list(conn, community_jid)

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

Fetch the pending membership-approval request list for a community.

request_participants_update(conn, community_jid, jids, action)

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

Approve or reject pending community membership requests.

revoke_invite(conn, community_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, community_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, community_jid, setting)

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

Update announcement or locked settings for a community.

toggle_ephemeral(conn, community_jid, expiration)

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

Enable or disable disappearing messages for a community.

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

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

Update or clear the community description.

update_subject(conn, community_jid, subject)

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

Update the subject for an existing community.