Message
This object represents a message.
📝 Schema
Field | Type | Description |
---|---|---|
message_id | int | Unique message identifier inside this chat. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent |
from | User | Optional. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats |
date | int | Date the message was sent in Unix time. It is always a positive number, representing a valid date. |
chat | Chat | Chat the message belongs to |
forward_from | User | Optional. For forwarded messages, sender of the original message. |
forward_from_chat | Chat | Optional. For messages forwarded from a channel, information about the original channel. |
forward_from_message_id | int | Optional. For forwarded channel posts, identifier of the original message in the channel. |
forward_date | int | Optional. For forwarded messages, date the original message was sent in Unix time. |
reply_to_message | Message | Optional. For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. |
edite_date | int | Optional. Date the message was last edited in Unix time. |
text | string | Optional. For text messages, the actual UTF-8 text of the message |
animation | Animation | Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set |
audio | Audio | Optional. Message is an audio file, information about the file |
document | Document | Optional. Message is a general file, information about the file |
photo | Array of PhotoSize | Optional. Message is a photo, available sizes of the photo |
sticker | Sticker | Optional. Message is a sticker, information about the sticker |
video | Video | Optional. Message is a video, information about the video |
voice | Voice | Optional. Message is a voice message, information about the file |
caption | string | Optional. Caption for the animation, audio, document, photo, video or voice |
contact | Contact | Optional. Message is a shared contact, information about the contact |
location | Location | Optional. Message is a shared location, information about the location |
new_chat_members | Array of User | Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) |
left_chat_member | User | Optional. A member was removed from the group, information about them (this member may be the bot itself) |
invoice | Invoice | Optional. Message is an invoice for a payment, information about the invoice. More about payments » |
successful_payment | SuccessfulPayment | Optional. Message is a service message about a successful payment, information about the payment. More about payments » |
reply_markup | InlineKeyboardMarkup | Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. |
⚙️ Get methods
getMessageId()
Retrieves the unique identifier of the message.
$messageMessageId = $messageObject->getMessageId();
getFrom()
Retrieves the sender of the message.
$messageFrom = $messageObject->getFrom();
getDate()
Retrieves the date the message was sent in Unix time.
$messageDate = $messageObject->getDate();
getChat()
Retrieves the chat the message belongs to.
$messageChat = $messageObject->getChat();
getForwardFrom()
Retrieves the sender of the original message, if this is a forwarded message.
$messageForwardFrom = $messageObject->getForwardFrom();
getForwardFromChat()
Retrieves the channel from which the message was forwarded, if applicable.
$messageForwardFromChat = $messageObject->getForwardFromChat();
getForwardFromMessageId()
Retrieves the original message ID in the channel for forwarded messages.
$messageForwardFromMessageId = $messageObject->getForwardFromMessageId();
getForwardDate()
Retrieves the Unix timestamp when the original message was sent.
$messageForwardDate = $messageObject->getForwardDate();
getReplyToMessage()
Retrieves the original message that this message is replying to.
$messageReplyTo = $messageObject->getReplyToMessage();
getEditDate()
Retrieves the last edit time of the message in Unix time.
$messageEditDate = $messageObject->getEditDate();
getText()
Retrieves the text content of the message, if available.
$messageText = $messageObject->getText();
getAnimation()
Retrieves details of the animation, if the message contains one.
$messageAnimation = $messageObject->getAnimation();
getAudio()
Retrieves details of the audio, if the message contains one.
$messageAudio = $messageObject->getAudio();
getDocument()
Retrieves details of the document, if the message contains one.
$messageDocument = $messageObject->getDocument();
getPhoto()
Retrieves the array of photo sizes, if the message contains a photo.
$messagePhoto = $messageObject->getPhoto();
getSticker()
Retrieves details of the sticker, if the message contains one.
$messageSticker = $messageObject->getSticker();
getVideo()
Retrieves details of the video, if the message contains one.
$messageVideo = $messageObject->getVideo();
getVoice()
Retrieves details of the voice message, if the message contains one.
$messageVoice = $messageObject->getVoice();
getCaption()
Retrieves the caption of the media, if available.
$messageCaption = $messageObject->getCaption();
getContact()
Retrieves details of the contact, if the message contains one.
$messageContact = $messageObject->getContact();
getLocation()
Retrieves details of the location, if the message contains one.
$messageLocation = $messageObject->getLocation();
getNewChatMembers()
Retrieves an array of new chat members added to the group or supergroup.
$newChatMembers = $messageObject->getNewChatMembers();
getLeftChatMember()
Retrieves details of the member who left or was removed from the chat.
$leftChatMember = $messageObject->getLeftChatMember();
getInvoice()
Retrieves details of the invoice, if the message contains one.
$messageInvoice = $messageObject->getInvoice();
getSuccessfulPayment()
Retrieves details of a successful payment message.
$successfulPayment = $messageObject->getSuccessfulPayment();
getReplyMarkup()
Retrieves the inline keyboard attached to the message, if available.
$replyMarkup = $messageObject->getReplyMarkup();
➕ More
For further information, refer to the official Bale documentation for more details.