telegram.Message¶
-
class
telegram.
Message
(message_id, date, chat, from_user=None, forward_from=None, forward_from_chat=None, forward_from_message_id=None, forward_date=None, reply_to_message=None, edit_date=None, text=None, entities=None, caption_entities=None, audio=None, document=None, game=None, photo=None, sticker=None, video=None, voice=None, video_note=None, new_chat_members=None, caption=None, contact=None, location=None, venue=None, left_chat_member=None, new_chat_title=None, new_chat_photo=None, delete_chat_photo=False, group_chat_created=False, supergroup_chat_created=False, channel_chat_created=False, migrate_to_chat_id=None, migrate_from_chat_id=None, pinned_message=None, invoice=None, successful_payment=None, forward_signature=None, author_signature=None, media_group_id=None, connected_website=None, animation=None, passport_data=None, poll=None, forward_sender_name=None, reply_markup=None, bot=None, dice=None, via_bot=None, proximity_alert_triggered=None, sender_chat=None, voice_chat_started=None, voice_chat_ended=None, voice_chat_participants_invited=None, message_auto_delete_timer_changed=None, voice_chat_scheduled=None, is_automatic_forward=None, has_protected_content=None, video_chat_scheduled=None, video_chat_started=None, video_chat_ended=None, video_chat_participants_invited=None, web_app_data=None, is_topic_message=None, message_thread_id=None, forum_topic_created=None, forum_topic_closed=None, forum_topic_reopened=None, **_kwargs)¶ Bases:
telegram.base.TelegramObject
This object represents a message.
Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their
message_id
andchat
are equal.Note
In Python
from
is a reserved word, usefrom_user
instead.Changed in version 13.12: Since Bot API 6.0, voice chat was renamed to video chat.
- Parameters
message_id (
int
) – Unique message identifier inside this chat.from_user (
telegram.User
, optional) – Sender of the message; empty for messages sent to channels. For backward compatibility, this will contain a fake sender user in non-channel chats, if the message was sent on behalf of a chat.sender_chat (
telegram.Chat
, optional) – Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility,from_user
contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.date (
datetime.datetime
) – Date the message was sent in Unix time. Converted todatetime.datetime
.chat (
telegram.Chat
) – Conversation the message belongs to.forward_from (
telegram.User
, optional) – For forwarded messages, sender of the original message.forward_from_chat (
telegram.Chat
, optional) – For messages forwarded from channels or from anonymous administrators, information about the original sender chat.forward_from_message_id (
int
, optional) – For forwarded channel posts, identifier of the original message in the channel.forward_sender_name (
str
, optional) – Sender’s name for messages forwarded from users who disallow adding a link to their account in forwarded messages.forward_date (
datetime.datetime
, optional) – For forwarded messages, date the original message was sent in Unix time. Converted todatetime.datetime
.is_automatic_forward (
bool
, optional) –True
, if the message is a channel post that was automatically forwarded to the connected discussion group.New in version 13.9.
reply_to_message (
telegram.Message
, optional) – For replies, the original message.edit_date (
datetime.datetime
, optional) – Date the message was last edited in Unix time. Converted todatetime.datetime
.has_protected_content (
bool
, optional) –True
, if the message can’t be forwarded.New in version 13.9.
media_group_id (
str
, optional) – The unique identifier of a media message group this message belongs to.text (str, optional) – For text messages, the actual UTF-8 text of the message, 0-4096 characters. Also found as
telegram.constants.MAX_MESSAGE_LENGTH
.entities (List[
telegram.MessageEntity
], optional) – For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. Seeparse_entity
andparse_entities
methods for how to use properly.caption_entities (List[
telegram.MessageEntity
]) – Optional. For Messages with a Caption. Special entities like usernames, URLs, bot commands, etc. that appear in the caption. SeeMessage.parse_caption_entity
andparse_caption_entities
methods for how to use properly.audio (
telegram.Audio
, optional) – Message is an audio file, information about the file.document (
telegram.Document
, optional) – Message is a general file, information about the file.animation (
telegram.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.game (
telegram.Game
, optional) – Message is a game, information about the game.photo (List[
telegram.PhotoSize
], optional) – Message is a photo, available sizes of the photo.sticker (
telegram.Sticker
, optional) – Message is a sticker, information about the sticker.video (
telegram.Video
, optional) – Message is a video, information about the video.voice (
telegram.Voice
, optional) – Message is a voice message, information about the file.video_note (
telegram.VideoNote
, optional) – Message is a video note, information about the video message.new_chat_members (List[
telegram.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).caption (
str
, optional) – Caption for the animation, audio, document, photo, video or voice, 0-1024 characters.contact (
telegram.Contact
, optional) – Message is a shared contact, information about the contact.location (
telegram.Location
, optional) – Message is a shared location, information about the location.venue (
telegram.Venue
, optional) – Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set.left_chat_member (
telegram.User
, optional) – A member was removed from the group, information about them (this member may be the bot itself).new_chat_title (
str
, optional) – A chat title was changed to this value.new_chat_photo (List[
telegram.PhotoSize
], optional) – A chat photo was changed to this value.delete_chat_photo (
bool
, optional) – Service message: The chat photo was deleted.group_chat_created (
bool
, optional) – Service message: The group has been created.supergroup_chat_created (
bool
, optional) – Service message: The supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found inreply_to_message
if someone replies to a very first message in a directly created supergroup.channel_chat_created (
bool
, optional) – Service message: The channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found inreply_to_message
if someone replies to a very first message in a channel.message_auto_delete_timer_changed (
telegram.MessageAutoDeleteTimerChanged
, optional) –Service message: auto-delete timer settings changed in the chat.
New in version 13.4.
migrate_to_chat_id (
int
, optional) – The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.migrate_from_chat_id (
int
, optional) – The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.pinned_message (
telegram.Message
, optional) – Specified message was pinned. Note that the Message object in this field will not contain furtherreply_to_message
fields even if it is itself a reply.invoice (
telegram.Invoice
, optional) – Message is an invoice for a payment, information about the invoice.successful_payment (
telegram.SuccessfulPayment
, optional) – Message is a service message about a successful payment, information about the payment.connected_website (
str
, optional) – The domain name of the website on which the user has logged in.forward_signature (
str
, optional) – For messages forwarded from channels, signature of the post author if present.author_signature (
str
, optional) – Signature of the post author for messages in channels, or the custom title of an anonymous group administrator.passport_data (
telegram.PassportData
, optional) – Telegram Passport data.poll (
telegram.Poll
, optional) – Message is a native poll, information about the poll.dice (
telegram.Dice
, optional) – Message is a dice with random value from 1 to 6.via_bot (
telegram.User
, optional) – Message was sent through an inline bot.proximity_alert_triggered (
telegram.ProximityAlertTriggered
, optional) – Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.voice_chat_scheduled (
telegram.VoiceChatScheduled
, optional) –Service message: voice chat scheduled.
New in version 13.5.
Deprecated since version 13.12.
voice_chat_started (
telegram.VoiceChatStarted
, optional) –Service message: voice chat started.
New in version 13.4.
Deprecated since version 13.12.
voice_chat_ended (
telegram.VoiceChatEnded
, optional) –Service message: voice chat ended.
New in version 13.4.
Deprecated since version 13.12.
voice_chat_participants_invited (
telegram.VoiceChatParticipantsInvited
optional) –Service message: new participants invited to a voice chat.
New in version 13.4.
Deprecated since version 13.12.
video_chat_scheduled (
telegram.VideoChatScheduled
, optional) –Service message: video chat scheduled.
New in version 13.12.
video_chat_started (
telegram.VideaChatStarted
, optional) –Service message: video chat started.
New in version 13.12.
video_chat_ended (
telegram.VideaChatEnded
, optional) –Service message: video chat ended.
New in version 13.12.
video_chat_participants_invited (
telegram.VideoChatParticipantsInvited
optional) –Service message: new participants invited to a video chat.
New in version 13.12.
web_app_data (
telegram.WebAppData
, optional) – Service message: data sent by a Web App. .. versionadded:: 13.12reply_markup (
telegram.InlineKeyboardMarkup
, optional) – Inline keyboard attached to the message.login_url
buttons are represented as ordinary url buttons.is_topic_message (
bool
, optional) –True
, if the message is sent to a forum topic.New in version 13.15.
message_thread_id (
int
, optional) –Unique identifier of a message thread to which the message belongs; for supergroups only.
New in version 13.15.
forum_topic_created (
telegram.ForumTopicCreated
, optional) –Service message: forum topic created
New in version 13.15.
forum_topic_closed (
telegram.ForumTopicClosed
, optional) –Service message: forum topic closed
New in version 13.15.
forum_topic_reopened (
telegram.ForumTopicReopened
, optional) –Service message: forum topic reopened
New in version 13.15.
bot (
telegram.Bot
, optional) – The Bot to use for instance methods.
-
message_id
¶ Unique message identifier inside this chat.
- Type
int
-
from_user
¶ Optional. Sender of the message; empty for messages sent to channels. For backward compatibility, this will contain a fake sender user in non-channel chats, if the message was sent on behalf of a chat.
- Type
-
sender_chat
¶ Optional. Sender of the message, sent on behalf of a chat. For backward compatibility,
from_user
contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat.- Type
-
date
¶ Date the message was sent.
- Type
datetime.datetime
-
chat
¶ Conversation the message belongs to.
- Type
-
forward_from
¶ Optional. Sender of the original message.
- Type
-
forward_from_chat
¶ Optional. For messages forwarded from channels or from anonymous administrators, information about the original sender chat.
- Type
-
forward_from_message_id
¶ Optional. Identifier of the original message in the channel.
- Type
int
-
forward_date
¶ Optional. Date the original message was sent.
- Type
datetime.datetime
-
is_automatic_forward
¶ Optional.
True
, if the message is a channel post that was automatically forwarded to the connected discussion group.New in version 13.9.
- Type
bool
-
reply_to_message
¶ Optional. For replies, 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.- Type
-
edit_date
¶ Optional. Date the message was last edited.
- Type
datetime.datetime
-
has_protected_content
¶ Optional.
True
, if the message can’t be forwarded.New in version 13.9.
- Type
bool
-
media_group_id
¶ Optional. The unique identifier of a media message group this message belongs to.
- Type
str
-
text
¶ Optional. The actual UTF-8 text of the message.
- Type
str
-
entities
¶ Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the text. See
Message.parse_entity
andparse_entities
methods for how to use properly.- Type
List[
telegram.MessageEntity
]
-
caption_entities
¶ Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the caption. See
Message.parse_caption_entity
andparse_caption_entities
methods for how to use properly.- Type
List[
telegram.MessageEntity
]
-
audio
¶ Optional. Information about the file.
- Type
-
document
¶ Optional. Information about the file.
- Type
-
animation
¶ For backward compatibility, when this field is set, the document field will also be set.
- Type
-
game
¶ Optional. Information about the game.
- Type
-
photo
¶ Optional. Available sizes of the photo.
- Type
List[
telegram.PhotoSize
]
-
sticker
¶ Optional. Information about the sticker.
- Type
-
video
¶ Optional. Information about the video.
- Type
-
voice
¶ Optional. Information about the file.
- Type
-
video_note
¶ Optional. Information about the video message.
- Type
-
new_chat_members
¶ Optional. Information about new members to the chat. (the bot itself may be one of these members).
- Type
List[
telegram.User
]
-
caption
¶ Optional. Caption for the document, photo or video, 0-1024 characters.
- Type
str
-
contact
¶ Optional. Information about the contact.
- Type
-
location
¶ Optional. Information about the location.
- Type
-
venue
¶ Optional. Information about the venue.
- Type
-
left_chat_member
¶ Optional. Information about the user that left the group. (this member may be the bot itself).
- Type
-
new_chat_title
¶ Optional. A chat title was changed to this value.
- Type
str
-
new_chat_photo
¶ Optional. A chat photo was changed to this value.
- Type
List[
telegram.PhotoSize
]
-
delete_chat_photo
¶ Optional. The chat photo was deleted.
- Type
bool
-
group_chat_created
¶ Optional. The group has been created.
- Type
bool
-
supergroup_chat_created
¶ Optional. The supergroup has been created.
- Type
bool
-
channel_chat_created
¶ Optional. The channel has been created.
- Type
bool
-
message_auto_delete_timer_changed
¶ Optional. Service message: auto-delete timer settings changed in the chat.
New in version 13.4.
-
migrate_to_chat_id
¶ Optional. The group has been migrated to a supergroup with the specified identifier.
- Type
int
-
migrate_from_chat_id
¶ Optional. The supergroup has been migrated from a group with the specified identifier.
- Type
int
-
pinned_message
¶ Optional. Specified message was pinned.
- Type
telegram.message
-
invoice
¶ Optional. Information about the invoice.
- Type
-
successful_payment
¶ Optional. Information about the payment.
-
connected_website
¶ Optional. The domain name of the website on which the user has logged in.
- Type
str
-
forward_signature
¶ Optional. Signature of the post author for messages forwarded from channels.
- Type
str
-
forward_sender_name
¶ Optional. Sender’s name for messages forwarded from users who disallow adding a link to their account in forwarded messages.
- Type
str
Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator.
- Type
str
-
passport_data
¶ Optional. Telegram Passport data.
-
poll
¶ Optional. Message is a native poll, information about the poll.
- Type
-
dice
¶ Optional. Message is a dice.
- Type
-
via_bot
¶ Optional. Bot through which the message was sent.
- Type
-
proximity_alert_triggered
¶ Optional. Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.
-
voice_chat_scheduled
¶ Optional. Service message: voice chat scheduled.
New in version 13.5.
Deprecated since version 13.12: contains the same value as
VideoChatScheduled
for backwards compatibility.
-
voice_chat_started
¶ Optional. Service message: voice chat started.
New in version 13.4.
Deprecated since version 13.12: contains the same value as
VideoChatStarted
for backwards compatibility.
-
voice_chat_ended
¶ Optional. Service message: voice chat ended.
New in version 13.4.
Deprecated since version 13.12: contains the same value as
VideoChatEnded
for backwards compatibility.
-
voice_chat_participants_invited
¶ Optional. Service message: new participants invited to a voice chat.
New in version 13.4.
Deprecated since version 13.12: contains the same value as
VideoChatParticipantsInvited
for backwards compatibility.
-
video_chat_scheduled
¶ Optional. Service message: video chat scheduled.
New in version 13.12.
-
video_chat_started
¶ Optional. Service message: video chat started.
New in version 13.12.
-
video_chat_ended
¶ Optional. Service message: video chat ended.
New in version 13.12.
-
video_chat_participants_invited
¶ Optional. Service message: new participants invited to a video chat.
New in version 13.12.
-
web_app_data
¶ Optional. Service message: data sent by a Web App.
New in version 13.12.
- Type
-
reply_markup
¶ Optional. Inline keyboard attached to the message.
-
is_topic_message
¶ Optional.
True
, if the message is sent to a forum topic.New in version 13.15.
- Type
bool
-
message_thread_id
¶ Optional. Unique identifier of a message thread to which the message belongs; for supergroups only.
New in version 13.15.
- Type
int
-
forum_topic_created
¶ Optional. Service message: forum topic created
New in version 13.15.
-
forum_topic_closed
¶ Optional. Service message: forum topic closed
New in version 13.15.
-
forum_topic_reopened
¶ Optional. Service message: forum topic reopened
New in version 13.15.
-
bot
¶ Optional. The Bot to use for instance methods.
- Type
-
property
caption_html
¶ Creates an HTML-formatted string from the markup entities found in the message’s caption.
Use this if you want to retrieve the message caption with the caption entities formatted as HTML in the same way the original message was formatted.
Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as HTML.
- Returns
Message caption with caption entities formatted as HTML.
- Return type
str
-
property
caption_html_urled
¶ Creates an HTML-formatted string from the markup entities found in the message’s caption.
Use this if you want to retrieve the message caption with the caption entities formatted as HTML. This also formats
telegram.MessageEntity.URL
as a hyperlink.Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as HTML.
- Returns
Message caption with caption entities formatted as HTML.
- Return type
str
-
property
caption_markdown
¶ Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.ParseMode.MARKDOWN
.Use this if you want to retrieve the message caption with the caption entities formatted as Markdown in the same way the original message was formatted.
Note
telegram.ParseMode.MARKDOWN
is a legacy mode, retained by Telegram forbackward compatibility. You should use
caption_markdown_v2()
instead.
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
- Returns
Message caption with caption entities formatted as Markdown.
- Return type
str
- Raises
ValueError – If the message contains underline, strikethrough, spoiler or nested entities.
-
property
caption_markdown_urled
¶ Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.ParseMode.MARKDOWN
.Use this if you want to retrieve the message caption with the caption entities formatted as Markdown. This also formats
telegram.MessageEntity.URL
as a hyperlink.Note
telegram.ParseMode.MARKDOWN
is a legacy mode, retained by Telegram forbackward compatibility. You should use
caption_markdown_v2_urled()
instead.
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
- Returns
Message caption with caption entities formatted as Markdown.
- Return type
str
- Raises
ValueError – If the message contains underline, strikethrough, spoiler or nested entities.
-
property
caption_markdown_v2
¶ Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.ParseMode.MARKDOWN_V2
.Use this if you want to retrieve the message caption with the caption entities formatted as Markdown in the same way the original message was formatted.
Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
- Returns
Message caption with caption entities formatted as Markdown.
- Return type
str
-
property
caption_markdown_v2_urled
¶ Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.ParseMode.MARKDOWN_V2
.Use this if you want to retrieve the message caption with the caption entities formatted as Markdown. This also formats
telegram.MessageEntity.URL
as a hyperlink.Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
- Returns
Message caption with caption entities formatted as Markdown.
- Return type
str
-
property
chat_id
¶ Shortcut for
telegram.Chat.id
forchat
.- Type
int
-
close_forum_topic
(timeout=None, api_kwargs=None)¶ Shortcut for:
bot.close_forum_topic( chat_id=message.chat_id, message_thread_id=message.message_thread_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.close_forum_topic()
.New in version 13.15.
- Returns
On success,
True
is returned.- Return type
bool
-
copy
(chat_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_to_message_id=None, allow_sending_without_reply=None, reply_markup=None, timeout=None, api_kwargs=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.copy_message(chat_id=chat_id, from_chat_id=update.effective_message.chat_id, message_id=update.effective_message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.copy_message()
.- Returns
On success, returns the MessageId of the sent message.
- Return type
-
classmethod
de_json
(data, bot)¶
-
delete
(timeout=None, api_kwargs=None)¶ Shortcut for:
bot.delete_message(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.delete_message()
.- Returns
On success,
True
is returned.- Return type
bool
-
delete_forum_topic
(timeout=None, api_kwargs=None)¶ Shortcut for:
bot.delete_forum_topic( chat_id=message.chat_id, message_thread_id=message.message_thread_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.delete_forum_topic()
.New in version 13.15.
- Returns
On success,
True
is returned.- Return type
bool
-
edit_caption
(caption=None, reply_markup=None, timeout=None, parse_mode=None, api_kwargs=None, caption_entities=None)¶ Shortcut for:
bot.edit_message_caption(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.edit_message_caption()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
edit_forum_topic
(name, icon_custom_emoji_id, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.edit_forum_topic( chat_id=message.chat_id, message_thread_id=message.message_thread_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.edit_forum_topic()
.New in version 13.15.
- Returns
On success,
True
is returned.- Return type
bool
-
edit_live_location
(latitude=None, longitude=None, location=None, reply_markup=None, timeout=None, api_kwargs=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None)¶ Shortcut for:
bot.edit_message_live_location(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.edit_message_live_location()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
edit_media
(media=None, reply_markup=None, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.edit_message_media(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.edit_message_media()
.Note
You can only edit messages that the bot sent itself(i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
edit_reply_markup
(reply_markup=None, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.edit_message_reply_markup(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.edit_message_reply_markup()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
edit_text
(text, parse_mode=None, disable_web_page_preview=None, reply_markup=None, timeout=None, api_kwargs=None, entities=None)¶ Shortcut for:
bot.edit_message_text(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.edit_message_text()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
property
effective_attachment
¶ telegram.Audio
ortelegram.Contact
ortelegram.Document
ortelegram.Animation
ortelegram.Game
ortelegram.Invoice
ortelegram.Location
or List[telegram.PhotoSize
] ortelegram.Sticker
ortelegram.SuccessfulPayment
ortelegram.Venue
ortelegram.Video
ortelegram.VideoNote
ortelegram.Voice
: The attachment that this message was sent with. May beNone
if no attachment was sent.
-
forward
(chat_id, disable_notification=None, timeout=None, api_kwargs=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.forward_message(chat_id=chat_id, from_chat_id=update.effective_message.chat_id, message_id=update.effective_message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.forward_message()
.Note
Since the release of Bot API 5.5 it can be impossible to forward messages from some chats. Use the attributes
telegram.Message.has_protected_content
andtelegram.Chat.has_protected_content
to check this.As a workaround, it is still possible to use
copy()
. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, instance representing the message forwarded.
- Return type
-
get_game_high_scores
(user_id, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.get_game_high_scores(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.get_game_high_scores()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
List[
telegram.GameHighScore
]
-
property
link
¶ Convenience property. If the chat of the message is not a private chat or normal group, returns a t.me link of the message.
- Type
str
-
parse_caption_entities
(types=None)¶ Returns a
dict
that mapstelegram.MessageEntity
tostr
. It contains entities from this message’s caption filtered by theirtelegram.MessageEntity.type
attribute as the key, and the text that each entity belongs to as the value of thedict
.Note
This method should always be used instead of the
caption_entities
attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. Seeparse_entity
for more info.- Parameters
types (List[
str
], optional) – List oftelegram.MessageEntity
types as strings. If thetype
attribute of an entity is contained in this list, it will be returned. Defaults to a list of all types. All types can be found as constants intelegram.MessageEntity
.- Returns
A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints.
- Return type
Dict[
telegram.MessageEntity
,str
]
-
parse_caption_entity
(entity)¶ Returns the text from a given
telegram.MessageEntity
.Note
This method is present because Telegram calculates the offset and length in UTF-16 codepoint pairs, which some versions of Python don’t handle automatically. (That is, you can’t just slice
Message.caption
with the offset and length.)- Parameters
entity (
telegram.MessageEntity
) – The entity to extract the text from. It must be an entity that belongs to this message.- Returns
The text of the given entity.
- Return type
str
- Raises
RuntimeError – If the message has no caption.
-
parse_entities
(types=None)¶ Returns a
dict
that mapstelegram.MessageEntity
tostr
. It contains entities from this message filtered by theirtelegram.MessageEntity.type
attribute as the key, and the text that each entity belongs to as the value of thedict
.Note
This method should always be used instead of the
entities
attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints. Seeparse_entity
for more info.- Parameters
types (List[
str
], optional) – List oftelegram.MessageEntity
types as strings. If thetype
attribute of an entity is contained in this list, it will be returned. Defaults to a list of all types. All types can be found as constants intelegram.MessageEntity
.- Returns
A dictionary of entities mapped to the text that belongs to them, calculated based on UTF-16 codepoints.
- Return type
Dict[
telegram.MessageEntity
,str
]
-
parse_entity
(entity)¶ Returns the text from a given
telegram.MessageEntity
.Note
This method is present because Telegram calculates the offset and length in UTF-16 codepoint pairs, which some versions of Python don’t handle automatically. (That is, you can’t just slice
Message.text
with the offset and length.)- Parameters
entity (
telegram.MessageEntity
) – The entity to extract the text from. It must be an entity that belongs to this message.- Returns
The text of the given entity.
- Return type
str
- Raises
RuntimeError – If the message has no text.
-
pin
(disable_notification=None, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.pin_chat_message(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.pin_chat_message()
.- Returns
On success,
True
is returned.- Return type
bool
-
reopen_forum_topic
(timeout=None, api_kwargs=None)¶ Shortcut for:
bot.reopen_forum_topic( chat_id=message.chat_id, message_thread_id=message.message_thread_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.reopen_forum_topic()
.New in version 13.15.
- Returns
On success,
True
is returned.- Return type
bool
-
reply_animation
(animation, duration=None, width=None, height=None, thumb=None, caption=None, parse_mode=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_animation(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_animation()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the animation is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_audio
(audio, duration=None, performer=None, title=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, thumb=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_audio(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_audio()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the audio is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_chat_action
(action, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.send_chat_action(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_chat_action()
.New in version 13.2.
- Returns
On success,
True
is returned.- Return type
bool
-
reply_contact
(phone_number=None, first_name=None, last_name=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, contact=None, vcard=None, api_kwargs=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_contact(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_contact()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the contact is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_copy
(from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_to_message_id=None, allow_sending_without_reply=None, reply_markup=None, timeout=None, api_kwargs=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.copy_message(chat_id=message.chat.id, from_chat_id=from_chat_id, message_id=message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.copy_message()
.- Parameters
quote (
bool
, optional) –If set to
True
, the copy is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.New in version 13.1.
- Returns
On success, returns the MessageId of the sent message.
- Return type
-
reply_dice
(disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, emoji=None, api_kwargs=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_dice(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_dice()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the dice is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_document
(document, filename=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, thumb=None, api_kwargs=None, disable_content_type_detection=None, allow_sending_without_reply=None, caption_entities=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_document(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_document()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the document is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_game
(game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_game(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_game()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the game is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.
New in version 13.2.
- Returns
On success, instance representing the message posted.
- Return type
-
reply_html
(text, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, entities=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_message( update.effective_message.chat_id, parse_mode=ParseMode.HTML, *args, **kwargs, )
Sends a message with HTML formatting.
For the documentation of the arguments, please see
telegram.Bot.send_message()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the message is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_invoice
(title, description, payload, provider_token, currency, prices, start_parameter=None, photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None, is_flexible=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, provider_data=None, send_phone_number_to_provider=None, send_email_to_provider=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, quote=None, max_tip_amount=None, suggested_tip_amounts=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_invoice(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_invoice()
.Warning
As of API 5.2
start_parameter
is an optional argument and therefore the order of the arguments had to be changed. Use keyword arguments to make sure that the arguments are passed correctly.New in version 13.2.
Changed in version 13.5: As of Bot API 5.2, the parameter
start_parameter
is optional.- Parameters
quote (
bool
, optional) – If set toTrue
, the invoice is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_location
(latitude=None, longitude=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, location=None, live_period=None, api_kwargs=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_location(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_location()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the location is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_markdown
(text, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, entities=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_message( update.effective_message.chat_id, parse_mode=ParseMode.MARKDOWN, *args, **kwargs, )
Sends a message with Markdown version 1 formatting.
For the documentation of the arguments, please see
telegram.Bot.send_message()
.Note
telegram.ParseMode.MARKDOWN
is a legacy mode, retained by Telegram for backward compatibility. You should usereply_markdown_v2()
instead.- Parameters
quote (
bool
, optional) – If set toTrue
, the message is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_markdown_v2
(text, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, entities=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_message( update.effective_message.chat_id, parse_mode=ParseMode.MARKDOWN_V2, *args, **kwargs, )
Sends a message with markdown version 2 formatting.
For the documentation of the arguments, please see
telegram.Bot.send_message()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the message is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_media_group
(media, disable_notification=None, reply_to_message_id=None, timeout=20, api_kwargs=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_media_group(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_media_group()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the media group is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
An array of the sent Messages.
- Return type
List[
telegram.Message
]- Raises
-
reply_photo
(photo, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_photo(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_photo()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the photo is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_poll
(question, options, is_anonymous=True, type='regular', allows_multiple_answers=False, correct_option_id=None, is_closed=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, explanation=None, explanation_parse_mode=None, open_period=None, close_date=None, api_kwargs=None, allow_sending_without_reply=None, explanation_entities=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_poll(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_poll()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the poll is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_sticker
(sticker, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, api_kwargs=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_sticker(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_sticker()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the sticker is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_text
(text, parse_mode=None, disable_web_page_preview=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, api_kwargs=None, allow_sending_without_reply=None, entities=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_message(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_message()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the message is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_venue
(latitude=None, longitude=None, title=None, address=None, foursquare_id=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=None, venue=None, foursquare_type=None, api_kwargs=None, google_place_id=None, google_place_type=None, allow_sending_without_reply=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_venue(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_venue()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the venue is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_video
(video, duration=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, width=None, height=None, parse_mode=None, supports_streaming=None, thumb=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_video(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_video()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the video is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_video_note
(video_note, duration=None, length=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, thumb=None, api_kwargs=None, allow_sending_without_reply=None, filename=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_video_note(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_video_note()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the video note is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
reply_voice
(voice, duration=None, caption=None, disable_notification=None, reply_to_message_id=None, reply_markup=None, timeout=20, parse_mode=None, api_kwargs=None, allow_sending_without_reply=None, caption_entities=None, filename=None, quote=None, protect_content=None, message_thread_id=None)¶ Shortcut for:
bot.send_voice(update.effective_message.chat_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.send_voice()
.- Parameters
quote (
bool
, optional) – If set toTrue
, the voice note is sent as an actual reply to this message. Ifreply_to_message_id
is passed inkwargs
, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.- Returns
On success, instance representing the message posted.
- Return type
-
set_game_score
(user_id, score, force=None, disable_edit_message=None, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.set_game_score(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.set_game_score()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
stop_live_location
(reply_markup=None, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.stop_message_live_location(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.stop_message_live_location()
.Note
You can only edit messages that the bot sent itself (i.e. of the
bot.send_*
family of methods) or channel posts, if the bot is an admin in that channel. However, this behaviour is undocumented and might be changed by Telegram.- Returns
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type
-
stop_poll
(reply_markup=None, timeout=None, api_kwargs=None)¶ Shortcut for:
bot.stop_poll(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.stop_poll()
.- Returns
On success, the stopped Poll with the final results is returned.
- Return type
-
property
text_html
¶ Creates an HTML-formatted string from the markup entities found in the message.
Use this if you want to retrieve the message text with the entities formatted as HTML in the same way the original message was formatted.
Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as HTML.
- Returns
Message text with entities formatted as HTML.
- Return type
str
-
property
text_html_urled
¶ Creates an HTML-formatted string from the markup entities found in the message.
Use this if you want to retrieve the message text with the entities formatted as HTML. This also formats
telegram.MessageEntity.URL
as a hyperlink.Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as HTML.
- Returns
Message text with entities formatted as HTML.
- Return type
str
-
property
text_markdown
¶ Creates an Markdown-formatted string from the markup entities found in the message using
telegram.ParseMode.MARKDOWN
.Use this if you want to retrieve the message text with the entities formatted as Markdown in the same way the original message was formatted.
Note
telegram.ParseMode.MARKDOWN
is a legacy mode, retained by Telegram forbackward compatibility. You should use
text_markdown_v2()
instead.
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
- Returns
Message text with entities formatted as Markdown.
- Return type
str
- Raises
ValueError – If the message contains underline, strikethrough, spoiler or nested entities.
-
property
text_markdown_urled
¶ Creates an Markdown-formatted string from the markup entities found in the message using
telegram.ParseMode.MARKDOWN
.Use this if you want to retrieve the message text with the entities formatted as Markdown. This also formats
telegram.MessageEntity.URL
as a hyperlink.Note
telegram.ParseMode.MARKDOWN
is a legacy mode, retained by Telegram forbackward compatibility. You should use
text_markdown_v2_urled()
instead.
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
- Returns
Message text with entities formatted as Markdown.
- Return type
str
- Raises
ValueError – If the message contains underline, strikethrough, spoiler or nested entities.
-
property
text_markdown_v2
¶ Creates an Markdown-formatted string from the markup entities found in the message using
telegram.ParseMode.MARKDOWN_V2
.Use this if you want to retrieve the message text with the entities formatted as Markdown in the same way the original message was formatted.
Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
- Returns
Message text with entities formatted as Markdown.
- Return type
str
-
property
text_markdown_v2_urled
¶ Creates an Markdown-formatted string from the markup entities found in the message using
telegram.ParseMode.MARKDOWN_V2
.Use this if you want to retrieve the message text with the entities formatted as Markdown. This also formats
telegram.MessageEntity.URL
as a hyperlink.Note
Custom emoji entities will currently be ignored by this function. Instead, the supplied replacement for the emoji will be used.
Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
- Returns
Message text with entities formatted as Markdown.
- Return type
str
-
to_dict
()¶
-
unpin
(timeout=None, api_kwargs=None)¶ Shortcut for:
bot.unpin_chat_message(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.unpin_chat_message()
.- Returns
On success,
True
is returned.- Return type
bool
-
unpin_all_forum_topic_messages
(timeout=None, api_kwargs=None)¶ Shortcut for:
bot.unpin_all_forum_topic_messages( chat_id=message.chat_id, message_thread_id=message.message_thread_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.unpin_all_forum_topic_messages()
.New in version 13.15.
- Returns
On success,
True
is returned.- Return type
bool