BotexTelegram.Services.Telegram.Api (botex_telegram v2.0.1)

The main api for working with a telegram.

Summary

Functions

Edit existing telegram message

Retrieves chat id from telegram message

gather data from message or callback

Retrieves message id from telegram message

Function retrieves user from telegram message

Send new or existing image to user or chat

Sends a message with buttons markup

Breaks the text into parts according to the specified separator and sends messages to the user

Functions

edit_message(msg, text, buttons)

@spec edit_message(
  Telegex.Type.CallbackQuery.t() | Telegex.Type.Message.t(),
  binary(),
  list()
) :: {:error, Telegex.Error.t()} | {:ok, Telegex.Type.Message.t()}

Edit existing telegram message

Parameters

  • telegram message
  • text: new text
  • buttons: new buttons

get_chat_id(arg1)

Retrieves chat id from telegram message

Parameters

  • msg: telegram message

get_date_time(arg1)

gather data from message or callback

get_message_id(arg1)

Retrieves message id from telegram message

get_user(arg1)

Function retrieves user from telegram message

Parameters

  • msg: telegram message

send_message(msg, chat_id, parse_mode \\ "MarkdownV2", markup \\ %{})

Sends a message

Parameters

  • msg: message text
  • chat_id: chat or user id
  • parse_mode: message processing mode for telegram "Markdown", "MarkdownV2" or "HTML"
  • markup: additional marking of the message, buttons, etc.

send_photo(file, chat_id)

@spec send_photo(nil | binary(), integer()) ::
  {:error, Telegex.Error.t()} | {:ok, binary() | Telegex.Type.Message.t()}

Send new or existing image to user or chat

Parameters

  • file: file path for new photo or id telegram file
  • chat_id: user or chat id

send_with_buttons(msg, chat_id, buttons)

@spec send_with_buttons(binary(), integer(), [
  [%{callback_data: binary(), text: binary()}, ...],
  ...
]) ::
  {:error, Telegex.Error.t()} | {:ok, Telegex.Type.Message.t()}

Sends a message with buttons markup

split_and_send(str, chat_id, delimiter \\ "\n", remove_delimiters? \\ false, limit \\ 4000)

@spec split_and_send(binary(), integer(), binary(), boolean(), non_neg_integer()) ::
  :ok

Breaks the text into parts according to the specified separator and sends messages to the user

Parameters

  • msg: message text

  • chat_id: chat or user id

  • delimiter: delimiter for message split, default -

  • remove_delimiters: remove delimiters from original message

  • limit: max length one message (telegram allow max 4096 symbols)