Message#

class pyrogram.types.Message#

A message.

Parameters:
  • id (int) – Unique message identifier inside this chat.

  • message_thread_id (int, optional) – Unique identifier of a message thread to which the message belongs; for supergroups only

  • 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.

  • date (datetime, optional) – Date the message was sent.

  • 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.

  • chat (Chat, optional) – Conversation the message belongs to.

  • forward_origin (MessageOrigin, optional) – Information about the original message for forwarded messages

  • is_topic_message (bool, optional) – True, if the message is sent to a forum topic.

  • is_automatic_forward (bool, optional) – True, if the message is a channel post that was automatically forwarded to the connected discussion group.

  • reply_to_message_id (int, optional) – The id of the message which this message directly 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.

  • 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) – For replies that quote part of the original message, the quoted part of the message

  • reply_to_story (Story, optional) – For replies to a story, the original story

  • via_bot (User) – The information of the bot that generated the message from an inline query of a user.

  • edit_date (datetime, optional) – Date the message was last edited.

  • has_protected_content (bool, optional) – True, if the message can’t be forwarded.

  • 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

  • media_group_id (str, 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.

  • 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.

  • link_preview_options (LinkPreviewOptions, optional) – Options used for link preview generation for the message, if it is a text message and link preview options were changed

  • effect_id (str, optional) – Unique identifier of the message effect added to the message. Use get_message_effects() to get the list of available message effect ids.

  • animation (Animation, optional) – Message is an animation, information about the animation.

  • audio (Audio, optional) – Message is an audio file, information about the file.

  • document (Document, optional) – Message is a general file, information about the file.

  • paid_media (PaidMediaInfo, optional) – Message contains paid media; information about the paid media.

  • photo (Photo, optional) – Message is a photo, information about the photo.

  • sticker (Sticker, optional) – Message is a sticker, information about the sticker.

  • story (Story, optional) – Message might be a forwarded story.

  • video (Video, optional) – Message is a video, information about the video.

  • video_note (VideoNote, optional) – Message is a video note, information about the video message.

  • voice (Voice, optional) – Message is a voice message, information about the file.

  • 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.

  • caption_entities (List of MessageEntity, optional) – For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption.

  • show_caption_above_media (bool, optional) – True, if the caption must be shown above the message media.

  • has_media_spoiler (bool, optional) – True, if the message media is covered by a spoiler animation.

  • contact (Contact, optional) – Message is a shared contact, information about the contact.

  • dice (Dice, optional) – A dice containing a value that is randomly generated by Telegram.

  • game (Game, optional) – Message is a game, information about the game.

  • poll (Poll, optional) – Message is a native poll, information about the poll.

  • venue (Venue, optional) – Message is a venue, information about the venue.

  • location (Location, optional) – Message is a shared location, information about the location.

  • 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).

  • 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.

  • message_auto_delete_timer_changed (MessageAutoDeleteTimerChanged, optional) – Service message: auto-delete timer settings changed in the chat.

  • 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.

  • invoice (Invoice, optional) – Message is an invoice for a payment, information about the invoice. More about payments »

  • successful_payment (SuccessfulPayment, optional) – Message is a service message about a successful payment, information about the payment. More about payments

  • refunded_payment (RefundedPayment, optional) – Message is a service message about a refunded payment, information about the payment. More about payments

  • users_shared (UsersShared, optional) – Service message: users were shared with the bot

  • chat_shared (ChatShared, optional) – Service message: a chat was shared with the bot

  • boost_added (ChatBoostAdded, optional) – Service message: user boosted the chat

  • forum_topic_created (ForumTopicCreated, optional) – Service message: forum topic created

  • forum_topic_edited (ForumTopicEdited, optional) – Service message: forum topic edited

  • forum_topic_closed (ForumTopicClosed, optional) – Service message: forum topic closed

  • forum_topic_reopened (ForumTopicReopened, optional) – Service message: forum topic reopened

  • general_forum_topic_hidden (GeneralForumTopicHidden, optional) – Service message: the ‘General’ forum topic hidden

  • general_forum_topic_unhidden (GeneralForumTopicUnhidden, optional) – Service message: the ‘General’ forum topic unhidden

  • giveaway_created (GiveawayCreated, optional) – Service message: a scheduled giveaway was created

  • giveaway (Giveaway, optional) – The message is a scheduled giveaway message

  • giveaway_winners (GiveawayWinners, optional) – A giveaway with public winners was completed

  • giveaway_completed (GiveawayCompleted, optional) – Service message: a giveaway without public winners was completed

  • video_chat_scheduled (VideoChatScheduled, optional) – Service message: voice chat scheduled.

  • video_chat_started (VideoChatStarted, optional) – Service message: the voice chat started.

  • video_chat_ended (VideoChatEnded, optional) – Service message: the voice chat has ended.

  • video_chat_participants_invited (VideoChatParticipantsInvited, optional) – Service message: new members were invited to the voice chat.

  • web_app_data (WebAppData, optional) – Service message: web app data sent to the 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.

  • 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.

  • mentioned (bool, optional) – The message contains a mention.

  • service (MessageServiceType, optional) – The message is a service message. This field will contain the enumeration type of the service message. You can use service = 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 use media = getattr(message, message.media.value) to access the media message.

  • web_page (WebPage, optional) – Message was sent with a webpage preview.

  • game_high_score (GameHighScore, optional) – The game score for a user. The reply_to_message field will contain the game Message.

  • views (int, optional) – View counter for channel posts.

    forwards (int, optional): Forward counter for channel posts.

  • 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.

  • 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 using command.

  • reactions (List of Reaction) – List of the reactions to this message.

  • custom_action (str, optional) – Custom action (most likely not supported by the current layer, an upgrade might be needed)

  • gift_code (GiftCode, optional) – Contains a Telegram Premium giftcode link.

  • gifted_premium (GiftedPremium, optional) – Info about a gifted Telegram Premium subscription

  • gifted_stars (GiftedStars, optional) – Info about gifted Telegram Stars

  • contact_registered (ContactRegistered, optional) – A service message that a contact has registered with Telegram.

  • chat_join_type (ChatJoinType, optional) – The message is a service message of the type NEW_CHAT_MEMBERS. This field will contain the enumeration type of how the user had joined the chat.

  • screenshot_taken (ScreenshotTaken, optional) – A service message that a screenshot of a message in the chat has been taken.

  • link (str, property) – Generate a link to this message, only for supergroups and channels. Can be None if the message cannot have a link.