AbstractConstructs a new BaseBotClient.
Telegram bot token received from BotFather. Must follow format <bot_id>:<secret_token>.
Configuration options for the client including custom fetch or local API server URL.
Protected Readonly_Internal fetch adapter instance used for HTTP dispatch.
Optionalinit: RequestInitOptionalinit: RequestInitReadonlyapiBase endpoint URL of the Telegram Bot API server.
Protected Optional ReadonlybaseOptional base delay in milliseconds used for retry calculations.
ReadonlyoptionsClient configuration options.
Protected ReadonlyrequestDefault per-request abort timeout in milliseconds.
ReadonlytokenSecret Telegram Bot API token received from BotFather.
Dynamically configures or updates the auto-retry and flood control settings.
Partial retry options to update.
This client instance for chaining.
Registers an observer invoked whenever a Bot API request finally fails.
Hooks run in registration order right before the TelegramApiError is thrown, after retries are exhausted. Observers cannot alter the error; exceptions inside a hook are swallowed and logged. Useful for alerting and metrics plugins.
Callback receiving the method name and the final error.
Optionaltag: string
Optional owner tag for grouped removal via BaseBotClient.removeHooksByTag.
This client instance for chaining.
Core request dispatcher to execute any raw Telegram Bot API endpoint.
Automatically serializes JSON objects or multipart FormData when file buffers / InputFile are present.
Handles HTTP 429 rate-limiting (honoring retry_after) and HTTP 5xx retries with exponential
backoff, sharing a single retry budget across both so that repeated 429s cannot retry forever
or starve genuine 5xx retries.
The expected return payload type from Telegram.
The Bot API method name (e.g. "sendMessage", "getMe", "setWebhook").
Key-value parameters corresponding to the API method fields.
Resolves with the unwrapped result field returned by Telegram.
TelegramApiError When Telegram returns ok: false, HTTP 4xx, or after retry exhaustion on 429/5xx/network errors.
Helper utility to pause asynchronous execution for a given number of seconds.
Used internally during retry delays and rate-limit backoff.
Duration in seconds to pause execution.
Promise that resolves once the specified duration elapses.
Registers a hook invoked before every outgoing Bot API request.
Hooks run in registration order and may mutate the payload. Intended for plugins that need to observe or decorate all API traffic (logging, metrics, throttling signals, test mocks).
Callback receiving the method name and the mutable payload.
Optionaltag: string
Optional owner tag; all hooks sharing a tag can be removed together via BaseBotClient.removeHooksByTag.
This client instance for chaining.
Registers a hook invoked with every successful Bot API response.
Hooks run in registration order. Returning a value replaces the result for subsequent hooks
and the caller; returning undefined keeps it unchanged. Useful for response logging,
caching, or normalization plugins.
Callback receiving the method name and the unwrapped result.
Optionaltag: string
Optional owner tag for grouped removal via BaseBotClient.removeHooksByTag.
This client instance for chaining.
Core HTTP dispatcher and credential manager for all Telegram Bot API operations.
Implements automated rate-limit backoff (HTTP 429
retry_after), exponential backoff for server errors (HTTP 5xx), payload serialization (JSON or multipartFormData), and uniform error unwrapping into TelegramApiError.