Available Types

All Pyrogram types listed here are accessible through the main package directly.

from pyrogram import User, Message, ...

Note

Optional fields may not exist when irrelevant – i.e.: they will contain the value of None and aren’t shown when, for example, using print().


Details

class pyrogram.User

A Telegram user or bot.

Parameters
  • id (int) – Unique identifier for this user or bot.

  • is_self (bool) – True, if this user is you yourself.

  • is_contact (bool) – True, if this user is in your contacts.

  • is_mutual_contact (bool) – True, if you both have each other’s contact.

  • is_deleted (bool) – True, if this user is deleted.

  • is_bot (bool) – True, if this user is a bot.

  • is_verified (bool) – True, if this user has been verified by Telegram.

  • is_restricted (bool) – True, if this user has been restricted. Bots only. See restriction_reason for details.

  • is_support (bool) – True, if this user is part of the Telegram support team.

  • is_scam (bool) – True, if this user has been flagged for scam.

  • first_name (str) – User’s or bot’s first name.

  • status (UserStatus, optional) – User’s Last Seen status. Empty for bots.

  • last_name (str, optional) – User’s or bot’s last name.

  • username (str, optional) – User’s or bot’s username.

  • language_code (str, optional) – IETF language tag of the user’s language.

  • phone_number (str, optional) – User’s phone number.

  • photo (ChatPhoto, optional) – User’s or bot’s current profile photo. Suitable for downloads only.

  • restriction_reason (str, optional) – The reason why this bot might be unavailable to some users. This field is available only in case is_restricted is True.

class pyrogram.UserStatus

A User status (Last Seen privacy).

Note

You won’t see exact last seen timestamps for people with whom you don’t share your own. Instead, you get “recently”, “within_week”, “within_month” or “long_time_ago” fields set.

Parameters
  • user_id (int) – User’s id.

  • online (bool, optional) – True if the user is online in this very moment, None otherwise. If True, the “date” field will be also set containing the online expiration date (i.e.: the date when a user will automatically go offline in case of no action by his client).

  • offline (bool, optional) – True if the user is offline in this moment and has the Last Seen privacy setting public, None otherwise. If True, the “date” field will be also set containing the last seen date (i.e.: the date when a user was online the last time).

  • date (int, optional) – Exact date in unix time. Available only in case “online” or “offline” equals to True.

  • recently (bool, optional) – True for users with hidden Last Seen privacy that have been online between 1 second and 2-3 days ago, None otherwise.

  • within_week (bool, optional) – True for users with hidden Last Seen privacy that have been online between 2-3 and seven days ago, None otherwise.

  • within_month (bool, optional) – True for users with hidden Last Seen privacy that have been online between 6-7 days and a month ago, None otherwise.

  • long_time_ago (bool, optional) – True for users with hidden Last Seen privacy that have been online more than a month ago (this is also always shown to blocked users), None otherwise.

class pyrogram.Chat

A chat.

Parameters
  • id (int) – Unique identifier for this chat.

  • type (str) – Type of chat, can be either “private”, “bot”, “group”, “supergroup” or “channel”.

  • is_verified (bool, optional) – True, if this chat has been verified by Telegram. Supergroups and channels only.

  • is_restricted (bool, optional) – True, if this chat has been restricted. Supergroups and channels only. See restriction_reason for details.

  • is_scam (bool, optional) – True, if this chat has been flagged for scam. Supergroups and channels only.

  • title (str, optional) – Title, for supergroups, channels and basic group chats.

  • username (str, optional) – Username, for private chats, bots, supergroups and channels if available.

  • first_name (str, optional) – First name of the other party in a private chat, for private chats and bots.

  • last_name (str, optional) – Last name of the other party in a private chat, for private chats.

  • photo (ChatPhoto, optional) – Chat photo. Suitable for downloads only.

  • description (str, optional) – Bio, for private chats and bots or description for groups, supergroups and channels. Returned only in get_chat().

  • invite_link (str, optional) – Chat invite link, for groups, supergroups and channels. Returned only in get_chat().

  • pinned_message (Message, optional) – Pinned message, for groups, supergroups channels and own chat. Returned only in get_chat().

  • sticker_set_name (str, optional) – For supergroups, name of group sticker set. Returned only in get_chat().

  • can_set_sticker_set (bool, optional) – True, if the group sticker set can be changed by you. Returned only in get_chat().

  • members_count (int, optional) – Chat members count, for groups, supergroups and channels only.

  • restriction_reason (str, optional) – The reason why this chat might be unavailable to some users. This field is available only in case is_restricted is True.

  • permissions (ChatPermissions optional) – Information about the chat default permissions, for groups and supergroups.

