December 30, 2021
Bot API 5.6
- Improved support for Protected Content.
- Added the parameter protect_content to the methods sendMessage, sendPhoto, sendVideo, sendAnimation, sendAudio, sendDocument, sendSticker, sendVideoNote, sendVoice, sendLocation, sendVenue, sendContact, sendPoll, sendDice, sendInvoice, sendGame, sendMediaGroup, copyMessage, forwardMessage to allow sending messages with protected content to any chat.
- Added support for spoiler entities, which will work in Telegram versions released after December 30, 2021. Older clients will display unsupported message.
- Added new MessageEntity type “spoiler”.
- Added the ability to specify spoiler entities using HTML and MarkdownV2 formatting options.
MessageEntity
This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
Field |
Type |
Description |
type |
String |
Type of the entity. Currently, can be “mention” (@username ), “hashtag” (#hashtag ), “cashtag” ($USD ), “bot_command” (/start@jobs_bot ), “url” (https://telegram.org ), “email” (do-not-reply@telegram.org ), “phone_number” (+1-212-555-0123 ), “bold” (bold text), “italic” (italic text), “underline” (underlined text), “strikethrough” (strikethrough text), “spoiler” (spoiler message), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames) |
sendMessage
Use this method to send text messages. On success, the sent Message is returned.
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of sent messages from forwarding and saving |
Formatting options
The Bot API supports basic formatting for messages. You can use bold, italic, underlined, strikethrough, and spoiler text, as well as inline links and pre-formatted code in your bots' messages. Telegram clients will render them accordingly. You can use either markdown-style or HTML-style formatting.
Message entities can be nested, providing following restrictions are met:
- If two entities have common characters then one of them is fully contained inside another.
- bold, italic, underline, strikethrough, and spoiler entities can contain and can be part of any other entities, except pre and code.
- All other entities can't contain each other.
MarkdownV2 style
To use this mode, pass MarkdownV2 in the parse_mode field. Use the following syntax in your message:
*bold \*text*
_italic \*text_
__underline__
~strikethrough~
||spoiler||
*bold _italic bold ~italic bold strikethrough ||italic bold strikethrough spoiler||~ __underline italic bold___ bold*
HTML style
To use this mode, pass HTML in the parse_mode field. The following tags are currently supported:
<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<u>underline</u>, <ins>underline</ins>
<s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
<span class="tg-spoiler">spoiler</span>
<b>bold <i>italic bold <s>italic bold strikethrough <span class="tg-spoiler">italic bold strikethrough spoiler</span></s> <u>underline italic bold</u></i> bold</b>
forwardMessage
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the forwarded message from forwarding and saving |
copyMessage
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendPhoto
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendAudio
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendDocument
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendVideo
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendAnimation
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendVoice
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendVideoNote
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendMediaGroup
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent messages from forwarding and saving |
sendLocation
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendVenue
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendContact
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendPoll
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendDice
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding |
sendSticker
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendInvoice
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |
sendGame
Parameter |
Type |
Required |
Description |
protect_content |
Boolean |
Optional |
Protects the contents of the sent message from forwarding and saving |