Struct representing a Telegram Message object.
This struct contains all the information about an incoming message, including text, media attachments, sender information, and chat details.
Fields
:message_id- Unique message identifier:from- Sender information (map with string keys):chat- Chat information (map with string keys):date- Message date as Unix timestamp:text- Message text content (nil if not a text message):photo- List of photo sizes (nil if no photo):document- Document attachment (nil if no document):sticker- Sticker (nil if no sticker):video- Video (nil if no video):voice- Voice message (nil if no voice):caption- Caption for media (nil if no caption):message_thread_id- Thread ID for forum chats (nil if not in a thread)
Examples
def handle_message(%Message{text: text, chat: chat}, ctx) do
# Pattern match on message fields
ctx
|> Message.text("You said: #{text}")
|> Message.send(chat["id"])
end
Summary
Functions
Converts a raw Telegram API message map to a Message struct.
Types
@type t() :: %TelegramEx.Types.Message{ caption: String.t() | nil, chat: map(), date: integer(), document: map() | nil, from: map(), message_id: integer(), message_thread_id: integer() | nil, photo: [map()] | nil, sticker: map() | nil, text: String.t() | nil, video: map() | nil, voice: map() | nil }
Message struct type.
Contains all fields from a Telegram message update.
Functions
Converts a raw Telegram API message map to a Message struct.
Parameters
map- Raw message map from Telegram API
Returns
A TelegramEx.Types.Message struct.
Examples
iex> Message.from_map(%{"message_id" => 1, "text" => "Hello", ...})
%TelegramEx.Types.Message{message_id: 1, text: "Hello", ...}