class pyrogram.ChatPreview

A chat preview.

Parameters
  • title (str) – Title of the chat.

  • photo (ChatPhoto, optional) – Chat photo. Suitable for downloads only.

  • type (str) – Type of chat, can be either, “group”, “supergroup” or “channel”.

  • members_count (int) – Chat members count.

  • members (List of User, optional) – Preview of some of the chat members.

class pyrogram.ChatPhoto

A chat photo.

Parameters
  • small_file_id (str) – Unique file identifier of small (160x160) chat photo. This file_id can be used only for photo download.

  • big_file_id (str) – Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.

class pyrogram.ChatMember

Contains information about one member of a chat.

Parameters
  • user (User) – Information about the user.

  • status (str) – The member’s status in the chat. Can be “creator”, “administrator”, “member”, “restricted”, “left” or “kicked”.

  • date (int, optional) – Date when the user joined, unix time. Not available for creator.

  • is_member (bool, optional) – Restricted only. True, if the user is a member of the chat at the moment of the request.

  • invited_by (User, optional) – Administrators and self member only. Information about the user who invited this member. In case the user joined by himself this will be the same as “user”.

  • promoted_by (User, optional) – Administrators only. Information about the user who promoted this member as administrator.

  • restricted_by (User, optional) – Restricted and kicked only. Information about the user who restricted or kicked this member.

  • permissions (ChatPermissions optional) – Administrators, restricted and kicked members only. Information about the member permissions.

class pyrogram.ChatMembers

Contains information about the members list of a chat.

Parameters
  • total_count (int) – Total number of members the chat has.

  • chat_members (List of ChatMember) – Requested chat members.

class pyrogram.ChatPermissions

A chat default permissions and a single member permissions within a chat.

Some permissions make sense depending on the context: default chat permissions, restricted/kicked member or administrators in groups or channels.

Parameters
  • until_date (int, optional) – Applicable to restricted and kicked members only. Date when user restrictions will be lifted, unix time. 0 means the restrictions will never be lifted (user restricted forever).

  • can_be_edited (bool, optional) – Applicable to administrators only. True, if you are allowed to edit administrator privileges of the user.

  • can_change_info (bool, optional) – Applicable to default chat permissions in private groups and administrators in public groups only. True, if the chat title, photo and other settings can be changed.

  • can_post_messages (bool, optional) – Applicable to channel administrators only. True, if the administrator can post messages in the channel, channels only.

  • can_edit_messages (bool, optional) – Applicable to channel administrators only. True, if the administrator can edit messages of other users and can pin messages, channels only.

  • can_delete_messages (bool, optional) – Applicable to administrators only. True, if the administrator can delete messages of other users.

  • can_restrict_members (bool, optional) – Applicable to administrators only. True, if the administrator can restrict, ban or unban chat members.

  • can_invite_users (bool, optional) – Applicable to default chat permissions and administrators only. True, if new users can be invited to the chat.

  • can_pin_messages (bool, optional) – Applicable to default chat permissions in private groups and administrators in public groups only. True, if messages can be pinned, supergroups only.

  • can_promote_members (bool, optional) – Applicable to administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user).

  • can_send_messages (bool, optional) – Applicable to default chat permissions and restricted members only. True, if text messages, contacts, locations and venues can be sent.

  • can_send_media_messages (bool, optional) – Applicable to default chat permissions and restricted members only. True, if audios, documents, photos, videos, video notes and voice notes can be sent, implies can_send_messages.

  • can_send_other_messages (bool, optional) – Applicable to default chat permissions and restricted members only. True, if animations, games, stickers and inline bot results can be sent, implies can_send_media_messages.

  • can_add_web_page_previews (bool, optional) – Applicable to default chat permissions and restricted members only. True, if web page previews can be attached to text messages, implies can_send_media_messages.

  • can_send_polls (bool, optional) – Applicable to default chat permissions and restricted members only. True, if polls can be sent, implies can_send_media_messages.

