2024-05-01 14:53:46 +02:00

7.8 KiB

title description nav_exclude image
message A message true https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png

Constructor: message

Back to constructors index

A message

Attributes:

Name Type Required Description
out Bool Optional Is this an outgoing message
mentioned Bool Optional Whether we were mentioned in this message
media_unread Bool Optional Whether there are unread media attachments in this message
silent Bool Optional Whether this is a silent message (no notification triggered)
post Bool Optional Whether this is a channel post
from_scheduled Bool Optional Whether this is a scheduled message
legacy Bool Optional This is a legacy message: it has to be refetched with the new layer
edit_hide Bool Optional Whether the message should be shown as not modified to the user, even if an edit date is present
pinned Bool Optional Whether this message is pinned
noforwards Bool Optional Whether 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_media Bool Optional If set, any eventual webpage preview will be shown on top of the message instead of at the bottom.
offline Bool Optional
id int Yes ID of the message
from_id Peer Optional ID of the sender of the message
from_boosts_applied int Optional
peer_id Peer Yes Peer ID, the chat where this message was sent
saved_peer_id Peer Optional Messages 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_from MessageFwdHeader Optional Info about forwarded messages
via_bot_id long Optional ID of the inline bot that generated the message
via_business_bot_id long Optional
reply_to MessageReplyHeader Optional Reply information
date int Yes Date of the message
message string Yes The message
media MessageMedia Optional Media attachment
reply_markup ReplyMarkup Optional Reply markup (bot/inline keyboards)
entities Array of MessageEntity Optional Message entities for styled text
parse_mode string Whether to parse HTML or Markdown markup in the message Optional
views int Optional View count for channel posts
forwards int Optional Forward counter
replies MessageReplies Optional Info about post comments (for channels) or message replies (for groups)
edit_date int Optional Last edit date of this message
post_author string Optional Name of the author of this message for channel posts (with signatures enabled)
grouped_id long Optional Multiple media messages sent using messages.sendMultiMedia with the same grouped ID indicate an album or media group
reactions MessageReactions Optional Reactions to this message
restriction_reason Array of RestrictionReason Optional Contains the reason why access to this message must be restricted.
ttl_period int Optional Time 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_id int Optional

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];