Message¶
- class telegram.Message(message_id, date, chat, from_user=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=None, group_chat_created=None, supergroup_chat_created=None, channel_chat_created=None, migrate_to_chat_id=None, migrate_from_chat_id=None, pinned_message=None, invoice=None, successful_payment=None, author_signature=None, media_group_id=None, connected_website=None, animation=None, passport_data=None, poll=None, reply_markup=None, dice=None, via_bot=None, proximity_alert_triggered=None, sender_chat=None, video_chat_started=None, video_chat_ended=None, video_chat_participants_invited=None, message_auto_delete_timer_changed=None, video_chat_scheduled=None, is_automatic_forward=None, has_protected_content=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, forum_topic_edited=None, general_forum_topic_hidden=None, general_forum_topic_unhidden=None, write_access_allowed=None, has_media_spoiler=None, chat_shared=None, story=None, giveaway=None, giveaway_completed=None, giveaway_created=None, giveaway_winners=None, users_shared=None, link_preview_options=None, external_reply=None, quote=None, forward_origin=None, reply_to_story=None, boost_added=None, sender_boost_count=None, business_connection_id=None, sender_business_bot=None, is_from_offline=None, chat_background_set=None, effect_id=None, show_caption_above_media=None, paid_media=None, refunded_payment=None, *, api_kwargs=None)[source]¶
Bases:
telegram.MaybeInaccessibleMessage
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.Available In
Returned In
Changed in version 21.0: Removed deprecated arguments and attributes
user_shared
,forward_from
,forward_from_chat
,forward_from_message_id
,forward_signature
,forward_sender_name
andforward_date
.Changed in version 20.8: * This class is now a subclass of
telegram.MaybeInaccessibleMessage
. * Thepinned_message
now can be eithertelegram.Message
ortelegram.InaccessibleMessage
.Changed in version 20.0:
The arguments and attributes
voice_chat_scheduled
,voice_chat_started
andvoice_chat_ended
,voice_chat_participants_invited
were renamed tovideo_chat_scheduled
/video_chat_scheduled
,video_chat_started
/video_chat_started
,video_chat_ended
/video_chat_ended
andvideo_chat_participants_invited
/video_chat_participants_invited
, respectively, in accordance to Bot API 6.0.The following are now keyword-only arguments in Bot methods:
{read, write, connect, pool}_timeout
,api_kwargs
,contact
,quote
,filename
,loaction
,venue
. Use a named argument for those, and notice that some positional arguments changed position as a result.
- Parameters:
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 be0
and the relevant message will be unusable until it is actually sent.from_user (
telegram.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.sender_chat (
telegram.Chat
, optional) – Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel’s discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats.Date the message was sent in Unix time. Converted to
datetime.datetime
.Changed in version 20.3: The default timezone of the bot is used for localization, which is UTC unless
telegram.ext.Defaults.tzinfo
is used.chat (
telegram.Chat
) – Conversation the message belongs to.is_automatic_forward (
bool
, optional) –True
, if the message is a channel post that was automatically forwarded to the connected discussion group.Added in version 13.9.
reply_to_message (
telegram.Message
, optional) – For replies, the original message. Note that the Message object in this field will not contain furtherreply_to_message
fields even if it itself is a reply.edit_date (
datetime.datetime
, optional) –Date the message was last edited in Unix time. Converted to
datetime.datetime
.Changed in version 20.3: The default timezone of the bot is used for localization, which is UTC unless
telegram.ext.Defaults.tzinfo
is used.has_protected_content (
bool
, optional) –True
, if the message can’t be forwarded.Added in version 13.9.
is_from_offline (
bool
, optional) –True
, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message.Added in version 21.1.
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.entities (Sequence[
telegram.MessageEntity
], optional) –For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. See
parse_entity
andparse_entities
methods for how to use properly. This list is empty if the message does not contain entities.Changed in version 20.0: Accepts any
collections.abc.Sequence
as input instead of just a list. The input is converted to a tuple.link_preview_options (
telegram.LinkPreviewOptions
, optional) –Options used for link preview generation for the message, if it is a text message and link preview options were changed.
Added in version 20.8.
Unique identifier of the message effect added to the message.
Added in version 21.3.
caption_entities (Sequence[
telegram.MessageEntity
], optional) –For messages with a Caption. 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. This list is empty if the message does not contain caption entities.Changed in version 20.0: Accepts any
collections.abc.Sequence
as input instead of just a list. The input is converted to a tuple.show_caption_above_media (
bool
, optional) –True
, if the caption must be shown above the message media.Added in version 21.3.
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. More about games >>.photo (Sequence[
telegram.PhotoSize
], optional) –Message is a photo, available sizes of the photo. This list is empty if the message does not contain a photo.
Changed in version 20.0: Accepts any
collections.abc.Sequence
as input instead of just a list. The input is converted to a tuple.sticker (
telegram.Sticker
, optional) – Message is a sticker, information about the sticker.story (
telegram.Story
, optional) –Message is a forwarded story.
Added in version 20.5.
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 (Sequence[
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). This list is empty if the message does not contain new chat members.
Changed in version 20.0: Accepts any
collections.abc.Sequence
as input instead of just a list. The input is converted to a tuple.caption (
str
, optional) – Caption for the animation, audio, document, paid media, 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 (Sequence[
telegram.PhotoSize
], optional) –A chat photo was changed to this value. This list is empty if the message does not contain a new chat photo.
Changed in version 20.0: Accepts any
collections.abc.Sequence
as input instead of just a list. The input is converted to a tuple.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.
Added in version 13.4.
migrate_to_chat_id (
int
, optional) – The group has been migrated to a supergroup with the specified identifier.migrate_from_chat_id (
int
, optional) – The supergroup has been migrated from a group with the specified identifier.pinned_message (
telegram.MaybeInaccessibleMessage
, optional) –Specified message was pinned. Note that the Message object in this field will not contain further
reply_to_message
fields even if it is itself a reply.Changed in version 20.8: This attribute now is either
telegram.Message
ortelegram.InaccessibleMessage
.invoice (
telegram.Invoice
, optional) – Message is an invoice for a payment, information about the invoice. More about payments >>.successful_payment (
telegram.SuccessfulPayment
, optional) – Message is a service message about a successful payment, information about the payment. More about payments >>.connected_website (
str
, optional) – The domain name of the website on which the user has logged in. More about Telegram Login >>.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.via_bot (
telegram.User
, optional) – Bot through which message was sent.proximity_alert_triggered (
telegram.ProximityAlertTriggered
, optional) – Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.video_chat_scheduled (
telegram.VideoChatScheduled
, optional) –Service message: video chat scheduled.
Added in version 20.0.
video_chat_started (
telegram.VideoChatStarted
, optional) –Service message: video chat started.
Added in version 20.0.
video_chat_ended (
telegram.VideoChatEnded
, optional) –Service message: video chat ended.
Added in version 20.0.
video_chat_participants_invited (
telegram.VideoChatParticipantsInvited
optional) –Service message: new participants invited to a video chat.
Added in version 20.0.
web_app_data (
telegram.WebAppData
, optional) –Service message: data sent by a Web App.
Added in version 20.0.
reply_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.Added in version 20.0.
message_thread_id (
int
, optional) –Unique identifier of a message thread to which the message belongs; for supergroups only.
Added in version 20.0.
forum_topic_created (
telegram.ForumTopicCreated
, optional) –Service message: forum topic created.
Added in version 20.0.
forum_topic_closed (
telegram.ForumTopicClosed
, optional) –Service message: forum topic closed.
Added in version 20.0.
forum_topic_reopened (
telegram.ForumTopicReopened
, optional) –Service message: forum topic reopened.
Added in version 20.0.
forum_topic_edited (
telegram.ForumTopicEdited
, optional) –Service message: forum topic edited.
Added in version 20.0.
general_forum_topic_hidden (
telegram.GeneralForumTopicHidden
, optional) –Service message: General forum topic hidden.
Added in version 20.0.
general_forum_topic_unhidden (
telegram.GeneralForumTopicUnhidden
, optional) –Service message: General forum topic unhidden.
Added in version 20.0.
write_access_allowed (
telegram.WriteAccessAllowed
, optional) –Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess.
Added in version 20.0.
has_media_spoiler (
bool
, optional) –True
, if the message media is covered by a spoiler animation.Added in version 20.0.
users_shared (
telegram.UsersShared
, optional) –Service message: users were shared with the bot
Added in version 20.8.
chat_shared (
telegram.ChatShared
, optional) –Service message: a chat was shared with the bot.
Added in version 20.1.
giveaway_created (
telegram.GiveawayCreated
, optional) –Service message: a scheduled giveaway was created
Added in version 20.8.
giveaway (
telegram.Giveaway
, optional) –The message is a scheduled giveaway message
Added in version 20.8.
giveaway_winners (
telegram.GiveawayWinners
, optional) –A giveaway with public winners was completed
Added in version 20.8.
giveaway_completed (
telegram.GiveawayCompleted
, optional) –Service message: a giveaway without public winners was completed
Added in version 20.8.
external_reply (
telegram.ExternalReplyInfo
, optional) –Information about the message that is being replied to, which may come from another chat or forum topic.
Added in version 20.8.
quote (
telegram.TextQuote
, optional) –For replies that quote part of the original message, the quoted part of the message.
Added in version 20.8.
forward_origin (
telegram.MessageOrigin
, optional) –Information about the original message for forwarded messages
Added in version 20.8.
reply_to_story (
telegram.Story
, optional) –For replies to a story, the original story.
Added in version 21.0.
boost_added (
telegram.ChatBoostAdded
, optional) –Service message: user boosted the chat.
Added in version 21.0.
sender_boost_count (
int
, optional) –If the sender of the message boosted the chat, the number of boosts added by the user.
Added in version 21.0.
business_connection_id (
str
, optional) –Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.
Added in version 21.1.
sender_business_bot (
telegram.User
, optional) –The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.
Added in version 21.1.
chat_background_set (
telegram.ChatBackground
, optional) –Service message: chat background set.
Added in version 21.2.
paid_media (
telegram.PaidMediaInfo
, optional) –Message contains paid media; information about the paid media.
Added in version 21.4.
refunded_payment (
telegram.RefundedPayment
, optional) –Message is a service message about a refunded payment, information about the payment.
Added in version 21.4.
- message_id[source]¶
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.- Type:
- from_user[source]¶
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.
- Type:
- sender_chat[source]¶
Optional. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel’s discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats.
- Type:
- date[source]¶
Date the message was sent in Unix time. Converted to
datetime.datetime
.Changed in version 20.3: The default timezone of the bot is used for localization, which is UTC unless
telegram.ext.Defaults.tzinfo
is used.- Type:
- is_automatic_forward[source]¶
Optional.
True
, if the message is a channel post that was automatically forwarded to the connected discussion group.Added in version 13.9.
- Type:
- reply_to_message[source]¶
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[source]¶
Optional. Date the message was last edited in Unix time. Converted to
datetime.datetime
.Changed in version 20.3: The default timezone of the bot is used for localization, which is UTC unless
telegram.ext.Defaults.tzinfo
is used.- Type:
- has_protected_content[source]¶
Optional.
True
, if the message can’t be forwarded.Added in version 13.9.
- Type:
- is_from_offline[source]¶
Optional.
True
, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message.Added in version 21.1.
- Type:
- media_group_id[source]¶
Optional. The unique identifier of a media message group this message belongs to.
- Type:
- text[source]¶
Optional. For text messages, the actual UTF-8 text of the message, 0-
4096
characters.- Type:
- entities[source]¶
Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text. See
parse_entity
andparse_entities
methods for how to use properly. This list is empty if the message does not contain entities.Changed in version 20.0: This attribute is now an immutable tuple.
- Type:
tuple[
telegram.MessageEntity
]
- link_preview_options[source]¶
Optional. Options used for link preview generation for the message, if it is a text message and link preview options were changed.
Added in version 20.8.
- effect_id[source]¶
Optional. Unique identifier of the message effect added to the message.
..versionadded:: 21.3
- Type:
Optional. For messages with a Caption. 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. This list is empty if the message does not contain caption entities.Changed in version 20.0: This attribute is now an immutable tuple.
- Type:
tuple[
telegram.MessageEntity
]
Optional.
True
, if the caption must be shown above the message media.Added in version 21.3.
- Type:
- animation[source]¶
Optional. Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set.
See also
- Type:
- game[source]¶
Optional. Message is a game, information about the game. More about games >>.
- Type:
- photo[source]¶
Optional. Message is a photo, available sizes of the photo. This list is empty if the message does not contain a photo.
See also
Changed in version 20.0: This attribute is now an immutable tuple.
- Type:
tuple[
telegram.PhotoSize
]
- video_note[source]¶
Optional. Message is a video note, information about the video message.
See also
- Type:
- new_chat_members[source]¶
Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members). This list is empty if the message does not contain new chat members.
Changed in version 20.0: This attribute is now an immutable tuple.
- Type:
tuple[
telegram.User
]
Optional. Caption for the animation, audio, document, paid media, photo, video or voice, 0-
1024
characters.- Type:
- venue[source]¶
Optional. Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set.
- Type:
- left_chat_member[source]¶
Optional. A member was removed from the group, information about them (this member may be the bot itself).
- Type:
- new_chat_photo[source]¶
A chat photo was changed to this value. This list is empty if the message does not contain a new chat photo.
Changed in version 20.0: This attribute is now an immutable tuple.
- Type:
tuple[
telegram.PhotoSize
]
- supergroup_chat_created[source]¶
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 in
reply_to_message
if someone replies to a very first message in a directly created supergroup.- Type:
- channel_chat_created[source]¶
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 in
reply_to_message
if someone replies to a very first message in a channel.- Type:
- message_auto_delete_timer_changed[source]¶
Optional. Service message: auto-delete timer settings changed in the chat.
Added in version 13.4.
- migrate_to_chat_id[source]¶
Optional. The group has been migrated to a supergroup with the specified identifier.
- Type:
- migrate_from_chat_id[source]¶
Optional. The supergroup has been migrated from a group with the specified identifier.
- Type:
- pinned_message[source]¶
Optional. Specified message was pinned. Note that the Message object in this field will not contain further
reply_to_message
fields even if it is itself a reply.Changed in version 20.8: This attribute now is either
telegram.Message
ortelegram.InaccessibleMessage
.
- invoice[source]¶
Optional. Message is an invoice for a payment, information about the invoice. More about payments >>.
- Type:
- successful_payment[source]¶
Optional. Message is a service message about a successful payment, information about the payment. More about payments >>.
- connected_website[source]¶
Optional. The domain name of the website on which the user has logged in. More about Telegram Login >>.
- Type:
- author_signature[source]¶
Optional. Signature of the post author for messages in channels, or the custom title of an anonymous group administrator.
- Type:
- proximity_alert_triggered[source]¶
Optional. Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.
- video_chat_scheduled[source]¶
Optional. Service message: video chat scheduled.
Added in version 20.0.
- video_chat_participants_invited[source]¶
Optional. Service message: new participants invited to a video chat.
Added in version 20.0.
- web_app_data[source]¶
Optional. Service message: data sent by a Web App.
Added in version 20.0.
- Type:
- reply_markup[source]¶
Optional. Inline keyboard attached to the message.
login_url
buttons are represented as ordinary url buttons.
- is_topic_message[source]¶
Optional.
True
, if the message is sent to a forum topic.Added in version 20.0.
- Type:
- message_thread_id[source]¶
Optional. Unique identifier of a message thread to which the message belongs; for supergroups only.
Added in version 20.0.
- Type:
- forum_topic_reopened[source]¶
Optional. Service message: forum topic reopened.
Added in version 20.0.
Optional. Service message: General forum topic hidden.
Added in version 20.0.
Optional. Service message: General forum topic unhidden.
Added in version 20.0.
- write_access_allowed[source]¶
Optional. Service message: the user allowed the bot added to the attachment menu to write messages.
Added in version 20.0.
- has_media_spoiler[source]¶
Optional.
True
, if the message media is covered by a spoiler animation.Added in version 20.0.
- Type:
Optional. Service message: users were shared with the bot
Added in version 20.8.
- Type:
Optional. Service message: a chat was shared with the bot.
Added in version 20.1.
- Type:
- giveaway_created[source]¶
Optional. Service message: a scheduled giveaway was created
Added in version 20.8.
- Type:
- giveaway[source]¶
Optional. The message is a scheduled giveaway message
Added in version 20.8.
- Type:
- giveaway_winners[source]¶
Optional. A giveaway with public winners was completed
Added in version 20.8.
- Type:
- giveaway_completed[source]¶
Optional. Service message: a giveaway without public winners was completed
Added in version 20.8.
- external_reply[source]¶
Optional. Information about the message that is being replied to, which may come from another chat or forum topic.
Added in version 20.8.
- quote[source]¶
Optional. For replies that quote part of the original message, the quoted part of the message.
Added in version 20.8.
- Type:
- forward_origin[source]¶
Optional. Information about the original message for forwarded messages
Added in version 20.8.
- Type:
- reply_to_story[source]¶
Optional. For replies to a story, the original story.
Added in version 21.0.
- Type:
- sender_boost_count[source]¶
Optional. If the sender of the message boosted the chat, the number of boosts added by the user.
Added in version 21.0.
- Type:
- business_connection_id[source]¶
Optional. Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.
Added in version 21.1.
- Type:
- sender_business_bot[source]¶
Optional. The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.
Added in version 21.1.
- Type:
- chat_background_set[source]¶
Optional. Service message: chat background set
Added in version 21.2.
- Type:
- paid_media[source]¶
Optional. Message contains paid media; information about the paid media.
Added in version 21.4.
- Type:
- refunded_payment[source]¶
Optional. Message is a service message about a refunded payment, information about the payment.
Added in version 21.4.
- Type:
- build_reply_arguments(quote=None, quote_index=None, target_chat_id=None, allow_sending_without_reply=None, message_thread_id=None)[source]¶
Builds a dictionary with the keys
chat_id
andreply_parameters
. This dictionary can be used to reply to a message with the given quote and target chat.Examples
Usage with
telegram.Bot.send_message()
:await bot.send_message( text="This is a reply", **message.build_reply_arguments(quote="Quoted Text") )
Usage with
reply_text()
, replying in the same chat:await message.reply_text( "This is a reply", do_quote=message.build_reply_arguments(quote="Quoted Text") )
Usage with
reply_text()
, replying in a different chat:await message.reply_text( "This is a reply", do_quote=message.build_reply_arguments( quote="Quoted Text", target_chat_id=-100123456789 ) )
Added in version 20.8.
- Parameters:
quote (
str
, optional) – Passed incompute_quote_position_and_entities()
as parameterquote
to compute quote entities. Defaults toNone
.quote_index (
int
, optional) – Passed incompute_quote_position_and_entities()
as parameterquote_index
to compute quote position. Defaults toNone
.target_chat_id (
int
|str
, optional) – Unique identifier for the target chat or username of the target channel (in the format@channelusername
). Defaults tochat_id
.allow_sending_without_reply (
bool
, optional) – PassTrue
, if the message should be sent even if the specified replied-to message is not found. Will be applied only if the reply happens in the same chat and forum topic.message_thread_id (
int
, optional) – Unique identifier for the target message thread of the forum topic.
- Return type:
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.
Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients.Changed in version 13.10: Spoiler entities are now formatted as HTML.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message caption with caption entities formatted as HTML.
- Return type:
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.Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients.Changed in version 13.10: Spoiler entities are now formatted as HTML.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message caption with caption entities formatted as HTML.
- Return type:
Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.constants.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.
Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Note
'Markdown'
is a legacy mode, retained by Telegram for backward compatibility. You should usecaption_markdown_v2()
Changed in version 20.5: Since custom emoji entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a custom emoji.Changed in version 20.8: Since block quotation entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a block quotation.- Returns:
Message caption with caption entities formatted as Markdown.
- Return type:
- Raises:
ValueError – If the message contains underline, strikethrough, spoiler, blockquote or nested entities.
Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.constants.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.Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Note
'Markdown'
is a legacy mode, retained by Telegram for backward compatibility. You should usecaption_markdown_v2_urled()
instead.Changed in version 20.5: Since custom emoji entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a custom emoji.Changed in version 20.8: Since block quotation entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a block quotation.- Returns:
Message caption with caption entities formatted as Markdown.
- Return type:
- Raises:
ValueError – If the message contains underline, strikethrough, spoiler, blockquote or nested entities.
Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.constants.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.
Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message caption with caption entities formatted as Markdown.
- Return type:
Creates an Markdown-formatted string from the markup entities found in the message’s caption using
telegram.constants.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.Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message caption with caption entities formatted as Markdown.
- Return type:
- property chat_id[source]¶
Shortcut for
telegram.Chat.id
forchat
.- Type:
- async close_forum_topic(*, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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()
.Added in version 20.0.
- compute_quote_position_and_entities(quote, index=None)[source]¶
Use this function to compute position and entities of a quote in the message text or caption. Useful for filling the parameters
quote_position
andquote_entities
oftelegram.ReplyParameters
when replying to a message.Example
Given a message with the text
"Hello, world! Hello, world!"
, the following code will return the position and entities of the second occurrence of"Hello, world!"
.message.compute_quote_position_and_entities("Hello, world!", 1)
Added in version 20.8.
- Parameters:
- Returns:
On success, a tuple containing information about quote position and entities is returned.
- Return type:
tuple[
int
,None
| tuple[MessageEntity
, …]]- Raises:
RuntimeError – If the message has neither
text
norcaption
.ValueError – If the requested index of quote doesn’t exist in the message.
- async copy(chat_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_markup=None, protect_content=None, message_thread_id=None, reply_parameters=None, show_caption_above_media=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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:
- async delete(*, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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()
.
- async delete_forum_topic(*, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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()
.Added in version 20.0.
Shortcut for:
await bot.edit_message_caption( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_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.Changed in version 21.4: Now also passes
business_connection_id
.- Returns:
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type:
- async edit_forum_topic(name=None, icon_custom_emoji_id=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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()
.Added in version 20.0.
- async edit_live_location(latitude=None, longitude=None, reply_markup=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, live_period=None, *, location=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.edit_message_live_location( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_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.Changed in version 21.4: Now also passes
business_connection_id
.- Returns:
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type:
- async edit_media(media, reply_markup=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.edit_message_media( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_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.Changed in version 21.4: Now also passes
business_connection_id
.- Returns:
On success, if edited message is not an inline message, the edited Message is returned, otherwise
True
is returned.- Return type:
- async edit_reply_markup(reply_markup=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.edit_message_reply_markup( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_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.Changed in version 21.4: Now also passes
business_connection_id
.- Returns:
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type:
- async edit_text(text, parse_mode=None, reply_markup=None, entities=None, link_preview_options=None, *, disable_web_page_preview=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.edit_message_text( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_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.Changed in version 21.4: Now also passes
business_connection_id
.- 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[source]¶
If the message is a user generated content which is not a plain text message, this property is set to this content. It may be one of
list[
telegram.PhotoSize
]
Otherwise
None
is returned.See also
Changed in version 20.0:
dice
,passport_data
andpoll
are now also considered to be an attachment.Changed in version 21.4:
paid_media
is now also considered to be an attachment.Deprecated since version 21.4:
successful_payment
will be removed in future major versions.
- async forward(chat_id, disable_notification=None, protect_content=None, message_thread_id=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.forward_message( 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.ChatFullInfo.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:
- async get_game_high_scores(user_id, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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:
tuple[
telegram.GameHighScore
]
- property id[source]¶
Shortcut for
message_id
.Added in version 20.0.
- Type:
- property link[source]¶
Convenience property. If the chat of the message is not a private chat or normal group, returns a t.me link of the message.
Changed in version 20.3: For messages that are replies or part of a forum topic, the link now points to the corresponding thread view.
- Type:
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
]
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:
- Raises:
RuntimeError – If the message has no caption.
- parse_entities(types=None)[source]¶
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)[source]¶
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:
- Raises:
RuntimeError – If the message has no text.
- async pin(disable_notification=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.pin_chat_message( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.pin_chat_message()
.Changed in version 21.5: Now also passes
business_connection_id
totelegram.Bot.pin_chat_message()
.
- async reopen_forum_topic(*, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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()
.Added in version 20.0.
- async reply_animation(animation, duration=None, width=None, height=None, caption=None, parse_mode=None, disable_notification=None, reply_markup=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None, thumbnail=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, show_caption_above_media=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_animation( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_animation()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_audio(audio, duration=None, performer=None, title=None, caption=None, disable_notification=None, reply_markup=None, parse_mode=None, caption_entities=None, protect_content=None, message_thread_id=None, thumbnail=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_audio( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_audio()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_chat_action(action, message_thread_id=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_chat_action( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_chat_action()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.Added in version 13.2.
- async reply_contact(phone_number=None, first_name=None, last_name=None, disable_notification=None, reply_markup=None, vcard=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, contact=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_contact( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_contact()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_copy(from_chat_id, message_id, caption=None, parse_mode=None, caption_entities=None, disable_notification=None, reply_markup=None, protect_content=None, message_thread_id=None, reply_parameters=None, show_caption_above_media=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.copy_message( chat_id=message.chat.id, message_thread_id=update.effective_message.message_thread_id, message_id=message_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.copy_message()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Added in version 13.1.
Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, returns the MessageId of the sent message.
- Return type:
- async reply_dice(disable_notification=None, reply_markup=None, emoji=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_dice( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_dice()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_document(document, caption=None, disable_notification=None, reply_markup=None, parse_mode=None, disable_content_type_detection=None, caption_entities=None, protect_content=None, message_thread_id=None, thumbnail=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_document( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_document()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_game(game_short_name, disable_notification=None, reply_markup=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_game( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_game()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
Added in version 13.2.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_html(text, disable_notification=None, reply_markup=None, entities=None, protect_content=None, message_thread_id=None, link_preview_options=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, disable_web_page_preview=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_message( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, parse_mode=ParseMode.HTML, business_connection_id=self.business_connection_id, *args, **kwargs, )
Sends a message with HTML formatting.
For the documentation of the arguments, please see
telegram.Bot.send_message()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async 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_markup=None, provider_data=None, send_phone_number_to_provider=None, send_email_to_provider=None, max_tip_amount=None, suggested_tip_amounts=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_invoice( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_invoice()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.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.Added in version 13.2.
Changed in version 13.5: As of Bot API 5.2, the parameter
start_parameter
is optional.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_location(latitude=None, longitude=None, disable_notification=None, reply_markup=None, live_period=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, location=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_location( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_location()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_markdown(text, disable_notification=None, reply_markup=None, entities=None, protect_content=None, message_thread_id=None, link_preview_options=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, disable_web_page_preview=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_message( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, parse_mode=ParseMode.MARKDOWN, business_connection_id=self.business_connection_id, *args, **kwargs, )
Sends a message with Markdown version 1 formatting.
For the documentation of the arguments, please see
telegram.Bot.send_message()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.Note
'Markdown'
is a legacy mode, retained by Telegram for backward compatibility. You should usereply_markdown_v2()
instead.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_markdown_v2(text, disable_notification=None, reply_markup=None, entities=None, protect_content=None, message_thread_id=None, link_preview_options=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, disable_web_page_preview=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_message( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, parse_mode=ParseMode.MARKDOWN_V2, business_connection_id=self.business_connection_id, *args, **kwargs, )
Sends a message with markdown version 2 formatting.
For the documentation of the arguments, please see
telegram.Bot.send_message()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_media_group(media, disable_notification=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None, caption=None, parse_mode=None, caption_entities=None)[source]¶
Shortcut for:
await bot.send_media_group( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_media_group()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
An array of the sent Messages.
- Return type:
tuple[
telegram.Message
]- Raises:
- async reply_paid_media(star_count, media, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, disable_notification=None, protect_content=None, reply_parameters=None, reply_markup=None, payload=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_paid_media( chat_id=message.chat.id, business_connection_id=message.business_connection_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.send_paid_media()
.Added in version 21.7.
- Keyword Arguments:
do_quote (
bool
|dict
, optional) – If set toTrue
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.- Returns:
On success, the sent message is returned.
- Return type:
- async reply_photo(photo, caption=None, disable_notification=None, reply_markup=None, parse_mode=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, show_caption_above_media=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_photo( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_photo()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_poll(question, options, is_anonymous=None, type=None, allows_multiple_answers=None, correct_option_id=None, is_closed=None, disable_notification=None, reply_markup=None, explanation=None, explanation_parse_mode=None, open_period=None, close_date=None, explanation_entities=None, protect_content=None, message_thread_id=None, reply_parameters=None, question_parse_mode=None, question_entities=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_poll( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_poll()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_sticker(sticker, disable_notification=None, reply_markup=None, protect_content=None, message_thread_id=None, emoji=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_sticker( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_sticker()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_text(text, parse_mode=None, disable_notification=None, reply_markup=None, entities=None, protect_content=None, message_thread_id=None, link_preview_options=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, disable_web_page_preview=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_message( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_message()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_venue(latitude=None, longitude=None, title=None, address=None, foursquare_id=None, disable_notification=None, reply_markup=None, foursquare_type=None, google_place_id=None, google_place_type=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, venue=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_venue( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_venue()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_video(video, duration=None, caption=None, disable_notification=None, reply_markup=None, width=None, height=None, parse_mode=None, supports_streaming=None, caption_entities=None, protect_content=None, message_thread_id=None, has_spoiler=None, thumbnail=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, show_caption_above_media=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_video( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_video()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_video_note(video_note, duration=None, length=None, disable_notification=None, reply_markup=None, protect_content=None, message_thread_id=None, thumbnail=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_video_note( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_video_note()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async reply_voice(voice, duration=None, caption=None, disable_notification=None, reply_markup=None, parse_mode=None, caption_entities=None, protect_content=None, message_thread_id=None, reply_parameters=None, message_effect_id=None, allow_paid_broadcast=None, *, reply_to_message_id=None, allow_sending_without_reply=None, filename=None, quote=None, do_quote=None, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.send_voice( update.effective_message.chat_id, message_thread_id=update.effective_message.message_thread_id, business_connection_id=self.business_connection_id, *args, **kwargs, )
For the documentation of the arguments, please see
telegram.Bot.send_voice()
.Changed in version 21.1: If
message_thread_id
is not provided, this will reply to the same thread (topic) of the original message.- Keyword Arguments:
If set to
True
, the reply is sent as an actual reply to this message. Ifreply_to_message_id
is passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats.Deprecated since version 20.8: This argument is deprecated in favor of
do_quote
do_quote (
bool
|dict
, optional) –If set to
True
, the replied message is quoted. For a dict, it must be the output ofbuild_reply_arguments()
to specify exactreply_parameters
. Ifreply_to_message_id
orreply_parameters
are passed, this parameter will be ignored. Default:True
in group chats andFalse
in private chats. Mutually exclusive withquote
.Added in version 20.8.
- Returns:
On success, instance representing the message posted.
- Return type:
- async set_game_score(user_id, score, force=None, disable_edit_message=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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:
- async set_reaction(reaction=None, is_big=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.set_message_reaction(chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs)
For the documentation of the arguments, please see
telegram.Bot.set_message_reaction()
.Added in version 20.8.
- async stop_live_location(reply_markup=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.stop_message_live_location( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_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.Changed in version 21.4: Now also passes
business_connection_id
.- Returns:
On success, if edited message is sent by the bot, the edited Message is returned, otherwise
True
is returned.- Return type:
- async stop_poll(reply_markup=None, *, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.stop_poll( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.stop_poll()
.Changed in version 21.4: Now also passes
business_connection_id
.- Returns:
On success, the stopped Poll with the final results is returned.
- Return type:
- property text_html[source]¶
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.
Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients.Changed in version 13.10: Spoiler entities are now formatted as HTML.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message text with entities formatted as HTML.
- Return type:
- property text_html_urled[source]¶
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.Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients.Changed in version 13.10: Spoiler entities are now formatted as HTML.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message text with entities formatted as HTML.
- Return type:
- property text_markdown[source]¶
Creates an Markdown-formatted string from the markup entities found in the message using
telegram.constants.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.
Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Note
'Markdown'
is a legacy mode, retained by Telegram for backward compatibility. You should usetext_markdown_v2()
instead.Changed in version 20.5: Since custom emoji entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a custom emoji.Changed in version 20.8: Since block quotation entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a block quotation.- Returns:
Message text with entities formatted as Markdown.
- Return type:
- Raises:
ValueError – If the message contains underline, strikethrough, spoiler, blockquote or nested entities.
- property text_markdown_urled[source]¶
Creates an Markdown-formatted string from the markup entities found in the message using
telegram.constants.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.Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Note
'Markdown'
is a legacy mode, retained by Telegram for backward compatibility. You should usetext_markdown_v2_urled()
instead.Changed in version 20.5: Since custom emoji entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a custom emoji.Changed in version 20.8: Since block quotation entities are not supported by
MARKDOWN
, this method now raises aValueError
when encountering a block quotation.- Returns:
Message text with entities formatted as Markdown.
- Return type:
- Raises:
ValueError – If the message contains underline, strikethrough, spoiler, blockquote or nested entities.
- property text_markdown_v2[source]¶
Creates an Markdown-formatted string from the markup entities found in the message using
telegram.constants.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.
Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message text with entities formatted as Markdown.
- Return type:
- property text_markdown_v2_urled[source]¶
Creates an Markdown-formatted string from the markup entities found in the message using
telegram.constants.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.Warning
The return value of this property is a best-effort approach. Unfortunately, it can not be guaranteed that sending a message with the returned string will render in the same way as the original message produces the same
entities
/caption_entities
as the original message. For example, Telegram recommends that entities of typeBLOCKQUOTE
andPRE
should start and end on a new line, but does not enforce this and leaves rendering decisions up to the clients. Moreover, markdown formatting is inherently less expressive than HTML, so some edge cases may not be coverable at all. For example, markdown formatting can not specify two consecutive block quotes without a blank line in between, but HTML can.Changed in version 13.10: Spoiler entities are now formatted as Markdown V2.
Changed in version 20.3: Custom emoji entities are now supported.
Changed in version 20.8: Blockquote entities are now supported.
- Returns:
Message text with entities formatted as Markdown.
- Return type:
- async unpin(*, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await bot.unpin_chat_message( chat_id=message.chat_id, message_id=message.message_id, business_connection_id=message.business_connection_id, *args, **kwargs )
For the documentation of the arguments, please see
telegram.Bot.unpin_chat_message()
.Changed in version 21.5: Now also passes
business_connection_id
totelegram.Bot.pin_chat_message()
.
- async unpin_all_forum_topic_messages(*, read_timeout=None, write_timeout=None, connect_timeout=None, pool_timeout=None, api_kwargs=None)[source]¶
Shortcut for:
await 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()
.Added in version 20.0.