class pyrogram.Dialog

A user’s dialog.

Parameters
  • chat (Chat) – Conversation the dialog belongs to.

  • top_message (Message) – The last message sent in the dialog at this time.

  • unread_messages_count (int) – Amount of unread messages in this dialog.

  • unread_mentions_count (int) – Amount of unread messages containing a mention in this dialog.

  • unread_mark (bool) – True, if the dialog has the unread mark set.

  • is_pinned (bool) – True, if the dialog is pinned.

class pyrogram.Dialogs

Contains a user’s dialogs chunk.

Parameters
  • total_count (int) – Total number of dialogs the user has.

  • dialogs (List of Dialog) – Requested dialogs.

class pyrogram.Message

A message.

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

  • date (int, optional) – Date the message was sent in Unix time.

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

  • from_user (User, optional) – Sender, empty for messages sent to channels.

  • forward_from (User, optional) – For forwarded messages, sender of the original message.

  • forward_sender_name (str, optional) – For messages forwarded from users who have hidden their accounts, name of the user.

  • forward_from_chat (Chat, optional) – For messages forwarded from channels, information about the original channel.

  • forward_from_message_id (int, optional) – For messages forwarded from channels, identifier of the original message in the channel.

  • forward_signature (str, optional) – For messages forwarded from channels, signature of the post author if present.

  • forward_date (int, optional) – For forwarded messages, date the original message was sent in Unix time.

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

  • 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 (bool, optional) – The message is a service message. A service message has one and only one of these fields set: left_chat_member, new_chat_title, new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created, migrate_to_chat_id, migrate_from_chat_id, pinned_message.

  • media (bool, optional) – The message is a media message. A media message has one and only one of these fields set: audio, document, photo, sticker, video, animation, voice, video_note, contact, location, venue.

  • edit_date (int, optional) – Date the message was last edited in Unix time.

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

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

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

  • 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 (bool, optional) – Message was sent with a webpage preview. Note: Support for web pages is still basic; a simple boolean is set in case the message contains a web page preview. In future versions this property could turn into a full web page object that contains more details.

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

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

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

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

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

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

class pyrogram.Messages

Contains a chat’s messages.

Parameters
  • total_count (int) – Total number of messages the target chat has.

  • messages (List of Message) – Requested messages.

class pyrogram.MessageEntity

One special entity in a text message. For example, hashtags, usernames, URLs, etc.

Parameters
  • type (str) – Type of the entity. Can be “mention” (@username), “hashtag”, “cashtag”, “bot_command”, “url”, “email”, “phone_number”, “bold” (bold text), italic (italic text), “code” (monowidth string), “pre” (monowidth block), “text_link” (for clickable text URLs), “text_mention” (for users without usernames).

  • offset (int) – Offset in UTF-16 code units to the start of the entity.

  • length (int) – Length of the entity in UTF-16 code units.

  • url (str, optional) – For “text_link” only, url that will be opened after user taps on the text.

  • user (User, optional) – For “text_mention” only, the mentioned user.

class pyrogram.Photo

A Photo.

