botlead v0.1.6 Botlead.Bot.Adapter.Telegram

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

Link to this type

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

Link to this type

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

Link to this section Functions

Link to this function

config(key, default \\ nil)
config(atom(), any()) :: any()

Read module config value with default as fallback.

Link to this function

config!(key)
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)
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)
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)
get_updates(integer(), integer()) :: {:ok, [map()]} | :error

Poll all updates from Telegram server.

Link to this function

init()
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 \\ [])
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)
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)
send_message(String.t(), String.t(), pid() | nil, Keyword.t()) :: :ok

Deliver message to Telegram with successful delivery postback.