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

Implementation business logic for Bot server for Telegram platform.

Summary

Functions

Returns a specification to start this module under a supervisor.

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.

Create Telegex client option specification for message response.

Parse messages recieved from Telegram server.

Deliver message to Telegram with successful delivery postback.

Types

cmd()

@type cmd() ::
  {:relay_msg_to_client, String.t(), map()} | {:restart_client, String.t()}

parsed_message()

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

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

config(key, default \\ nil)

@spec config(atom(), any()) :: any()

Read module config value with default as fallback.

config!(key)

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

Read module config value, raise if not configured.

delete_message(chat_id, message_id, client_pid, opts)

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

Delete existing message by it's id.

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

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

Edit existing message by it's id.

get_updates(last_update, poll_limit)

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

Poll all updates from Telegram server.

msg_to_opts(msg, msg_opts \\ [])

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

Create Telegex client option specification for message response.

process_messages(messages, old_message_ids)

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

Parse messages recieved from Telegram server.

send_message(chat_id, text, client_pid, opts)

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

Deliver message to Telegram with successful delivery postback.

start_link(opts \\ [])