Noizu.Telegram.Webhook (Noizu Telegram v0.1.0)

Copy Markdown View Source

Webhook management and inbound verification.

  • set/2 / delete/0 manage the bot's webhook registration.
  • valid_secret?/2 verifies the X-Telegram-Bot-Api-Secret-Token header against the expected secret with a constant-time comparison.

Secret tokens are never logged: set/2 redacts them from any error text.

Summary

Functions

Bot API deleteWebhook.

Header name used for the webhook secret (X-Telegram-Bot-Api-Secret-Token).

Bot API setWebhook.

Verify the X-Telegram-Bot-Api-Secret-Token header value against the expected secret, in constant time. Either side nil ⇒ false.

Functions

delete(opts \\ [])

@spec delete(keyword()) :: {:ok, true} | {:error, Noizu.Telegram.Error.t()}

Bot API deleteWebhook.

secret_header()

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

Header name used for the webhook secret (X-Telegram-Bot-Api-Secret-Token).

set(url, opts \\ [])

@spec set(String.t(), keyword()) :: {:ok, true} | {:error, Noizu.Telegram.Error.t()}

Bot API setWebhook.

Opts: :secret_token (header value Telegram echoes back), :allowed_updates, :drop_pending_updates, :max_connections, :certificate.

valid_secret?(expected, provided)

@spec valid_secret?(String.t() | nil, String.t() | nil) :: boolean()

Verify the X-Telegram-Bot-Api-Secret-Token header value against the expected secret, in constant time. Either side nil ⇒ false.