Link Search Menu Expand Document

Constructor: message

Back to constructors index

A message

Attributes:

NameTypeRequiredDescription
outBoolOptionalIs this an outgoing message
mentionedBoolOptionalWhether we were mentioned in this message
media_unreadBoolOptionalWhether there are unread media attachments in this message
silentBoolOptionalWhether this is a silent message (no notification triggered)
postBoolOptionalWhether this is a channel post
from_scheduledBoolOptionalWhether this is a scheduled message
legacyBoolOptionalThis is a legacy message: it has to be refetched with the new layer
edit_hideBoolOptionalWhether the message should be shown as not modified to the user, even if an edit date is present
pinnedBoolOptionalWhether this message is pinned
noforwardsBoolOptionalWhether this message is protected and thus cannot be forwarded; clients should also prevent users from saving attached media (i.e. videos should only be streamed, photos should be kept in RAM, et cetera).
invert_mediaBoolOptionalIf set, any eventual webpage preview will be shown on top of the message instead of at the bottom.
offlineBoolOptional
idintYesID of the message
from_idPeerOptionalID of the sender of the message
from_boosts_appliedintOptional
peer_idPeerYesPeer ID, the chat where this message was sent
saved_peer_idPeerOptionalMessages fetched from a saved messages dialog » will have peer=inputPeerSelf and the saved_peer_id flag set to the ID of the saved dialog.
fwd_fromMessageFwdHeaderOptionalInfo about forwarded messages
via_bot_idlongOptionalID of the inline bot that generated the message
via_business_bot_idlongOptional
reply_toMessageReplyHeaderOptionalReply information
dateintYesDate of the message
messagestringYesThe message
mediaMessageMediaOptionalMedia attachment
reply_markupReplyMarkupOptionalReply markup (bot/inline keyboards)
entitiesArray of MessageEntityOptionalMessage entities for styled text
parse_modestringWhether to parse HTML or Markdown markup in the messageOptional
viewsintOptionalView count for channel posts
forwardsintOptionalForward counter
repliesMessageRepliesOptionalInfo about post comments (for channels) or message replies (for groups)
edit_dateintOptionalLast edit date of this message
post_authorstringOptionalName of the author of this message for channel posts (with signatures enabled)
grouped_idlongOptionalMultiple media messages sent using messages.sendMultiMedia with the same grouped ID indicate an album or media group
reactionsMessageReactionsOptionalReactions to this message
restriction_reasonArray of RestrictionReasonOptionalContains the reason why access to this message must be restricted.
ttl_periodintOptionalTime To Live of the message, once message.date+message.ttl_period === time(), the message will be deleted on the server, and must be deleted locally as well.
quick_reply_shortcut_idintOptional

Type: Message

Usage of parse_mode:

Set parse_mode to html to enable HTML parsing of the message.

Set parse_mode to Markdown to enable markdown parsing of the message.

The following tags are currently supported:

<br>a newline
<b><i>bold works ok, internal tags are stripped</i> </b>
<strong>bold</strong>
<em>italic</em>
<i>italic</i>
<u>underline</u>
<s>strikethrough</s>
<del>strikethrough</del>
<strike>strikethrough</strike>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<blockquote>pre-formatted fixed-width code block</blockquote>
<a href="https://github.com">URL</a>
<a href="mention:@danogentili">Mention by username</a>
<a href="mention:186785362">Mention by user id</a>
<a href="tg://user?id=186785362">Mention by user id</a>
Custom emoji: <emoji id="5368324170671202286">👍</emoji>
Custom emoji: <tg-emoji emoji-id="5368324170671202286">👍</tg-emoji>
<pre language="json">Pre tags can have a language attribute</pre>
<spoiler>Spoiler</spoiler>
<tg-spoiler>Spoiler</tg-spoiler>

You can also use normal markdown (bot API MarkdownV2 syntax), note that to create mentions you can also use the mention: syntax like in html:

*bold \*text*
_italic \*text_
__underline__
~strikethrough~
||spoiler||
*bold _italic bold ~italic bold strikethrough ||italic bold strikethrough spoiler||~ __underline italic bold___ bold*
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
![👍](tg://emoji?id=5368324170671202286)
\`inline fixed-width code\`
\`\`\`
pre-formatted fixed-width code block
\`\`\`
\`\`\`php
pre-formatted fixed-width code block written in the PHP programming language
\`\`\`

[Mention by username](mention:@danogentili)
[Mention by user id](mention:186785362)
[Mention by user id](tg://user?id=186785362)
[👍](emoji:5368324170671202286)
[👍](tg://emoji?id=5368324170671202286)

Example:

$message = ['_' => 'message', 'out' => Bool, 'mentioned' => Bool, 'media_unread' => Bool, 'silent' => Bool, 'post' => Bool, 'from_scheduled' => Bool, 'legacy' => Bool, 'edit_hide' => Bool, 'pinned' => Bool, 'noforwards' => Bool, 'invert_media' => Bool, 'offline' => Bool, 'id' => int, 'from_id' => Peer, 'from_boosts_applied' => int, 'peer_id' => Peer, 'saved_peer_id' => Peer, 'fwd_from' => MessageFwdHeader, 'via_bot_id' => long, 'via_business_bot_id' => long, 'reply_to' => MessageReplyHeader, 'date' => int, 'message' => 'string', 'media' => MessageMedia, 'reply_markup' => ReplyMarkup, 'entities' => [MessageEntity, MessageEntity]parse_mode: 'string', , 'views' => int, 'forwards' => int, 'replies' => MessageReplies, 'edit_date' => int, 'post_author' => 'string', 'grouped_id' => long, 'reactions' => MessageReactions, 'restriction_reason' => [RestrictionReason, RestrictionReason], 'ttl_period' => int, 'quick_reply_shortcut_id' => int];