tgram.bound package

Submodules

tgram.bound.callback_query module

class tgram.bound.callback_query.CallbackB[source]

Bases: object

answer(text: str = None, show_alert: bool = None, url: str = None, cache_time: int = None) bool[source]

Answer the callback query.

Parameters:
  • text (str, optional) – Notification text.

  • show_alert (bool, optional) – If True, an alert will be shown.

  • url (str, optional) – URL to be opened.

  • cache_time (int, optional) – The maximum amount of time in seconds that the result of the callback query may be cached client-side.

Returns:

True on success.

Return type:

bool

edit_message_caption(caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the caption of the message.

Parameters:
  • caption (str, optional) – New caption of the message.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in message caption.

  • show_caption_above_media (bool, optional) – If True, the caption will be shown above the media.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – New inline keyboard.

Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_live_location(latitude: float, longitude: float, live_period: int, horizontal_accuracy: float = None, heading: int = None, proximity_alert_radius: int = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the live location of the message.

Parameters:
  • latitude (float) – Latitude of the new location.

  • longitude (float) – Longitude of the new location.

  • live_period (int) – Period in seconds for which the location will be updated.

Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_media(media: tgram.types.InputMedia, reply_markup: tgram.types.InlineKeyboardMarkup = None) tgram.types.Message | bool[source]

Edit the media of the message.

Parameters:
Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_reply_markup(reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the reply markup of the message.

Parameters:

reply_markup (tgram.types.InlineKeyboardMarkup, optional) – New inline keyboard.

Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_text(text: str, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the text of the message.

Parameters:
Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

property sender_user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

property user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

tgram.bound.message module

class tgram.bound.message.MessageB[source]

Bases: object

copy(chat_id: int | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, reply_parameters: ReplyParameters = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) MessageId[source]

Copies the current message to another chat.

Parameters:
  • chat_id (Union[int, str]) – Unique identifier for the target chat or username of the target channel (in the format @channelusername).

  • caption (str, optional) – New caption for the message, if any.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the copied message from forwarding and saving.

  • reply_parameters (tgram.types.ReplyParameters, optional) – Additional parameters for the reply.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The ID of the copied message.

Return type:

tgram.types.MessageId

Example

```python await message.copy(

chat_id=”@target_channel”, caption=”Check out this copied message!”, disable_notification=True

)

delete() bool[source]

Deletes the current message.

Parameters:

self (tgram.types.Message) – The message object itself.

Returns:

True on success.

Return type:

bool

Example

```python # Assuming ‘message’ is an instance of tgram.types.Message success = await message.delete() if success:

print(“Message deleted successfully.”)

else:

print(“Failed to delete the message.”)

```

download(file_path: str = None, in_memory: bool = None) Path | BytesIO[source]

Downloads the media content of the message.

Parameters:
  • file_path (str, optional) – The path where the file should be saved. If not provided, the file will be saved in the current directory with its original name.

  • in_memory (bool, optional) – If True, the file will be downloaded into memory and returned as a BytesIO object. If False or not provided, the file will be saved to disk.

Returns:

The path to the saved file or a BytesIO object containing the file data.

Return type:

Union[Path, BytesIO]

Raises:

ValueError – If the message does not contain any media.

Example

```python # Downloading a photo to a specific path await message.download(file_path=”downloads/photo.jpg”)

# Downloading a video into memory video_data = await message.download(in_memory=True) with open(“downloads/video.mp4”, “wb”) as f:

f.write(video_data.getbuffer())

```

edit(text: str, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, reply_markup: InlineKeyboardMarkup = None) Message | bool

Edit the text of a message.

Parameters: self (tgram.types.Message): The message object itself. text (str): New text of the message. parse_mode (tgram.types.ParseMode, optional): Mode for parsing entities in the message text. Defaults to None. entities (List[tgram.types.MessageEntity], optional): List of special entities that appear in message text. Defaults to None. link_preview_options (tgram.types.LinkPreviewOptions, optional): Options for link previews in the message. Defaults to None. reply_markup (tgram.types.InlineKeyboardMarkup, optional): Inline keyboard attached to the message. Defaults to None.

Returns: Union[tgram.types.Message, bool]: On success, the edited message is returned, otherwise True is returned.

Example: ```python message = await bot.send_message(chat_id, “Original text”) edited_message = await message.edit_text(

text=”Edited text”, parse_mode=tgram.types.ParseMode.MARKDOWN, entities=[tgram.types.MessageEntity(type=”bold”, offset=0, length=5)], link_preview_options=tgram.types.LinkPreviewOptions(disable_web_page_preview=True), reply_markup=tgram.types.InlineKeyboardMarkup(inline_keyboard=[[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]])

```

edit_caption(caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the caption of a message.

Parameters:
  • caption (str, optional) – New caption of the message. Defaults to None.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message caption. Defaults to None.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode. Defaults to None.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media. Defaults to None.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Inline keyboard attached to the message. Defaults to None.

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python message = await bot.send_photo(chat_id, photo=”path/to/photo.jpg”, caption=”Original caption”) edited_message = await message.edit_caption(

caption=”Edited caption”, parse_mode=tgram.types.ParseMode.MARKDOWN, caption_entities=[tgram.types.MessageEntity(type=”bold”, offset=0, length=6)], show_caption_above_media=True, reply_markup=tgram.types.InlineKeyboardMarkup(inline_keyboard=[[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]])

)

edit_live_location(latitude: float, longitude: float, live_period: int = None, horizontal_accuracy: float = None, heading: int = None, proximity_alert_radius: int = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edits the live location of a message.

Parameters:
  • latitude (float) – Latitude of the new location.

  • longitude (float) – Longitude of the new location.

  • live_period (int, optional) – Period in seconds for which the location will be updated (should be between 60 and 86400).

  • horizontal_accuracy (float, optional) – The radius of uncertainty for the location, measured in meters; 0-1500.

  • heading (int, optional) – For live locations, a direction in which the user is moving, in degrees; 1-360.

  • proximity_alert_radius (int, optional) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters; 1-100000.

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

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python await message.edit_live_location(

latitude=37.7749, longitude=-122.4194, live_period=3600, horizontal_accuracy=50, heading=90, proximity_alert_radius=100, reply_markup=tgram.types.InlineKeyboardMarkup(

inline_keyboard=[

[tgram.types.InlineKeyboardButton(text=”Stop”, callback_data=”stop”)]

]

)

)

edit_media(media: tgram.types.InputMedia, reply_markup: tgram.types.InlineKeyboardMarkup = None) tgram.types.Message | bool[source]

Edit the media content of a message.

Parameters:
  • media (tgram.types.InputMedia) – The new media content to replace the current media.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Inline keyboard attached to the message. Defaults to None.

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python new_media = tgram.types.InputMediaPhoto(media=”path/to/new_photo.jpg”) edited_message = await message.edit_media(

media=new_media, reply_markup=tgram.types.InlineKeyboardMarkup(

inline_keyboard=[

[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]

]

)

)

edit_reply_markup(reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the reply markup of a message.

Parameters:

reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Inline keyboard attached to the message. Defaults to None.

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python message = await bot.send_message(chat_id, “Original text”) edited_message = await message.edit_reply_markup(

reply_markup=tgram.types.InlineKeyboardMarkup(
inline_keyboard=[

[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]

]

)

)

edit_text(text: str, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the text of a message.

Parameters: self (tgram.types.Message): The message object itself. text (str): New text of the message. parse_mode (tgram.types.ParseMode, optional): Mode for parsing entities in the message text. Defaults to None. entities (List[tgram.types.MessageEntity], optional): List of special entities that appear in message text. Defaults to None. link_preview_options (tgram.types.LinkPreviewOptions, optional): Options for link previews in the message. Defaults to None. reply_markup (tgram.types.InlineKeyboardMarkup, optional): Inline keyboard attached to the message. Defaults to None.

Returns: Union[tgram.types.Message, bool]: On success, the edited message is returned, otherwise True is returned.

Example: ```python message = await bot.send_message(chat_id, “Original text”) edited_message = await message.edit_text(

text=”Edited text”, parse_mode=tgram.types.ParseMode.MARKDOWN, entities=[tgram.types.MessageEntity(type=”bold”, offset=0, length=5)], link_preview_options=tgram.types.LinkPreviewOptions(disable_web_page_preview=True), reply_markup=tgram.types.InlineKeyboardMarkup(inline_keyboard=[[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]])

```

property file_id: str

Returns the file_id of the media contained in the message.

This property checks the message for various types of media (e.g., audio, video, photo, etc.) and returns the file_id of the media if found.

Raises:

ValueError – If the message does not contain any media.

Returns:

The file_id of the media contained in the message.

Return type:

str

Example

`python file_id = message.file_id print(f"The file_id of the media is: {file_id}") `

forward(chat_id: int | str, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None) Message[source]

Forwards the current message to another chat.

Parameters:
  • chat_id (Union[int, str]) – Unique identifier for the target chat or username of the target channel (in the format @channelusername).

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the forwarded message from forwarding and saving.

Returns:

The forwarded message.

Return type:

tgram.types.Message

Example

```python await message.forward(

chat_id=”@target_channel”, disable_notification=True

)

property id: int

Generates a link to the message.

This property generates a link to the message based on the chat type and chat username or ID.

Returns:

The link to the message, or None if the chat type is private.

Return type:

Optional[str]

Example

```python message_link = message.link if message_link:

print(f”Message link: {message_link}”)

else:

print(“This message is in a private chat and does not have a link.”)

```

property media: Literal['audio', 'video', 'photo', 'animation', 'voice', 'video_note', 'sticker', 'document'] | None

Returns the type of media contained in the message, if any.

This property checks the message for various types of media (e.g., audio, video, photo, etc.) and returns the type of media if found.

Returns:

The type of media contained in the message, or None if no media is found.

Return type:

Optional[Literal[“audio”, “video”, “photo”, “animation”, “voice”, “video_note”, “sticker”, “document”]]

Example

```python media_type = message.media if media_type:

print(f”The message contains {media_type}.”)

else:

print(“The message does not contain any media.”)

```

react(reaction: List[tgram.types.ReactionType] | tgram.types.ReactionType | List[str] | str) bool[source]

Adds a reaction to the current message.

Parameters:

reaction (Union[List[tgram.types.ReactionType], tgram.types.ReactionType, List[str], str]) – The reaction(s) to be added. Can be a list of ReactionType objects, a single ReactionType object, a list of emoji strings, or a single emoji string.

Returns:

True on success.

Return type:

bool

Example

```python # Adding a single reaction using an emoji string await message.react(reaction=”👍”)

# Adding multiple reactions using emoji strings await message.react(reaction=[”👍”, “❤️”])

# Adding a single reaction using a ReactionType object reaction_type = tgram.types.ReactionTypeEmoji(”👍”) await message.react(reaction=reaction_type)

# Adding multiple reactions using ReactionType objects reaction_types = [tgram.types.ReactionTypeEmoji(”👍”), tgram.types.ReactionTypeEmoji(”❤️”)] await message.react(reaction=reaction_types) ```

reply(text: str, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message

Sends a text message in reply to the current message.

Parameters:
  • text (str) – The text of the message to be sent.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message text.

  • entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in message text, which can be specified instead of parse_mode.

  • link_preview_options (tgram.types.LinkPreviewOptions, optional) – Options for link previews.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_text(

text=”<code>Hello, world!</code>”, parse_mode=”HTML”, disable_notification=True

)

reply_animation(animation: Path | bytes | str, message_thread_id: int = None, duration: int = None, width: int = None, height: int = None, thumbnail: Path | bytes | str = None, caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, has_spoiler: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends an animation (GIF) in reply to the current message.

Parameters:
  • animation (Union[Path, bytes, str]) – The animation to be sent. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

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

  • width (int, optional) – Width of the animation.

  • height (int, optional) – Height of the animation.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the animation.

  • caption (str, optional) – Caption for the animation.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the animation caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • has_spoiler (bool, optional) – Whether the animation contains a spoiler.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_animation(

animation=”path/to/animation.gif”, caption=”Check out this cool animation!”, parse_mode=”Markdown”, disable_notification=True

)

reply_audio(audio: Path | bytes | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, duration: int = None, performer: str = None, title: str = None, thumbnail: Path | bytes | str = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends an audio file in reply to the current message.

Parameters:
  • audio (Union[Path, bytes, str]) – The audio file to be sent. Can be a file path, bytes, or a URL.

  • caption (str, optional) – Caption for the audio file.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the audio caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

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

  • performer (str, optional) – Performer of the audio.

  • title (str, optional) – Title of the audio.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the audio file.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_audio(

audio=”path/to/audio.mp3”, caption=”Here is the audio file.”, parse_mode=”Markdown”, duration=120, performer=”Artist Name”, title=”Audio Title”, disable_notification=True

)

reply_chat_action(action: str, message_thread_id: int = None) bool[source]

Sends a chat action in reply to the current message.

Parameters:
  • action (str) – Type of action to broadcast. Choose one, depending on what the user is about to receive: ‘typing’ for text messages, ‘upload_photo’ for photos, ‘record_video’ or ‘upload_video’ for videos, ‘record_voice’ or ‘upload_voice’ for voice notes, ‘upload_document’ for general files, ‘find_location’ for location data, ‘record_video_note’ or ‘upload_video_note’ for video notes.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

Returns:

True on success.

Return type:

bool

Example

```python await message.reply_chat_action(

action=”typing”

)

reply_contact(phone_number: str, first_name: str, last_name: str = None, vcard: str = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a contact in reply to the current message.

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

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

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

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

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_contact(

phone_number=”+123456789”, first_name=”John”, last_name=”Doe”, disable_notification=True

)

reply_dice(emoji: str = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a dice message in reply to the current message.

Parameters:
  • emoji (str, optional) – Emoji on which the dice throw animation is based. Currently, must be one of ‘🎲’, ‘🎯’, ‘🏀’, ‘⚽’, ‘🎳’, or ‘🎰’.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_dice(

emoji=”🎲”, disable_notification=True

)

reply_document(document: Path | bytes | str, message_thread_id: int = None, thumbnail: Path | bytes | str = None, caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, disable_content_type_detection: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a document in reply to the current message.

Parameters:
  • document (Union[Path, bytes, str]) – The document to send. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the file sent; can be ignored if server-side thumbnail generation is supported.

  • caption (str, optional) – Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the document caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • disable_content_type_detection (bool, optional) – Disables automatic server-side content type detection for files uploaded using multipart/form-data.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Unique identifier for the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_document(

document=”path/to/document.pdf”, caption=”Here is the document you requested.”, parse_mode=”Markdown”, disable_notification=True

)

reply_game(game_short_name: str, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup = None) Message[source]

Sends a game in reply to the current message.

Parameters:
  • game_short_name (str) – Short name of the game.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Additional interface options. A JSON-serialized object for an inline keyboard.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_game(

game_short_name=”game_name”, disable_notification=True

)

reply_invoice(title: str, description: str, payload: str, currency: str, prices: List[LabeledPrice], provider_token: str = None, max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, start_parameter: str = None, provider_data: str = None, photo_url: str = None, photo_size: int = None, photo_width: int = None, photo_height: int = None, need_name: bool = None, need_phone_number: bool = None, need_email: bool = None, need_shipping_address: bool = None, send_phone_number_to_provider: bool = None, send_email_to_provider: bool = None, is_flexible: bool = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup = None) Message[source]

Sends an invoice in reply to the current message.

Parameters:
  • title (str) – Product name, 1-32 characters.

  • description (str) – Product description, 1-255 characters.

  • payload (str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.

  • currency (str) – Three-letter ISO 4217 currency code.

  • prices (List[tgram.types.LabeledPrice]) – Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.).

  • provider_token (str, optional) – Payment provider token, obtained via BotFather.

  • max_tip_amount (int, optional) – The maximum accepted amount for tips in the smallest units of the currency.

  • suggested_tip_amounts (List[int], optional) – A list of suggested amounts of tips in the smallest units of the currency.

  • start_parameter (str, optional) – Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.

  • provider_data (str, optional) – JSON-encoded data about the invoice, which will be shared with the payment provider.

  • photo_url (str, optional) – URL of the product photo for the invoice.

  • photo_size (int, optional) – Photo size.

  • photo_width (int, optional) – Photo width.

  • photo_height (int, optional) – Photo height.

  • need_name (bool, optional) – Pass True if you require the user’s full name to complete the order.

  • need_phone_number (bool, optional) – Pass True if you require the user’s phone number to complete the order.

  • need_email (bool, optional) – Pass True if you require the user’s email address to complete the order.

  • need_shipping_address (bool, optional) – Pass True if you require the user’s shipping address to complete the order.

  • send_phone_number_to_provider (bool, optional) – Pass True if the user’s phone number should be sent to the provider.

  • send_email_to_provider (bool, optional) – Pass True if the user’s email address should be sent to the provider.

  • is_flexible (bool, optional) – Pass True if the final price depends on the shipping method.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Additional interface options. A JSON-serialized object for an inline keyboard.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python prices = [tgram.types.LabeledPrice(label=”Product”, amount=1000)] await message.reply_invoice(

title=”Product Title”, description=”Product Description”, payload=”payload”, currency=”USD”, prices=prices, provider_token=”provider_token”, disable_notification=True

)

reply_location(latitude: float, longitude: float, message_thread_id: int = None, horizontal_accuracy: float = None, live_period: int = None, heading: int = None, proximity_alert_radius: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a location in reply to the current message.

Parameters:
  • latitude (float) – Latitude of the location.

  • longitude (float) – Longitude of the location.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • horizontal_accuracy (float, optional) – The radius of uncertainty for the location, measured in meters; 0-1500.

  • live_period (int, optional) – Period in seconds for which the location will be updated (should be between 60 and 86400).

  • heading (int, optional) – For live locations, a direction in which the user is moving, in degrees; 1-360.

  • proximity_alert_radius (int, optional) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters; 1-100000.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_location(

latitude=37.7749, longitude=-122.4194, live_period=3600, disable_notification=True

)

reply_media_from_file_id(file_id: str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a media message using a file_id in reply to the current message.

Parameters:
  • file_id (str) – The file_id of the media to be sent.

  • caption (str, optional) – Caption for the media.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the media caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_media_from_file_id(

file_id=”ABC123”, caption=”Check out this media!”, parse_mode=”Markdown”, disable_notification=True

)

reply_media_group(media: List[tgram.types.InputMedia], message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None) List[tgram.types.Message][source]

Sends a group of photos or videos as an album in reply to the current message.

Parameters:
  • media (List[tgram.types.InputMedia]) – A list of media to be sent. Each media item can be a photo or video.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

Returns:

The sent messages.

Return type:

List[tgram.types.Message]

Example

```python media = [

tgram.types.InputMediaPhoto(media=”path/to/photo1.jpg”), tgram.types.InputMediaPhoto(media=”path/to/photo2.jpg”), tgram.types.InputMediaVideo(media=”path/to/video.mp4”)

] await message.reply_media_group(

media=media, disable_notification=True

)

reply_paid_media(star_count: int, media: List[tgram.types.InputPaidMedia], caption: str = None, parse_mode: tgram.types.ParseMode = None, caption_entities: List[tgram.types.MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, reply_markup: tgram.types.InlineKeyboardMarkup | tgram.types.ReplyKeyboardMarkup | tgram.types.ReplyKeyboardRemove | tgram.types.ForceReply = None) tgram.types.Message[source]

Sends a paid media message in reply to the current message.

Parameters:
  • star_count (int) – Number of stars required to view the media.

  • media (List[tgram.types.InputPaidMedia]) – A list of paid media to be sent.

  • caption (str, optional) – Caption for the media.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the media caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python media = [

tgram.types.InputPaidMedia(media=”path/to/photo1.jpg”), tgram.types.InputPaidMedia(media=”path/to/photo2.jpg”)

] await message.reply_paid_media(

star_count=5, media=media, caption=”Check out this paid media!”, parse_mode=”Markdown”, disable_notification=True

)

reply_photo(photo: Path | bytes | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, has_spoiler: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a photo in reply to the current message.

Parameters:
  • photo (Union[Path, bytes, str]) – The photo to be sent. Can be a file path, bytes, or a URL.

  • caption (str, optional) – Caption for the photo.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the photo caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • has_spoiler (bool, optional) – Whether the photo contains a spoiler.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_photo(

photo=”path/to/photo.jpg”, caption=”Check out this photo!”, parse_mode=”Markdown”, disable_notification=True

)

reply_sticker(sticker: Path | bytes | str, emoji: str = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a sticker in reply to the current message.

Parameters:
  • sticker (Union[Path, bytes, str]) – The sticker to be sent. Can be a file path, bytes, or a URL.

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

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_sticker(

sticker=”path/to/sticker.webp”, emoji=”😊”, disable_notification=True

)

reply_text(text: str, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a text message in reply to the current message.

Parameters:
  • text (str) – The text of the message to be sent.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message text.

  • entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in message text, which can be specified instead of parse_mode.

  • link_preview_options (tgram.types.LinkPreviewOptions, optional) – Options for link previews.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_text(

text=”<code>Hello, world!</code>”, parse_mode=”HTML”, disable_notification=True

)

reply_video(video: Path | bytes | str, message_thread_id: int = None, duration: int = None, width: int = None, height: int = None, thumbnail: Path | bytes | str = None, caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, has_spoiler: bool = None, supports_streaming: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a video in reply to the current message.

Parameters:
  • video (Union[Path, bytes, str]) – The video to be sent. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

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

  • width (int, optional) – Video width.

  • height (int, optional) – Video height.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the video.

  • caption (str, optional) – Caption for the video.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the video caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • has_spoiler (bool, optional) – Whether the video contains a spoiler.

  • supports_streaming (bool, optional) – Whether the video supports streaming.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_video(

video=”path/to/video.mp4”, caption=”Check out this video!”, parse_mode=”Markdown”, disable_notification=True

)

reply_video_note(video_note: Path | bytes | str, message_thread_id: int = None, duration: int = None, length: int = None, thumbnail: Path | bytes | str = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a video note in reply to the current message.

Parameters:
  • video_note (Union[Path, bytes, str]) – The video note to be sent. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • duration (int, optional) – Duration of the video note in seconds.

  • length (int, optional) – Video width and height (diameter of the video message) in pixels.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the video note.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_video_note(

video_note=”path/to/video_note.mp4”, duration=60, length=240, disable_notification=True

)

reply_voice(voice: Path | bytes | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, duration: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a voice message in reply to the current message.

Parameters:
  • voice (Union[Path, bytes, str]) – The voice message to be sent. Can be a file path, bytes, or a URL.

  • caption (str, optional) – Caption for the voice message.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the voice message caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • duration (int, optional) – Duration of the voice message in seconds.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_voice(

voice=”path/to/voice.ogg”, caption=”Here is the voice message.”, parse_mode=”Markdown”, duration=60, disable_notification=True

)

property sender_user: User | None

Returns the user who sent the message.

This property retrieves the user who sent the message, if available.

Returns:

The user who sent the message, or None if the user is not available.

Return type:

Optional[tgram.types.User]

Example

```python user = message.user if user:

print(f”Message sent by: {user.first_name}”)

else:

print(“User information is not available.”)

```

property service: str | None

Returns the type of service message contained in the message, if any.

This property checks the message for various types of service messages (e.g., video chat started, pinned message, etc.) and returns the type of service message if found.

Returns:

The type of service message contained in the message, or None if no service message is found.

Return type:

Optional[str]

Example

```python service_type = message.service if service_type:

print(f”The message contains a service message of type {service_type}.”)

else:

print(“The message does not contain any service message.”)

```

property user: User | None

Returns the user who sent the message.

This property retrieves the user who sent the message, if available.

Returns:

The user who sent the message, or None if the user is not available.

Return type:

Optional[tgram.types.User]

Example

```python user = message.user if user:

print(f”Message sent by: {user.first_name}”)

else:

print(“User information is not available.”)

```

tgram.bound.user module

class tgram.bound.user.UserB[source]

Bases: object

property full_name: str
property mention: Mention
property photo: PhotoSize | None

Module contents

class tgram.bound.CallbackB[source]

Bases: object

answer(text: str = None, show_alert: bool = None, url: str = None, cache_time: int = None) bool[source]

Answer the callback query.

Parameters:
  • text (str, optional) – Notification text.

  • show_alert (bool, optional) – If True, an alert will be shown.

  • url (str, optional) – URL to be opened.

  • cache_time (int, optional) – The maximum amount of time in seconds that the result of the callback query may be cached client-side.

Returns:

True on success.

Return type:

bool

edit_message_caption(caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the caption of the message.

Parameters:
  • caption (str, optional) – New caption of the message.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in message caption.

  • show_caption_above_media (bool, optional) – If True, the caption will be shown above the media.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – New inline keyboard.

Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_live_location(latitude: float, longitude: float, live_period: int, horizontal_accuracy: float = None, heading: int = None, proximity_alert_radius: int = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the live location of the message.

Parameters:
  • latitude (float) – Latitude of the new location.

  • longitude (float) – Longitude of the new location.

  • live_period (int) – Period in seconds for which the location will be updated.

Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_media(media: tgram.types.InputMedia, reply_markup: tgram.types.InlineKeyboardMarkup = None) tgram.types.Message | bool[source]

Edit the media of the message.

Parameters:
Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_reply_markup(reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the reply markup of the message.

Parameters:

reply_markup (tgram.types.InlineKeyboardMarkup, optional) – New inline keyboard.

Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

edit_message_text(text: str, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the text of the message.

Parameters:
Returns:

The edited message or True on success.

Return type:

Union[tgram.types.Message, bool]

property sender_user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

property user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

class tgram.bound.ChatB[source]

Bases: object

ban_member(user_id: int, until_date: int = None, revoke_messages: bool = None) bool[source]

Ban a member from the chat.

Parameters:
  • user_id (int) – The ID of the user to ban.

  • until_date (int, optional) – Date when the user will be unbanned, unix time.

  • revoke_messages (bool, optional) – Pass True to delete all messages from the chat for the user that is being removed.

Returns:

True if the user was successfully banned, False otherwise.

Return type:

bool

ban_sender_chat(sender_chat_id: int) bool[source]

Ban a channel chat in a supergroup or a channel.

Parameters:

sender_chat_id (int) – The ID of the sender chat to ban.

Returns:

True if the sender chat was successfully banned, False otherwise.

Return type:

bool

property full_name: str

Get the full name of the chat.

Returns:

The full name of the chat.

Return type:

str

get_muted_members() List[int][source]

Get a list of muted members in the chat.

Returns:

A list of user IDs who are muted in the chat.

Return type:

List[int]

leave() bool[source]

Leave the chat.

Returns:

True if the bot successfully left the chat, False otherwise.

Return type:

bool

property mention: Mention

Get a mention object for the chat.

Parameters:

name (str, optional) – The name to use for the mention. Defaults to the chat’s first name.

Returns:

A mention object for the chat.

Return type:

Mention

mute(user_id: int) bool[source]

Mute a member in the chat.

Parameters:

user_id (int) – The ID of the user to mute.

Returns:

True if the user was successfully muted, False otherwise.

Return type:

bool

restrict_member(user_id: int, permissions: ChatPermissions, use_independent_chat_permissions: bool = None, until_date: int = None) bool[source]

Restrict a member in the chat.

Parameters:
  • user_id (int) – The ID of the user to restrict.

  • permissions (tgram.types.ChatPermissions) – New user permissions.

  • use_independent_chat_permissions (bool, optional) – Pass True if chat permissions are set independently.

  • until_date (int, optional) – Date when restrictions will be lifted for the user, unix time.

Returns:

True if the user was successfully restricted, False otherwise.

Return type:

bool

unban_member(user_id: int, only_if_banned: bool = None) bool[source]

Unban a previously banned member from the chat.

Parameters:
  • user_id (int) – The ID of the user to unban.

  • only_if_banned (bool, optional) – Do nothing if the user is not banned.

Returns:

True if the user was successfully unbanned, False otherwise.

Return type:

bool

unban_sender_chat(sender_chat_id: int) bool[source]

Unban a previously banned channel chat in a supergroup or a channel.

Parameters:

sender_chat_id (int) – The ID of the sender chat to unban.

Returns:

True if the sender chat was successfully unbanned, False otherwise.

Return type:

bool

unmute(user_id: int) bool[source]

Unmute a previously muted member in the chat.

Parameters:

user_id (int) – The ID of the user to unmute.

Returns:

True if the user was successfully unmuted, False otherwise.

Return type:

bool

unrestrict_member(user_id: int, use_independent_chat_permissions: bool = None) bool[source]

Unrestrict a previously restricted member in the chat.

Parameters:
  • user_id (int) – The ID of the user to unrestrict.

  • use_independent_chat_permissions (bool, optional) – Pass True if chat permissions are set independently.

Returns:

True if the user was successfully unrestricted, False otherwise.

Return type:

bool

class tgram.bound.ChatJoinRequestB[source]

Bases: object

property sender_user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

property user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

class tgram.bound.ChatMemberUpdatedB[source]

Bases: object

property sender_user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

property user: User | None

Get the user who sent the callback query.

Returns:

The user who sent the callback query.

Return type:

Optional[tgram.types.User]

class tgram.bound.ChosenInlineResultB[source]

Bases: object

property sender_user: User | None
property user: User | None
class tgram.bound.InlineQueryB[source]

Bases: object

answer(results: List[tgram.types.InlineQueryResult], cache_time: int = None, is_personal: bool = None, next_offset: str = None, button: tgram.types.InlineQueryResultsButton = None) bool[source]

Sends answers to an inline query.

Parameters: - results (List[tgram.types.InlineQueryResult]): A list of results for the inline query. - cache_time (int, optional): The maximum amount of time in seconds that the result of the inline query may be cached on the server. - is_personal (bool, optional): Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query. - next_offset (str, optional): Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don’t support pagination. Offset length can’t exceed 64 bytes. - button (tgram.types.InlineQueryResultsButton, optional): A button to be shown above inline query results.

Returns: - bool: True on success.

property sender_user: User | None

Returns the user who sent the inline query.

Returns: - Optional[tgram.types.User]: The user who sent the inline query.

property user: User | None

Returns the user who sent the inline query.

Returns: - Optional[tgram.types.User]: The user who sent the inline query.

class tgram.bound.MessageB[source]

Bases: object

copy(chat_id: int | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, reply_parameters: ReplyParameters = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) MessageId[source]

Copies the current message to another chat.

Parameters:
  • chat_id (Union[int, str]) – Unique identifier for the target chat or username of the target channel (in the format @channelusername).

  • caption (str, optional) – New caption for the message, if any.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the copied message from forwarding and saving.

  • reply_parameters (tgram.types.ReplyParameters, optional) – Additional parameters for the reply.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The ID of the copied message.

Return type:

tgram.types.MessageId

Example

```python await message.copy(

chat_id=”@target_channel”, caption=”Check out this copied message!”, disable_notification=True

)

delete() bool[source]

Deletes the current message.

Parameters:

self (tgram.types.Message) – The message object itself.

Returns:

True on success.

Return type:

bool

Example

```python # Assuming ‘message’ is an instance of tgram.types.Message success = await message.delete() if success:

print(“Message deleted successfully.”)

else:

print(“Failed to delete the message.”)

```

download(file_path: str = None, in_memory: bool = None) Path | BytesIO[source]

Downloads the media content of the message.

Parameters:
  • file_path (str, optional) – The path where the file should be saved. If not provided, the file will be saved in the current directory with its original name.

  • in_memory (bool, optional) – If True, the file will be downloaded into memory and returned as a BytesIO object. If False or not provided, the file will be saved to disk.

Returns:

The path to the saved file or a BytesIO object containing the file data.

Return type:

Union[Path, BytesIO]

Raises:

ValueError – If the message does not contain any media.

Example

```python # Downloading a photo to a specific path await message.download(file_path=”downloads/photo.jpg”)

# Downloading a video into memory video_data = await message.download(in_memory=True) with open(“downloads/video.mp4”, “wb”) as f:

f.write(video_data.getbuffer())

```

edit(text: str, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, reply_markup: InlineKeyboardMarkup = None) Message | bool

Edit the text of a message.

Parameters: self (tgram.types.Message): The message object itself. text (str): New text of the message. parse_mode (tgram.types.ParseMode, optional): Mode for parsing entities in the message text. Defaults to None. entities (List[tgram.types.MessageEntity], optional): List of special entities that appear in message text. Defaults to None. link_preview_options (tgram.types.LinkPreviewOptions, optional): Options for link previews in the message. Defaults to None. reply_markup (tgram.types.InlineKeyboardMarkup, optional): Inline keyboard attached to the message. Defaults to None.

Returns: Union[tgram.types.Message, bool]: On success, the edited message is returned, otherwise True is returned.

Example: ```python message = await bot.send_message(chat_id, “Original text”) edited_message = await message.edit_text(

text=”Edited text”, parse_mode=tgram.types.ParseMode.MARKDOWN, entities=[tgram.types.MessageEntity(type=”bold”, offset=0, length=5)], link_preview_options=tgram.types.LinkPreviewOptions(disable_web_page_preview=True), reply_markup=tgram.types.InlineKeyboardMarkup(inline_keyboard=[[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]])

```

edit_caption(caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the caption of a message.

Parameters:
  • caption (str, optional) – New caption of the message. Defaults to None.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message caption. Defaults to None.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode. Defaults to None.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media. Defaults to None.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Inline keyboard attached to the message. Defaults to None.

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python message = await bot.send_photo(chat_id, photo=”path/to/photo.jpg”, caption=”Original caption”) edited_message = await message.edit_caption(

caption=”Edited caption”, parse_mode=tgram.types.ParseMode.MARKDOWN, caption_entities=[tgram.types.MessageEntity(type=”bold”, offset=0, length=6)], show_caption_above_media=True, reply_markup=tgram.types.InlineKeyboardMarkup(inline_keyboard=[[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]])

)

edit_live_location(latitude: float, longitude: float, live_period: int = None, horizontal_accuracy: float = None, heading: int = None, proximity_alert_radius: int = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edits the live location of a message.

Parameters:
  • latitude (float) – Latitude of the new location.

  • longitude (float) – Longitude of the new location.

  • live_period (int, optional) – Period in seconds for which the location will be updated (should be between 60 and 86400).

  • horizontal_accuracy (float, optional) – The radius of uncertainty for the location, measured in meters; 0-1500.

  • heading (int, optional) – For live locations, a direction in which the user is moving, in degrees; 1-360.

  • proximity_alert_radius (int, optional) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters; 1-100000.

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

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python await message.edit_live_location(

latitude=37.7749, longitude=-122.4194, live_period=3600, horizontal_accuracy=50, heading=90, proximity_alert_radius=100, reply_markup=tgram.types.InlineKeyboardMarkup(

inline_keyboard=[

[tgram.types.InlineKeyboardButton(text=”Stop”, callback_data=”stop”)]

]

)

)

edit_media(media: tgram.types.InputMedia, reply_markup: tgram.types.InlineKeyboardMarkup = None) tgram.types.Message | bool[source]

Edit the media content of a message.

Parameters:
  • media (tgram.types.InputMedia) – The new media content to replace the current media.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Inline keyboard attached to the message. Defaults to None.

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python new_media = tgram.types.InputMediaPhoto(media=”path/to/new_photo.jpg”) edited_message = await message.edit_media(

media=new_media, reply_markup=tgram.types.InlineKeyboardMarkup(

inline_keyboard=[

[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]

]

)

)

edit_reply_markup(reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the reply markup of a message.

Parameters:

reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Inline keyboard attached to the message. Defaults to None.

Returns:

On success, the edited message is returned, otherwise True is returned.

Return type:

Union[tgram.types.Message, bool]

Example

```python message = await bot.send_message(chat_id, “Original text”) edited_message = await message.edit_reply_markup(

reply_markup=tgram.types.InlineKeyboardMarkup(
inline_keyboard=[

[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]

]

)

)

edit_text(text: str, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, reply_markup: InlineKeyboardMarkup = None) Message | bool[source]

Edit the text of a message.

Parameters: self (tgram.types.Message): The message object itself. text (str): New text of the message. parse_mode (tgram.types.ParseMode, optional): Mode for parsing entities in the message text. Defaults to None. entities (List[tgram.types.MessageEntity], optional): List of special entities that appear in message text. Defaults to None. link_preview_options (tgram.types.LinkPreviewOptions, optional): Options for link previews in the message. Defaults to None. reply_markup (tgram.types.InlineKeyboardMarkup, optional): Inline keyboard attached to the message. Defaults to None.

Returns: Union[tgram.types.Message, bool]: On success, the edited message is returned, otherwise True is returned.

Example: ```python message = await bot.send_message(chat_id, “Original text”) edited_message = await message.edit_text(

text=”Edited text”, parse_mode=tgram.types.ParseMode.MARKDOWN, entities=[tgram.types.MessageEntity(type=”bold”, offset=0, length=5)], link_preview_options=tgram.types.LinkPreviewOptions(disable_web_page_preview=True), reply_markup=tgram.types.InlineKeyboardMarkup(inline_keyboard=[[tgram.types.InlineKeyboardButton(text=”Button”, callback_data=”data”)]])

```

property file_id: str

Returns the file_id of the media contained in the message.

This property checks the message for various types of media (e.g., audio, video, photo, etc.) and returns the file_id of the media if found.

Raises:

ValueError – If the message does not contain any media.

Returns:

The file_id of the media contained in the message.

Return type:

str

Example

`python file_id = message.file_id print(f"The file_id of the media is: {file_id}") `

forward(chat_id: int | str, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None) Message[source]

Forwards the current message to another chat.

Parameters:
  • chat_id (Union[int, str]) – Unique identifier for the target chat or username of the target channel (in the format @channelusername).

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the forwarded message from forwarding and saving.

Returns:

The forwarded message.

Return type:

tgram.types.Message

Example

```python await message.forward(

chat_id=”@target_channel”, disable_notification=True

)

property id: int

Generates a link to the message.

This property generates a link to the message based on the chat type and chat username or ID.

Returns:

The link to the message, or None if the chat type is private.

Return type:

Optional[str]

Example

```python message_link = message.link if message_link:

print(f”Message link: {message_link}”)

else:

print(“This message is in a private chat and does not have a link.”)

```

property media: Literal['audio', 'video', 'photo', 'animation', 'voice', 'video_note', 'sticker', 'document'] | None

Returns the type of media contained in the message, if any.

This property checks the message for various types of media (e.g., audio, video, photo, etc.) and returns the type of media if found.

Returns:

The type of media contained in the message, or None if no media is found.

Return type:

Optional[Literal[“audio”, “video”, “photo”, “animation”, “voice”, “video_note”, “sticker”, “document”]]

Example

```python media_type = message.media if media_type:

print(f”The message contains {media_type}.”)

else:

print(“The message does not contain any media.”)

```

react(reaction: List[tgram.types.ReactionType] | tgram.types.ReactionType | List[str] | str) bool[source]

Adds a reaction to the current message.

Parameters:

reaction (Union[List[tgram.types.ReactionType], tgram.types.ReactionType, List[str], str]) – The reaction(s) to be added. Can be a list of ReactionType objects, a single ReactionType object, a list of emoji strings, or a single emoji string.

Returns:

True on success.

Return type:

bool

Example

```python # Adding a single reaction using an emoji string await message.react(reaction=”👍”)

# Adding multiple reactions using emoji strings await message.react(reaction=[”👍”, “❤️”])

# Adding a single reaction using a ReactionType object reaction_type = tgram.types.ReactionTypeEmoji(”👍”) await message.react(reaction=reaction_type)

# Adding multiple reactions using ReactionType objects reaction_types = [tgram.types.ReactionTypeEmoji(”👍”), tgram.types.ReactionTypeEmoji(”❤️”)] await message.react(reaction=reaction_types) ```

reply(text: str, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message

Sends a text message in reply to the current message.

Parameters:
  • text (str) – The text of the message to be sent.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message text.

  • entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in message text, which can be specified instead of parse_mode.

  • link_preview_options (tgram.types.LinkPreviewOptions, optional) – Options for link previews.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_text(

text=”<code>Hello, world!</code>”, parse_mode=”HTML”, disable_notification=True

)

reply_animation(animation: Path | bytes | str, message_thread_id: int = None, duration: int = None, width: int = None, height: int = None, thumbnail: Path | bytes | str = None, caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, has_spoiler: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends an animation (GIF) in reply to the current message.

Parameters:
  • animation (Union[Path, bytes, str]) – The animation to be sent. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

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

  • width (int, optional) – Width of the animation.

  • height (int, optional) – Height of the animation.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the animation.

  • caption (str, optional) – Caption for the animation.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the animation caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • has_spoiler (bool, optional) – Whether the animation contains a spoiler.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_animation(

animation=”path/to/animation.gif”, caption=”Check out this cool animation!”, parse_mode=”Markdown”, disable_notification=True

)

reply_audio(audio: Path | bytes | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, duration: int = None, performer: str = None, title: str = None, thumbnail: Path | bytes | str = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends an audio file in reply to the current message.

Parameters:
  • audio (Union[Path, bytes, str]) – The audio file to be sent. Can be a file path, bytes, or a URL.

  • caption (str, optional) – Caption for the audio file.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the audio caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

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

  • performer (str, optional) – Performer of the audio.

  • title (str, optional) – Title of the audio.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the audio file.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_audio(

audio=”path/to/audio.mp3”, caption=”Here is the audio file.”, parse_mode=”Markdown”, duration=120, performer=”Artist Name”, title=”Audio Title”, disable_notification=True

)

reply_chat_action(action: str, message_thread_id: int = None) bool[source]

Sends a chat action in reply to the current message.

Parameters:
  • action (str) – Type of action to broadcast. Choose one, depending on what the user is about to receive: ‘typing’ for text messages, ‘upload_photo’ for photos, ‘record_video’ or ‘upload_video’ for videos, ‘record_voice’ or ‘upload_voice’ for voice notes, ‘upload_document’ for general files, ‘find_location’ for location data, ‘record_video_note’ or ‘upload_video_note’ for video notes.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

Returns:

True on success.

Return type:

bool

Example

```python await message.reply_chat_action(

action=”typing”

)

reply_contact(phone_number: str, first_name: str, last_name: str = None, vcard: str = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a contact in reply to the current message.

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

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

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

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

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_contact(

phone_number=”+123456789”, first_name=”John”, last_name=”Doe”, disable_notification=True

)

reply_dice(emoji: str = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a dice message in reply to the current message.

Parameters:
  • emoji (str, optional) – Emoji on which the dice throw animation is based. Currently, must be one of ‘🎲’, ‘🎯’, ‘🏀’, ‘⚽’, ‘🎳’, or ‘🎰’.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_dice(

emoji=”🎲”, disable_notification=True

)

reply_document(document: Path | bytes | str, message_thread_id: int = None, thumbnail: Path | bytes | str = None, caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, disable_content_type_detection: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a document in reply to the current message.

Parameters:
  • document (Union[Path, bytes, str]) – The document to send. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the file sent; can be ignored if server-side thumbnail generation is supported.

  • caption (str, optional) – Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the document caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • disable_content_type_detection (bool, optional) – Disables automatic server-side content type detection for files uploaded using multipart/form-data.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Unique identifier for the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_document(

document=”path/to/document.pdf”, caption=”Here is the document you requested.”, parse_mode=”Markdown”, disable_notification=True

)

reply_game(game_short_name: str, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup = None) Message[source]

Sends a game in reply to the current message.

Parameters:
  • game_short_name (str) – Short name of the game.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Additional interface options. A JSON-serialized object for an inline keyboard.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_game(

game_short_name=”game_name”, disable_notification=True

)

reply_invoice(title: str, description: str, payload: str, currency: str, prices: List[LabeledPrice], provider_token: str = None, max_tip_amount: int = None, suggested_tip_amounts: List[int] = None, start_parameter: str = None, provider_data: str = None, photo_url: str = None, photo_size: int = None, photo_width: int = None, photo_height: int = None, need_name: bool = None, need_phone_number: bool = None, need_email: bool = None, need_shipping_address: bool = None, send_phone_number_to_provider: bool = None, send_email_to_provider: bool = None, is_flexible: bool = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup = None) Message[source]

Sends an invoice in reply to the current message.

Parameters:
  • title (str) – Product name, 1-32 characters.

  • description (str) – Product description, 1-255 characters.

  • payload (str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.

  • currency (str) – Three-letter ISO 4217 currency code.

  • prices (List[tgram.types.LabeledPrice]) – Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.).

  • provider_token (str, optional) – Payment provider token, obtained via BotFather.

  • max_tip_amount (int, optional) – The maximum accepted amount for tips in the smallest units of the currency.

  • suggested_tip_amounts (List[int], optional) – A list of suggested amounts of tips in the smallest units of the currency.

  • start_parameter (str, optional) – Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter.

  • provider_data (str, optional) – JSON-encoded data about the invoice, which will be shared with the payment provider.

  • photo_url (str, optional) – URL of the product photo for the invoice.

  • photo_size (int, optional) – Photo size.

  • photo_width (int, optional) – Photo width.

  • photo_height (int, optional) – Photo height.

  • need_name (bool, optional) – Pass True if you require the user’s full name to complete the order.

  • need_phone_number (bool, optional) – Pass True if you require the user’s phone number to complete the order.

  • need_email (bool, optional) – Pass True if you require the user’s email address to complete the order.

  • need_shipping_address (bool, optional) – Pass True if you require the user’s shipping address to complete the order.

  • send_phone_number_to_provider (bool, optional) – Pass True if the user’s phone number should be sent to the provider.

  • send_email_to_provider (bool, optional) – Pass True if the user’s email address should be sent to the provider.

  • is_flexible (bool, optional) – Pass True if the final price depends on the shipping method.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (tgram.types.InlineKeyboardMarkup, optional) – Additional interface options. A JSON-serialized object for an inline keyboard.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python prices = [tgram.types.LabeledPrice(label=”Product”, amount=1000)] await message.reply_invoice(

title=”Product Title”, description=”Product Description”, payload=”payload”, currency=”USD”, prices=prices, provider_token=”provider_token”, disable_notification=True

)

reply_location(latitude: float, longitude: float, message_thread_id: int = None, horizontal_accuracy: float = None, live_period: int = None, heading: int = None, proximity_alert_radius: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a location in reply to the current message.

Parameters:
  • latitude (float) – Latitude of the location.

  • longitude (float) – Longitude of the location.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • horizontal_accuracy (float, optional) – The radius of uncertainty for the location, measured in meters; 0-1500.

  • live_period (int, optional) – Period in seconds for which the location will be updated (should be between 60 and 86400).

  • heading (int, optional) – For live locations, a direction in which the user is moving, in degrees; 1-360.

  • proximity_alert_radius (int, optional) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters; 1-100000.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_location(

latitude=37.7749, longitude=-122.4194, live_period=3600, disable_notification=True

)

reply_media_from_file_id(file_id: str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a media message using a file_id in reply to the current message.

Parameters:
  • file_id (str) – The file_id of the media to be sent.

  • caption (str, optional) – Caption for the media.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the media caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_media_from_file_id(

file_id=”ABC123”, caption=”Check out this media!”, parse_mode=”Markdown”, disable_notification=True

)

reply_media_group(media: List[tgram.types.InputMedia], message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None) List[tgram.types.Message][source]

Sends a group of photos or videos as an album in reply to the current message.

Parameters:
  • media (List[tgram.types.InputMedia]) – A list of media to be sent. Each media item can be a photo or video.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

Returns:

The sent messages.

Return type:

List[tgram.types.Message]

Example

```python media = [

tgram.types.InputMediaPhoto(media=”path/to/photo1.jpg”), tgram.types.InputMediaPhoto(media=”path/to/photo2.jpg”), tgram.types.InputMediaVideo(media=”path/to/video.mp4”)

] await message.reply_media_group(

media=media, disable_notification=True

)

reply_paid_media(star_count: int, media: List[tgram.types.InputPaidMedia], caption: str = None, parse_mode: tgram.types.ParseMode = None, caption_entities: List[tgram.types.MessageEntity] = None, show_caption_above_media: bool = None, disable_notification: bool = None, protect_content: bool = None, reply_markup: tgram.types.InlineKeyboardMarkup | tgram.types.ReplyKeyboardMarkup | tgram.types.ReplyKeyboardRemove | tgram.types.ForceReply = None) tgram.types.Message[source]

Sends a paid media message in reply to the current message.

Parameters:
  • star_count (int) – Number of stars required to view the media.

  • media (List[tgram.types.InputPaidMedia]) – A list of paid media to be sent.

  • caption (str, optional) – Caption for the media.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the media caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python media = [

tgram.types.InputPaidMedia(media=”path/to/photo1.jpg”), tgram.types.InputPaidMedia(media=”path/to/photo2.jpg”)

] await message.reply_paid_media(

star_count=5, media=media, caption=”Check out this paid media!”, parse_mode=”Markdown”, disable_notification=True

)

reply_photo(photo: Path | bytes | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, has_spoiler: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a photo in reply to the current message.

Parameters:
  • photo (Union[Path, bytes, str]) – The photo to be sent. Can be a file path, bytes, or a URL.

  • caption (str, optional) – Caption for the photo.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the photo caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • has_spoiler (bool, optional) – Whether the photo contains a spoiler.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_photo(

photo=”path/to/photo.jpg”, caption=”Check out this photo!”, parse_mode=”Markdown”, disable_notification=True

)

reply_sticker(sticker: Path | bytes | str, emoji: str = None, message_thread_id: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a sticker in reply to the current message.

Parameters:
  • sticker (Union[Path, bytes, str]) – The sticker to be sent. Can be a file path, bytes, or a URL.

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

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_sticker(

sticker=”path/to/sticker.webp”, emoji=”😊”, disable_notification=True

)

reply_text(text: str, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, entities: List[MessageEntity] = None, link_preview_options: LinkPreviewOptions = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a text message in reply to the current message.

Parameters:
  • text (str) – The text of the message to be sent.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the message text.

  • entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in message text, which can be specified instead of parse_mode.

  • link_preview_options (tgram.types.LinkPreviewOptions, optional) – Options for link previews.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_text(

text=”<code>Hello, world!</code>”, parse_mode=”HTML”, disable_notification=True

)

reply_video(video: Path | bytes | str, message_thread_id: int = None, duration: int = None, width: int = None, height: int = None, thumbnail: Path | bytes | str = None, caption: str = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, show_caption_above_media: bool = None, has_spoiler: bool = None, supports_streaming: bool = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a video in reply to the current message.

Parameters:
  • video (Union[Path, bytes, str]) – The video to be sent. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

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

  • width (int, optional) – Video width.

  • height (int, optional) – Video height.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the video.

  • caption (str, optional) – Caption for the video.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the video caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • show_caption_above_media (bool, optional) – Whether to show the caption above the media.

  • has_spoiler (bool, optional) – Whether the video contains a spoiler.

  • supports_streaming (bool, optional) – Whether the video supports streaming.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_video(

video=”path/to/video.mp4”, caption=”Check out this video!”, parse_mode=”Markdown”, disable_notification=True

)

reply_video_note(video_note: Path | bytes | str, message_thread_id: int = None, duration: int = None, length: int = None, thumbnail: Path | bytes | str = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a video note in reply to the current message.

Parameters:
  • video_note (Union[Path, bytes, str]) – The video note to be sent. Can be a file path, bytes, or a URL.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • duration (int, optional) – Duration of the video note in seconds.

  • length (int, optional) – Video width and height (diameter of the video message) in pixels.

  • thumbnail (Union[Path, bytes, str], optional) – Thumbnail of the video note.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_video_note(

video_note=”path/to/video_note.mp4”, duration=60, length=240, disable_notification=True

)

reply_voice(voice: Path | bytes | str, caption: str = None, message_thread_id: int = None, parse_mode: Literal['Markdown', 'MarkdownV2', 'HTML', 'Disable'] = None, caption_entities: List[MessageEntity] = None, duration: int = None, disable_notification: bool = None, protect_content: bool = None, message_effect_id: str = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply = None) Message[source]

Sends a voice message in reply to the current message.

Parameters:
  • voice (Union[Path, bytes, str]) – The voice message to be sent. Can be a file path, bytes, or a URL.

  • caption (str, optional) – Caption for the voice message.

  • message_thread_id (int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.

  • parse_mode (tgram.types.ParseMode, optional) – Mode for parsing entities in the voice message caption.

  • caption_entities (List[tgram.types.MessageEntity], optional) – List of special entities that appear in the caption, which can be specified instead of parse_mode.

  • duration (int, optional) – Duration of the voice message in seconds.

  • disable_notification (bool, optional) – Sends the message silently. Users will receive a notification with no sound.

  • protect_content (bool, optional) – Protects the contents of the sent message from forwarding and saving.

  • message_effect_id (str, optional) – Identifier of the message effect.

  • reply_markup (Union[tgram.types.InlineKeyboardMarkup, tgram.types.ReplyKeyboardMarkup, tgram.types.ReplyKeyboardRemove, tgram.types.ForceReply], optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.

Returns:

The sent message.

Return type:

tgram.types.Message

Example

```python await message.reply_voice(

voice=”path/to/voice.ogg”, caption=”Here is the voice message.”, parse_mode=”Markdown”, duration=60, disable_notification=True

)

property sender_user: User | None

Returns the user who sent the message.

This property retrieves the user who sent the message, if available.

Returns:

The user who sent the message, or None if the user is not available.

Return type:

Optional[tgram.types.User]

Example

```python user = message.user if user:

print(f”Message sent by: {user.first_name}”)

else:

print(“User information is not available.”)

```

property service: str | None

Returns the type of service message contained in the message, if any.

This property checks the message for various types of service messages (e.g., video chat started, pinned message, etc.) and returns the type of service message if found.

Returns:

The type of service message contained in the message, or None if no service message is found.

Return type:

Optional[str]

Example

```python service_type = message.service if service_type:

print(f”The message contains a service message of type {service_type}.”)

else:

print(“The message does not contain any service message.”)

```

property user: User | None

Returns the user who sent the message.

This property retrieves the user who sent the message, if available.

Returns:

The user who sent the message, or None if the user is not available.

Return type:

Optional[tgram.types.User]

Example

```python user = message.user if user:

print(f”Message sent by: {user.first_name}”)

else:

print(“User information is not available.”)

```

class tgram.bound.PaidMediaPurchasedB[source]

Bases: object

property sender_user: User | None
property user: User | None
class tgram.bound.PreCheckoutQueryB[source]

Bases: object

answer(ok: bool = True, error_message: str = None) bool[source]
property sender_user: User | None
property user: User | None
class tgram.bound.ShippingQueryB[source]

Bases: object

property sender_user: User | None
property user: User | None
class tgram.bound.UserB[source]

Bases: object

property full_name: str
property mention: Mention
property photo: PhotoSize | None