Parameters
  • file_id (str) – Unique identifier for this photo.

  • width (int) – Photo width.

  • height (int) – Photo height.

  • file_size (int) – File size.

  • date (int) – Date the photo was sent in Unix time.

  • thumbs (List of Thumbnail, optional) – Available thumbnails of this photo.

class pyrogram.ProfilePhotos

Contains a user’s profile pictures.

Parameters
  • total_count (int) – Total number of profile pictures the target user has.

  • profile_photos (List of Photo) – Requested profile pictures.

class pyrogram.Thumbnail

One size of a photo or a file/sticker thumbnail.

Parameters
  • file_id (str) – Unique identifier for this file.

  • width (int) – Photo width.

  • height (int) – Photo height.

  • file_size (int) – File size.

class pyrogram.Audio

An audio file to be treated as music by the Telegram clients.

Parameters
  • file_id (str) – Unique identifier for this file.

  • duration (int) – Duration of the audio in seconds as defined by sender.

  • file_name (str, optional) – Audio file name.

  • mime_type (str, optional) – MIME type of the file as defined by sender.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the audio was sent in Unix time.

  • performer (str, optional) – Performer of the audio as defined by sender or by audio tags.

  • title (str, optional) – Title of the audio as defined by sender or by audio tags.

  • thumbs (List of Thumbnail, optional) – Thumbnails of the music file album cover.

class pyrogram.Document

A generic file (as opposed to photos, voice messages, audio files, …).

Parameters
  • file_id (str) – Unique file identifier.

  • file_name (str, optional) – Original filename as defined by sender.

  • mime_type (str, optional) – MIME type of the file as defined by sender.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the document was sent in Unix time.

  • thumbs (List of Thumbnail, optional) – Document thumbnails as defined by sender.

class pyrogram.Animation

An animation file (GIF or H.264/MPEG-4 AVC video without sound).

Parameters
  • file_id (str) – Unique identifier for this file.

  • width (int) – Animation width as defined by sender.

  • height (int) – Animation height as defined by sender.

  • duration (int) – Duration of the animation in seconds as defined by sender.

  • file_name (str, optional) – Animation file name.

  • mime_type (str, optional) – Mime type of a file as defined by sender.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the animation was sent in Unix time.

  • thumbs (List of Thumbnail, optional) – Animation thumbnails.

class pyrogram.Video

A video file.

Parameters
  • file_id (str) – Unique identifier for this file.

  • width (int) – Video width as defined by sender.

  • height (int) – Video height as defined by sender.

  • duration (int) – Duration of the video in seconds as defined by sender.

  • file_name (str, optional) – Video file name.

  • mime_type (str, optional) – Mime type of a file as defined by sender.

  • supports_streaming (bool, optional) – True, if the video was uploaded with streaming support.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the video was sent in Unix time.

  • thumbs (List of Thumbnail, optional) – Video thumbnails.

class pyrogram.Voice

A voice note.

Parameters
  • file_id (str) – Unique identifier for this file.

  • duration (int) – Duration of the audio in seconds as defined by sender.

  • waveform (bytes, optional) – Voice waveform.

  • mime_type (str, optional) – MIME type of the file as defined by sender.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the voice was sent in Unix time.

class pyrogram.VideoNote

A video note.

Parameters
  • file_id (str) – Unique identifier for this file.

  • length (int) – Video width and height as defined by sender.

  • duration (int) – Duration of the video in seconds as defined by sender.

  • mime_type (str, optional) – MIME type of the file as defined by sender.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the video note was sent in Unix time.

  • thumbs (List of Thumbnail, optional) – Video thumbnails.

class pyrogram.Contact

A phone contact.

Parameters
  • phone_number (str) – Contact’s phone number.

  • first_name (str) – Contact’s first name.

  • last_name (str, optional) – Contact’s last name.

  • user_id (int, optional) – Contact’s user identifier in Telegram.

  • vcard (str, optional) – Additional data about the contact in the form of a vCard.

