PhoenixKit.Integrations.Telegram.SiteBot (phoenix_kit v2.62.2)

Copy Markdown View Source

The website's Telegram bot for user notifications: one website-wide Telegram connection (Settings → Integrations), chosen by the admin, that delivers to every user who linked their chat to it (Telegram.Linking).

The choice is the telegram_notifications_connection setting — the uuid of a :system Telegram connection. Empty means off, which is the default: a site that never opts in keeps today's behaviour (personal bots only).

connection_uuid/0 returns the uuid only while it still names an existing website Telegram connection, so deleting or replacing the connection turns the feature off instead of leaving a dangling reference.

Summary

Functions

The bot's @username (without the @), or nil when it cannot be told. Read from the last connection test; asks Telegram when that never ran.

Stops delivering user notifications through the website bot.

The site bot's connection uuid, or nil when off or no longer valid.

Makes uuid — a website Telegram connection — the one that delivers user notifications. There is one: choosing another replaces it, because a bot's updates can be read by one reader only.

Whether uuid is the connection chosen for user notifications.

Whether the website bot has a webhook. Linking reads the bot's updates with getUpdates, which Telegram refuses on a bot that has one.

Functions

bot_username(uuid)

@spec bot_username(String.t()) :: String.t() | nil

The bot's @username (without the @), or nil when it cannot be told. Read from the last connection test; asks Telegram when that never ran.

clear(opts \\ [])

@spec clear(keyword()) :: :ok | {:error, term()}

Stops delivering user notifications through the website bot.

connection_uuid()

@spec connection_uuid() :: String.t() | nil

The site bot's connection uuid, or nil when off or no longer valid.

select(uuid, opts \\ [])

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

Makes uuid — a website Telegram connection — the one that delivers user notifications. There is one: choosing another replaces it, because a bot's updates can be read by one reader only.

selected?(uuid)

@spec selected?(String.t()) :: boolean()

Whether uuid is the connection chosen for user notifications.

webhook_set?(uuid)

@spec webhook_set?(String.t()) :: boolean()

Whether the website bot has a webhook. Linking reads the bot's updates with getUpdates, which Telegram refuses on a bot that has one.