phpbotgram

PollingOptions
in package

Read onlyYes
FinalYes

Tuning knobs for `Dispatcher::startPolling` — port of the constructor parameters of `aiogram.dispatcher.dispatcher.Dispatcher.start_polling` grouped into a single value object.

Why a DTO instead of mirroring upstream's positional kwargs:

  • start_polling upstream takes 4+ tunables (timeout, backoff config, allowed_updates, handle_as_tasks, plus concurrency limit). Passing them individually leaks the entry-point signature; bundling them lets callers build a config once and reuse it across runPolling and startPolling.
  • The readonly modifier means the polling loop never reads a moving target — a config swap requires building a new PollingOptions and restarting the loop.

Defaults (spec § "Polling loop"):

  • pollingTimeout=10 — long-poll seconds passed to getUpdates. Upstream Dispatcher.start_polling defaults to 10 (the internal _polling helper defaults to 30, but the public entry point is 10, which is what users see).
  • backoffConfig=new BackoffConfig() — matches upstream DEFAULT_BACKOFF_CONFIG = BackoffConfig(1.0, 5.0, 1.3, 0.1).
  • allowedUpdates=Unspecified::instance() — Fix I8 sentinel for "auto-resolve via Router::resolveUsedUpdateTypes() at polling start" (mirrors upstream's UNSET default at dispatcher.py:526). Distinct from null, which remains the explicit "send no allowed_updates key" passthrough so Telegram returns every subscribed type.
  • handleAsTasks=100 — concurrent in-flight updates per bot. Upstream exposes handle_as_tasks: bool (on/off) PLUS tasks_concurrency_limit: int|None (cap). Collapsing into one int|null slot is denser without losing information: null => fully serial (handle_as_tasks=False); int n => concurrent with semaphore of size n (handle_as_tasks=True, tasks_concurrency_limit=n).

Table of Contents

Properties

$allowedUpdates  : null|array<int, string>|Unspecified
Telegram `allowed_updates` parameter, plus the `Unspecified` sentinel for "auto-resolve at polling start". Three legal shapes:
$backoffConfig  : BackoffConfig
$handleAsTasks  : int|null
$pollingTimeout  : int

Methods

__construct()  : mixed

Properties

$allowedUpdates

Telegram `allowed_updates` parameter, plus the `Unspecified` sentinel for "auto-resolve at polling start". Three legal shapes:

public null|array<int, string>|Unspecified $allowedUpdates
  • Unspecified::instance() (default): Dispatcher::startPolling calls Router::resolveUsedUpdateTypes() and substitutes the resulting list<string> before kicking off the per-bot polling fibers. Mirrors upstream dispatcher.py:564-565.
  • null: explicit opt-out — the getUpdates request omits the allowed_updates key, so Telegram returns every subscribed type.
  • list<string>: a caller-curated list; passed through verbatim.

Methods

__construct()

public __construct([int $pollingTimeout = 10 ][, BackoffConfig|null $backoffConfig = null ][, null|array<int, string>|Unspecified $allowedUpdates = new Unspecified() ][, int|null $handleAsTasks = 100 ]) : mixed
Parameters
$pollingTimeout : int = 10

Long-poll seconds for getUpdates. 0 means short-poll (return immediately). Must be >= 0.

$backoffConfig : BackoffConfig|null = null

Retry tuning; null => use new BackoffConfig() (upstream DEFAULT_BACKOFF_CONFIG).

$allowedUpdates : null|array<int, string>|Unspecified = new Unspecified()

Telegram allowed_updates parameter. See $allowedUpdates property docblock for the three legal shapes. Omit the argument to get the Unspecified auto-resolve default (PHP can't use a function call as a default value, so the constructor maps a no-arg call to the sentinel in the body).

$handleAsTasks : int|null = 100

Concurrent in-flight updates per bot. null => fully serial (no fiber spawn); positive int => fiber pool of that size. Must be >= 1 or null.

On this page

Search results