Botlead.Bot.Adapter.Telegram (botlead v0.2.4)

Implementation business logic for Bot server for Telegram platform.

Link to this section Summary

Functions

Read module config value with default as fallback.

Read module config value, raise if not configured.

Delete existing message by it's id.

Poll all updates from Telegram server.

Start Telegram process either by webhook or with periodical config.

Create Nadia client option specification for message response.

Parse messages recieved from Telegram server.

Deliver message to Telegram with successful delivery postback.

Link to this section Types

Specs

cmd() ::
  {:relay_msg_to_client, String.t(), map()} | {:restart_client, String.t()}
Link to this type

parsed_message()

Specs

parsed_message() :: :no_parser | :invalid_message | cmd()

Link to this section Functions

Link to this function

config(key, default \\ nil)

Specs

config(atom(), any()) :: any()

Read module config value with default as fallback.

Specs

config!(atom()) :: any() | no_return()

Read module config value, raise if not configured.

Link to this function

delete_message(chat_id, message_id, client_pid, opts)

Specs

delete_message(String.t(), String.t(), pid() | nil, Keyword.t()) :: :ok

Delete existing message by it's id.

Link to this function

edit_message(chat_id, message_id, text, client_pid, opts)

Specs

edit_message(String.t(), String.t(), String.t(), pid() | nil, Keyword.t()) ::
  :ok

Edit existing message by it's id.

Link to this function

get_updates(last_update, poll_limit)

Specs

get_updates(integer(), integer()) :: {:ok, [map()]} | :error

Poll all updates from Telegram server.

Specs

init() :: :ok | {:poll, integer(), integer()}

Start Telegram process either by webhook or with periodical config.

Link to this function

msg_to_opts(msg, msg_opts \\ [])

Specs

msg_to_opts(
  %Botlead.Message{
    content: term(),
    inline_keyboard: term(),
    parse_mode: term()
  },
  Keyword.t()
) :: Keyword.t()

Create Nadia client option specification for message response.

Link to this function

process_messages(messages, old_message_ids)

Specs

process_messages([map()], [integer()]) ::
  {:ok, [integer()], integer(), [parsed_message()]}

Parse messages recieved from Telegram server.

Link to this function

send_message(chat_id, text, client_pid, opts)

Specs

send_message(String.t() | integer(), String.t(), pid() | nil, Keyword.t()) ::
  :ok

Deliver message to Telegram with successful delivery postback.