Message¶
- class pyrogram.types.Message¶
A message.
- Parameters:
id (
int) – Unique message identifier inside this chat.from_user (
User, optional) – Sender, empty for messages sent to channels.sender_chat (
Chat, optional) – Sender of the message, sent on behalf of a chat. The channel itself for channel messages. The supergroup itself for messages from anonymous group administrators. The linked channel for messages automatically forwarded to the discussion group.sender_boost_count (
int, optional) – If the sender of the message boosted the chat, the number of boosts added by the user.sender_business_bot (
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.sender_tag (
str, optional) – Tag or custom title of the sender of the message. For supergroups only.date (
datetime, optional) – Date the message was sent.chat (
Chat, optional) – Conversation the message belongs to.topic_message (
bool, optional) – True, if the message is a forum topic message.automatic_forward (
bool, optional) – True, if the message is a channel post that was automatically forwarded to the connected discussion group.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.topic (
ForumTopic, optional) – Topic the message belongs to.forward_origin (
MessageOrigin, optional) – Information about the original message for forwarded messages.message_thread_id (
int, optional) – Unique identifier of a message thread to which the message belongs. For forums only.direct_messages_topic_id (
int, optional) – Unique identifier of a topic in a channel direct messages chat administered by the current user. For direct chats only.effect_id (
int, optional) – Unique identifier of the message effect. For private chats only.reply_to_message_id (
int, optional) – The id of the message which this message directly replied to.reply_to_story_id (
int, optional) – The id of the story which this message directly replied to.reply_to_story_user_id (
int, optional) – The id of the story sender which this message directly replied to.reply_to_top_message_id (
int, optional) – The id of the first message which started this message thread.reply_to_poll_option_id (
str, optional) – Persistent identifier of the specific poll option that is being replied to.reply_to_message (
Message, optional) – For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.reply_to_story (
Story, optional) – For replies, the original story.reply_to_checklist_task_id (
int, optional) – Identifier of the specific checklist task that is being replied to.mentioned (
bool, optional) – The message contains a mention.empty (
bool, optional) – The message is empty. A message can be empty in case it was deleted or you tried to retrieve a message that doesn’t exist yet.service (
MessageServiceType, optional) – The message is a service message. This field will contain the enumeration type of the service message. You can useservice = getattr(message, message.service.value)to access the service message.media (
MessageMediaType, optional) – The message is a media message. This field will contain the enumeration type of the media message. You can usemedia = getattr(message, message.media.value)to access the media message.paid_media (
PaidMediaInfo, optional) – The message is a paid media message.checklist (
Checklist, optional) – The message is a checklist message.show_caption_above_media (
bool, optional) – If True, caption must be shown above the message media.edit_date (
datetime, optional) – Date the message was last edited.edit_hidden (
bool, optional) – The message shown as not modified. A message can be not modified in case it has received a reaction.media_group_id (
int, optional) – The unique identifier of a media message group this message belongs to.author_signature (
str, optional) – Signature of the post author for messages in channels, or the custom title of an anonymous group administrator.is_paid_post (
bool, optional) – True, if the message is a paid post. Note that such posts must not be deleted for 24 hours to receive the payment and can’t be edited.has_protected_content (
bool, optional) – True, if the message can’t be forwarded.has_media_spoiler (
bool, optional) – True, if the message media is covered by a spoiler animation.text (
str, optional) – For text messages, the actual UTF-8 text of the message, 0-4096 characters. If the message contains entities (bold, italic, …) you can access text.markdown or text.html to get the marked up message text. In case there is no entity, the fields will contain the same text as text.entities (List of
MessageEntity, optional) – For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text.caption_entities (List of
MessageEntity, optional) – For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.audio (
Audio, optional) – Message is an audio file, information about the file.document (
Document, optional) – Message is a general file, information about the file.photo (
Photo, optional) – Message is a photo, information about the photo.sticker (
Sticker, optional) – Message is a sticker, information about the sticker.animation (
Animation, optional) – Message is an animation, information about the animation.game (
Game, optional) – Message is a game, information about the game.giveaway (
Giveaway, optional) – Message is a giveaway, information about the giveaway.invoice (
Invoice, optional) – Message is a invoice, information about the invoice. More about payments »story (
Story, optional) – Message is a story, information about the story.video (
Video, optional) – Message is a video, information about the video.video_processing_pending (
bool, optional) – True, if the video is still processing.voice (
Voice, optional) – Message is a voice message, information about the file.video_note (
VideoNote, optional) – Message is a video note, information about the video message.caption (
str, optional) – Caption for the audio, document, photo, video or voice, 0-1024 characters. If the message contains caption entities (bold, italic, …) you can access caption.markdown or caption.html to get the marked up caption text. In case there is no caption entity, the fields will contain the same text as caption.contact (
Contact, optional) – Message is a shared contact, information about the contact.location (
Location, optional) – Message is a shared location, information about the location.venue (
Venue, optional) – Message is a venue, information about the venue.web_page (
WebPage, optional) – Message was sent with a webpage preview.link_preview_options (
LinkPreviewOptions, optional) – Options used for link preview generation for the message.poll (
Poll, optional) – Message is a native poll, information about the poll.dice (
Dice, optional) – A dice containing a value that is randomly generated by Telegram.new_chat_members (List of
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).left_chat_member (
User, optional) – A member was removed from the group, information about them (this member may be the bot itself).chat_owner_left (
ChatOwnerLeft, optional) – Service message: chat owner has left.chat_owner_changed (
ChatOwnerChanged, optional) – Service message: chat owner has changed.chat_join_type (
ChatJoinType, optional) – This field will contain the enumeration type of how the user had joined the chat.new_chat_title (
str, optional) – A chat title was changed to this value.new_chat_photo (
Photo, optional) – A chat photo was change to this value.delete_chat_photo (
bool, optional) – Service message: the chat photo was deleted.group_chat_created (
bool, optional) – Service message: the group has been created.supergroup_chat_created (
bool, optional) – Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_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 in reply_to_message if someone replies to a very first message in a channel.migrate_to_chat_id (
int, optional) – The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.migrate_from_chat_id (
int, optional) – The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.pinned_message (
Message, 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.game_high_score (
GameHighScore, optional) – The game score for a user. The reply_to_message field will contain the game Message.views (
int, optional) – Channel post views.forwards (
int, optional) – Channel post forwards.via_bot (
User) – The information of the bot that generated the message from an inline query of a user.outgoing (
bool, optional) – Whether the message is incoming or outgoing. Messages received from other chats are incoming (outgoing is False). Messages sent from yourself to other chats are outgoing (outgoing is True). An exception is made for your own personal chat; messages sent there will be incoming.external_reply (
ExternalReplyInfo, optional) – Information about the message that is being replied to, which may come from another chat or forum topic.quote (
TextQuote, optional) – Chosen quote from the replied message.matches (List of regex Matches, *optional*) – A list containing all Match Objects that match the text of this message. Only applicable when using
Filters.regex.command (List of
str, optional) – A list containing the command and its arguments, if any. E.g.: “/start 1 2 3” would produce [“start”, “1”, “2”, “3”]. Only applicable when usingcommand.forum_topic_created (
ForumTopicCreated, optional) – Service message: forum topic createdforum_topic_closed (
ForumTopicClosed, optional) – Service message: forum topic closedforum_topic_reopened (
ForumTopicReopened, optional) – Service message: forum topic reopenedforum_topic_edited (
ForumTopicEdited, optional) – Service message: forum topic editedgeneral_forum_topic_hidden (
GeneralForumTopicHidden, optional) – Service message: general forum topic hiddengeneral_forum_topic_unhidden (
GeneralForumTopicUnhidden, optional) – Service message: general forum topic unhiddenvideo_chat_scheduled (
VideoChatScheduled, optional) – Service message: voice chat scheduled.history_cleared (
HistoryCleared, optional) – Service message: history clearedvideo_chat_started (
VideoChatStarted, optional) – Service message: the voice chat started.video_chat_ended (
VideoChatEnded, optional) – Service message: the voice chat has ended.video_chat_members_invited (
VoiceChatParticipantsInvited, optional) – Service message: new members were invited to the voice chat.phone_call_started (
PhoneCallStarted, optional) – Service message: phone call started.phone_call_ended (
PhoneCallEnded, optional) – Service message: phone call ended.web_app_data (
WebAppData, optional) – Service message: web app data sent to the bot.paid_messages_refunded (
PaidMessagesRefunded, optional) – Service message: paid messages refunded.paid_messages_price_changed (
PaidMessagesPriceChanged, optional) – Service message: paid messages price.direct_message_price_changed (
DirectMessagePriceChanged, optional) – Service message: direct messages price.checklist_tasks_done (
ChecklistTasksDone, optional) – Service message: checklist tasks done.checklist_tasks_added (
ChecklistTasksAdded, optional) – Service message: checklist tasks added.premium_gift_code (
PremiumGiftCode, optional) – Service message: premium gift code information.gifted_premium (
GiftedPremium, optional) – Service message: gifted premium information.gifted_stars (
GiftedStars, optional) – Service message: gifted stars information.gifted_ton (
GiftedTon, optional) – Service message: gifted ton information.gift (
Gift, optional) – Service message: star gift information.is_prepaid_upgrade (
bool, optional) – True, if the messages is about prepaid upgrade of the gift by another user.is_from_auction (
bool, optional) – True, if the message is a notification about a gift won on an auction.suggest_profile_photo (
Photo, optional) – Service message: suggested profile photo.suggest_birthday (
Birthday, optional) – Service message: suggested birthday.users_shared (
UsersShared, optional) – Service message: users shared information.chat_shared (
ChatShared, optional) – Service message: chat shared information.successful_payment (
SuccessfulPayment, optional) – Service message: successful payment.refunded_payment (
RefundedPayment, optional) – Service message: refunded payment.suggested_post_approval_failed (
SuggestedPostApprovalFailed, optional) – Service message: suggested post approval failed.suggested_post_approved (
SuggestedPostApproved, optional) – Service message: suggested post approved.suggested_post_declined (
SuggestedPostDeclined, optional) – Service message: suggested post declined.suggested_post_paid (
SuggestedPostPaid, optional) – Service message: suggested post paid.suggested_post_refunded (
SuggestedPostRefunded, optional) – Service message: suggested post refunded.giveaway_created (
bool, optional) – Service message: giveaway launched.giveaway_winners (
GiveawayWinners, optional) – A giveaway with public winners was completed.giveaway_completed (
GiveawayCompleted, optional) – Service message: a giveaway without public winners was completed.managed_bot_created (
ManagedBotCreated, optional) – Service message: user created a bot that will be managed by the current bot.poll_option_added (
PollOptionAdded, optional) – Service message: answer option was added to a poll.poll_option_deleted (
PollOptionDeleted, optional) – Service message: answer option was deleted from a poll.chat_set_theme (
ChatTheme, optional) – Service message: The chat theme was changed.chat_set_background (
ChatBackground, optional) – Service message: The chat background was changed.set_message_auto_delete_time (
int, optional) – Service message: The auto-delete or self-destruct timer for messages in the chat has been changed.chat_boost (
int, optional) – Service message: The chat was boosted by the sender of the message. Number of times the chat was boosted.write_access_allowed (
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 requestWriteAccessconnected_website (
str, optional) – The domain name of the website on which the user has logged in. More about Telegram Logincontact_registered (
ContactRegistered, optional) – Service message: Contact registered in Telegram.proximity_alert_triggered (
ProximityAlertTriggered, optional) – Service message: A user in the chat came within proximity alert range.giveaway_prize_stars (
GiveawayPrizeStars, optional) – Service message: Stars were received by the current user from a giveaway.screenshot_taken (
ScreenshotTaken, optional) – Service message: screenshot of a message in the chat has been taken.upgraded_gift_purchase_offer (
UpgradedGiftPurchaseOffer, optional) – Service message: An offer to purchase an upgraded gift was sent or received.upgraded_gift_purchase_offer_rejected (
UpgradedGiftPurchaseOfferRejected, optional) – Service message: An offer to purchase a gift was rejected or expired.chat_has_protected_content_toggled (
ChatHasProtectedContentToggled, optional) – Service message: Anhas_protected_contentsetting was changed or request to change it was rejected in a chat.chat_has_protected_content_disable_requested (
ChatProtectedContentDisableRequested, optional) – Service message: An process requested to disablehas_protected_contentin a chat.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. This update may at times be triggered by unavailable changes to message fields that are either unavailable or not actively used by the current bot.reply_markup (
InlineKeyboardMarkup|ReplyKeyboardMarkup|ReplyKeyboardRemove|ForceReply, optional) – Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.reactions (
MessageReactions) – Reactions of this message.send_paid_messages_stars (
int, optional) – The number of Telegram Stars the sender paid to send the message.raw (
Message, optional) – The raw message object, as received from the Telegram API.link (
str, property) – Generate a link to this message, only for groups and channels.content (
str, property) – The text or caption content of the message.unread_media (
bool, optional) – True, if there are unread media attachments in this message.silent (
bool, optional) – True, if the message sent without notification.legacy (
bool, optional) – True, if the message is a legacy message. This means that the message is based on the old layer and should be refetched with the new layer.pinned (
bool, optional) – True, if the message is pinned.restriction_reason (List of
RestrictionReason, optional) – Contains a list of human-readable description of the reason why access to this message must be restricted.fact_check (
FactCheck, optional) – Information about fact-check added to the message.suggested_post_info (
SuggestedPostInfo, optional) – Information about the suggested post.channel_post (
bool, optional) – True, if the message is a channel post.repeat_period (
int, optional) – Period after which the message will be sent again in seconds.summary_language_code (
str, optional) – IETF language tag of the message language on which it can be summarized. None if summary isn’t available for the message.