class pyrogram.Location

A point on the map.

Parameters
  • longitude (float) – Longitude as defined by sender.

  • latitude (float) – Latitude as defined by sender.

class pyrogram.Venue

A venue.

Parameters
  • location (Location) – Venue location.

  • title (str) – Name of the venue.

  • address (str) – Address of the venue.

  • foursquare_id (str, optional) – Foursquare identifier of the venue.

  • foursquare_type (str, optional) – Foursquare type of the venue. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)

class pyrogram.Sticker

A sticker.

Parameters
  • file_id (str) – Unique identifier for this file.

  • width (int) – Sticker width.

  • height (int) – Sticker height.

  • file_name (str, optional) – Sticker file name.

  • mime_type (str, optional) – MIME type of the file as defined by sender.

  • file_size (int, optional) – File size.

  • date (int, optional) – Date the sticker was sent in Unix time.

  • emoji (str, optional) – Emoji associated with the sticker.

  • set_name (str, optional) – Name of the sticker set to which the sticker belongs.

  • thumbs (List of Thumbnail, optional) – Sticker thumbnails in the .webp or .jpg format.

class pyrogram.Game

A game. Use BotFather to create and edit games, their short names will act as unique identifiers.

Parameters
  • id (int) – Unique identifier of the game.

  • title (str) – Title of the game.

  • short_name (str) – Unique short name of the game.

  • description (str) – Description of the game.

  • photo (Photo) – Photo that will be displayed in the game message in chats.

  • animation (Animation, optional) – Animation that will be displayed in the game message in chats. Upload via BotFather.

class pyrogram.Poll

A Poll.

Parameters
  • id (str) – Unique poll identifier.

  • question (str) – Poll question, 1-255 characters.

  • options (List of PollOption) – List of poll options.

  • is_closed (bool) – True, if the poll is closed.

  • total_voters (int) – Total count of voters for this poll.

  • chosen_option (int, optional) – Index of your chosen option (0-9), None in case you haven’t voted yet.

class pyrogram.PollOption

Contains information about one answer option in a poll.

Parameters
  • text (str) – Option text, 1-100 characters.

  • voter_count (int) – Number of users that voted for this option. Equals to 0 until you vote.

  • data (bytes) – The data this poll option is holding.

class pyrogram.ReplyKeyboardMarkup

A custom keyboard with reply options.

Parameters
  • keyboard (List of List of KeyboardButton) – List of button rows, each represented by a List of KeyboardButton objects.

  • resize_keyboard (bool, optional) – Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to false, in which case the custom keyboard is always of the same height as the app’s standard keyboard.

  • one_time_keyboard (bool, optional) – Requests clients to hide the keyboard as soon as it’s been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat – the user can press a special button in the input field to see the custom keyboard again. Defaults to false.

  • selective (bool, optional) – Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply (has reply_to_message_id), sender of the original message. Example: A user requests to change the bot’s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.

class pyrogram.KeyboardButton

One button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields are mutually exclusive.

Parameters
  • text (str) – Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.

  • request_contact (bool, optional) – If True, the user’s phone number will be sent as a contact when the button is pressed. Available in private chats only.

  • request_location (bool, optional) – If True, the user’s current location will be sent when the button is pressed. Available in private chats only.

class pyrogram.ReplyKeyboardRemove

Object used to tell clients to remove a bot keyboard.

Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup).

Parameters

selective (bool, optional) – Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply (has reply_to_message_id), sender of the original message. Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven’t voted yet.

class pyrogram.InlineKeyboardMarkup

An inline keyboard that appears right next to the message it belongs to.

Parameters

inline_keyboard (List of List of InlineKeyboardButton) – List of button rows, each represented by a List of InlineKeyboardButton objects.

class pyrogram.InlineKeyboardButton

One button of an inline keyboard.

You must use exactly one of the optional fields.

