BaileysEx.Connection.Config (baileys_ex v0.1.0-alpha.7)

Copy Markdown View Source

Connection configuration defaults and platform mapping.

print_qr_in_terminal remains only as a compatibility knob with Baileys rc.9. It is deprecated and does not print QR codes automatically; consumers should handle connection.update.qr themselves.

Summary

Functions

Default logic to determine if a history sync message should be processed. By default, only non-FULL syncs are processed inline.

Returns the numeric device property platform type for a given browser string. Defaults to 1 (CHROME) if missing.

Create a new Config with default options. Accepts a keyword list of overrides.

Returns the effective initial QR timeout, honoring the Baileys-style single override when configured.

Returns the effective QR refresh timeout, honoring the Baileys-style single override when configured.

Returns the platform ID block identifier for device properties based on browser name.

Returns the internal platform symbol for a given browser name string. Returns :UNKNOWN if the browser name is not recognized.

Returns whether the runtime should auto-reconnect for the given disconnect reason and upcoming retry attempt.

Returns the numeric sub-platform ID for web client features (e.g. Mac/Windows).

Types

browser()

@type browser() :: {String.t(), String.t(), String.t()}

cached_group_metadata_fun()

@type cached_group_metadata_fun() :: (String.t() -> map() | {:ok, map()} | nil)

platform()

@type platform() ::
  :CHROME
  | :FIREFOX
  | :SAFARI
  | :EDGE
  | :OPERA
  | :DESKTOP
  | :DARWIN
  | :WIN32
  | :LINUX
  | :UNKNOWN

reconnect_policy()

@type reconnect_policy() :: :disabled | :restart_required | :all_non_logged_out

should_sync_history_message_fun()

@type should_sync_history_message_fun() :: (map() -> boolean())

t()

@type t() :: %BaileysEx.Connection.Config{
  browser: browser(),
  cached_group_metadata: cached_group_metadata_fun() | nil,
  connect_timeout_ms: pos_integer(),
  country_code: String.t(),
  default_query_timeout_ms: pos_integer(),
  enable_auto_session_recreation: boolean(),
  enable_recent_message_cache: boolean(),
  fire_init_queries: boolean(),
  initial_sync_timeout_ms: pos_integer(),
  keep_alive_interval_ms: pos_integer(),
  mark_online_on_connect: boolean(),
  max_msg_retry_count: pos_integer(),
  max_retries: non_neg_integer(),
  pairing_qr_initial_timeout_ms: pos_integer(),
  pairing_qr_refresh_timeout_ms: pos_integer(),
  pairing_qr_timeout_ms: pos_integer() | nil,
  print_qr_in_terminal: boolean(),
  reconnect_policy: reconnect_policy(),
  retry_delay_ms: pos_integer(),
  retry_request_delay_ms: pos_integer(),
  should_sync_history_message: should_sync_history_message_fun(),
  sync_full_history: boolean(),
  validate_patch_macs: boolean(),
  validate_snapshot_macs: boolean(),
  version: version(),
  ws_url: String.t()
}

version()

@type version() :: [non_neg_integer()]

Functions

default_should_sync_history_message(history_message)

@spec default_should_sync_history_message(map()) :: boolean()

Default logic to determine if a history sync message should be processed. By default, only non-FULL syncs are processed inline.

device_props_platform_type(browser_name)

@spec device_props_platform_type(String.t()) :: non_neg_integer()

Returns the numeric device property platform type for a given browser string. Defaults to 1 (CHROME) if missing.

new(opts \\ [])

@spec new(keyword()) :: t()

Create a new Config with default options. Accepts a keyword list of overrides.

pairing_qr_initial_timeout(config)

@spec pairing_qr_initial_timeout(t()) :: pos_integer()

Returns the effective initial QR timeout, honoring the Baileys-style single override when configured.

pairing_qr_refresh_timeout(config)

@spec pairing_qr_refresh_timeout(t()) :: pos_integer()

Returns the effective QR refresh timeout, honoring the Baileys-style single override when configured.

platform_id(browser_name)

@spec platform_id(String.t()) :: String.t()

Returns the platform ID block identifier for device properties based on browser name.

platform_type(browser_name)

@spec platform_type(String.t()) :: platform()

Returns the internal platform symbol for a given browser name string. Returns :UNKNOWN if the browser name is not recognized.

should_reconnect?(config, arg2, attempt)

@spec should_reconnect?(t(), term(), non_neg_integer()) :: boolean()

Returns whether the runtime should auto-reconnect for the given disconnect reason and upcoming retry attempt.

web_sub_platform(config)

@spec web_sub_platform(t()) :: non_neg_integer()

Returns the numeric sub-platform ID for web client features (e.g. Mac/Windows).