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

Copy Markdown View Source

Presence helpers aligned with Baileys' presence and chatstate behavior.

Summary

Types

Presence states supported by Baileys.

Parsed presence payload emitted through the event emitter.

Functions

Parse an incoming presence or chatstate node and optionally emit presence_update.

Send a Baileys-compatible presence or chatstate update.

Subscribe to presence updates for a JID, appending a TC token when one exists.

Types

presence()

@type presence() :: :unavailable | :available | :composing | :recording | :paused

Presence states supported by Baileys.

presence_update()

@type presence_update() :: %{
  id: String.t(),
  presences: %{required(String.t()) => map()}
}

Parsed presence payload emitted through the event emitter.

Functions

handle_update(node, opts \\ [])

@spec handle_update(
  BaileysEx.BinaryNode.t(),
  keyword()
) :: {:ok, presence_update()} | :ignore | {:error, :invalid_presence_node}

Parse an incoming presence or chatstate node and optionally emit presence_update.

send_update(sendable, type, to_jid \\ nil, opts \\ [])

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

Send a Baileys-compatible presence or chatstate update.

subscribe(sendable, to_jid, opts \\ [])

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

Subscribe to presence updates for a JID, appending a TC token when one exists.