Parameters
  • text (str) – Label text on the button.

  • callback_data (str | bytes, optional) – Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.

  • url (str, optional) – HTTP url to be opened when button is pressed.

  • switch_inline_query (str, optional) – If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.Note: This offers an easy way for users to start using your bot in inline mode when they are currently in a private chat with it. Especially useful when combined with switch_pm… actions – in this case the user will be automatically returned to the chat they switched from, skipping the chat selection screen.

  • switch_inline_query_current_chat (str, optional) – If set, pressing the button will insert the bot’s username and the specified inline query in the current chat’s input field. Can be empty, in which case only the bot’s username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options.

class pyrogram.ForceReply

Object used to force clients to show a reply interface.

Upon receiving a message with this object, Telegram clients will display a reply interface to the user.

This acts as if the user has selected the bot’s message and tapped “Reply”. This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.

Parameters

selective (bool, optional) – Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply (has reply_to_message_id), sender of the original message.

class pyrogram.CallbackQuery

An incoming callback query from a callback button in an inline keyboard.

If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.

Parameters
  • id (str) – Unique identifier for this query.

  • from_user (User) – Sender.

  • chat_instance (str, optional) – Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.

  • message (Message, optional) – Message with the callback button that originated the query. Note that message content and message date will not be available if the message is too old.

  • inline_message_id (str) – Identifier of the message sent via the bot in inline mode, that originated the query.

  • data (str | bytes, optional) – Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field.

  • game_short_name (str, optional) – Short name of a Game to be returned, serves as the unique identifier for the game.

class pyrogram.GameHighScore

One row of the high scores table for a game.

Parameters
  • user (User) – User.

  • score (int) – Score.

  • position (position, optional) – Position in high score table for the game.

class pyrogram.GameHighScores

The high scores table for a game.

Parameters
  • total_count (int) – Total number of scores the target game has.

  • game_high_scores (List of GameHighScore) – Game scores.

class pyrogram.CallbackGame

Placeholder, currently holds no information.

Use BotFather to set up your game.

class pyrogram.InputMedia

Content of a media message to be sent.

It should be one of:

class pyrogram.InputMediaPhoto

A photo to be sent inside an album. It is intended to be used with send_media_group().

Parameters
  • media (str) – Photo to send. Pass a file_id as string to send a photo that exists on the Telegram servers or pass a file path as string to upload a new photo that exists on your local machine. Sending photo by a URL is currently unsupported.

  • caption (str, optional) – Caption of the photo to be sent, 0-1024 characters

  • parse_mode (str, optional) – Pass “markdown” or “html” if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption. Defaults to “markdown”.

class pyrogram.InputMediaVideo

A video to be sent inside an album. It is intended to be used with send_media_group().

Parameters
  • media (str) – Video to send. Pass a file_id as string to send a video that exists on the Telegram servers or pass a file path as string to upload a new video that exists on your local machine. Sending video by a URL is currently unsupported.

  • thumb (str) – Thumbnail of the video sent. The thumbnail should be in JPEG format and less than 200 KB in size. A thumbnail’s width and height should not exceed 320 pixels. Thumbnails can’t be reused and can be only uploaded as a new file.

  • caption (str, optional) – Caption of the video to be sent, 0-1024 characters

  • parse_mode (str, optional) – Pass “markdown” or “html” if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption. Defaults to “markdown”.

  • width (int, optional) – Video width.

  • height (int, optional) – Video height.

  • duration (int, optional) – Video duration.

  • supports_streaming (bool, optional) – Pass True, if the uploaded video is suitable for streaming.

class pyrogram.InputMediaAudio

An audio to be sent inside an album.

It is intended to be used with send_media_group().

