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
@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
@spec get_chat_id( Telegex.Type.CallbackQuery.t() | Telegex.Type.Message.t() | Telegex.Type.PreCheckoutQuery.t() ) :: integer()
Retrieves chat id from telegram message
Parameters
- msg: telegram message
@spec get_date_time( Telegex.Type.CallbackQuery.t() | Telegex.Type.Message.t() | Telegex.Type.PreCheckoutQuery.t() | nil ) :: DateTime.t() | nil
gather data from message or callback
@spec get_message_id( Telegex.Type.CallbackQuery.t() | Telegex.Type.Message.t() | Telegex.Type.PreCheckoutQuery.t() ) :: integer()
Retrieves message id from telegram message
@spec get_user( Telegex.Type.CallbackQuery.t() | Telegex.Type.Message.t() | Telegex.Type.PreCheckoutQuery.t() ) :: Telegex.Type.User.t() | %{}
Function retrieves user from telegram message
Parameters
- msg: telegram message
@spec send_message( binary(), integer(), String.t(), map() | Telegex.Type.ReplyKeyboardMarkup.t() | Telegex.Type.ForceReply.t() ) :: {:error, Telegex.Error.t()} | {:ok, Telegex.Type.Message.t()}
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.
@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
@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
@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)