Parameters
  • media (str) – Audio to send. Pass a file_id as string to send an audio that exists on the Telegram servers or pass a file path as string to upload a new audio that exists on your local machine.

  • thumb (str, optional) – Thumbnail of the music file album cover. The thumbnail should be in JPEG format and less than 200 KB in size. A thumbnail’s width and height should not exceed 320 pixels. Thumbnails can’t be reused and can be only uploaded as a new file.

  • caption (str, optional) – Caption of the audio to be sent, 0-1024 characters

  • parse_mode (str, optional) – Pass “markdown” or “html” if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption. Defaults to “markdown”.

  • duration (int, optional) – Duration of the audio in seconds

  • performer (int, optional) – Performer of the audio

  • title (int, optional) – Title of the audio

class pyrogram.InputMediaAnimation

An animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent inside an album.

Parameters
  • media (str) – Animation to send. Pass a file_id as string to send a file that exists on the Telegram servers or pass a file path as string to upload a new file that exists on your local machine.

  • thumb (str, optional) – Thumbnail of the animation file sent. The thumbnail should be in JPEG format and less than 200 KB in size. A thumbnail’s width and height should not exceed 320 pixels. Thumbnails can’t be reused and can be only uploaded as a new file.

  • caption (str, optional) – Caption of the animation to be sent, 0-1024 characters

  • parse_mode (str, optional) – Pass “markdown” or “html” if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption. Defaults to “markdown”.

  • width (int, optional) – Animation width.

  • height (int, optional) – Animation height.

  • duration (int, optional) – Animation duration.

class pyrogram.InputMediaDocument

A generic file to be sent inside an album.

Parameters
  • media (str) – File to send. Pass a file_id as string to send a file that exists on the Telegram servers or pass a file path as string to upload a new file that exists on your local machine.

  • thumb (str) – Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 KB in size. A thumbnail’s width and height should not exceed 320 pixels. Thumbnails can’t be reused and can be only uploaded as a new file.

  • caption (str, optional) – Caption of the document to be sent, 0-1024 characters

  • parse_mode (str, optional) – Pass “markdown” or “html” if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your caption. Defaults to “markdown”.

class pyrogram.InputPhoneContact

A Phone Contact to be added in your Telegram address book. It is intended to be used with ~Client.add_contacts()

Parameters
  • phone (str) – Contact’s phone number

  • first_name (str) – Contact’s first name

  • last_name (str, optional) – Contact’s last name

class pyrogram.InlineQuery

An incoming inline query.

When the user sends an empty query, your bot could return some default or trending results.

Parameters
  • id (str) – Unique identifier for this query.

  • from_user (User) – Sender.

  • query (str) – Text of the query (up to 512 characters).

  • offset (str) – Offset of the results to be returned, can be controlled by the bot.

  • location (Location. optional) – Sender location, only for bots that request user location.

class pyrogram.InlineQueryResult

One result of an inline query.

Pyrogram currently supports results of the following types:

class pyrogram.InlineQueryResultArticle

Link to an article or web page.

TODO: Hide url?

Parameters
  • id (str) – Unique identifier for this result, 1-64 bytes.

  • title (str) – Title for the result.

  • input_message_content (InputMessageContent) – Content of the message to be sent.

  • reply_markup (InlineKeyboardMarkup, optional) – Inline keyboard attached to the message.

  • url (str, optional) – URL of the result.

  • description (str, optional) – Short description of the result.

  • thumb_url (str, optional) – Url of the thumbnail for the result.

  • thumb_width (int, optional) – Thumbnail width.

  • thumb_height (int, optional) – Thumbnail height.

class pyrogram.InputMessageContent

Content of a message to be sent as a result of an inline query.

Pyrogram currently supports the following types:

class pyrogram.InputTextMessageContent

Content of a text message to be sent as the result of an inline query.

Parameters
  • message_text (str) – Text of the message to be sent, 1-4096 characters.

  • parse_mode (str, optional) – Pass “markdown” or “html” if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your message. Defaults to “markdown”.

  • disable_web_page_preview (bool, optional) – Disables link previews for links in this message.