pytdbot.methods.methods

class pytdbot.methods.methods.Methods[source]

Bases: TDLibFunctions

TDLib API functions class

async editTextMessage(chat_id, message_id, text, parse_mode=None, entities=None, disable_web_page_preview=False, url=None, force_small_media=None, force_large_media=None, show_above_text=None, reply_markup=None)[source]

Edit text message

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Message identifier in the chat specified in chat_id

  • text (str) – New text of the message

  • parse_mode (str, optional) – Mode for parsing entities in the message text

  • entities (list, optional) – List of MessageEntity objects representing entities that may appear in the message text

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

  • url (str, optional) – URL to use for link preview. If empty, then the first URL found in the message text will be used. Default is None

  • force_small_media (bool, optional) – True, if shown media preview must be small; ignored in secret chats or if the URL isn’t explicitly specified. Default is None

  • force_large_media (bool, optional) – True, if shown media preview must be large; ignored in secret chats or if the URL isn’t explicitly specified. Default is None

  • show_above_text (bool, optional) – True, if link preview must be shown above message text; otherwise, the link preview will be shown below the message text; ignored in secret chats. Default is None

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async forwardMessage(chat_id, from_chat_id, message_id, in_game_share=False, disable_notification=False)[source]

Forward message to chat

Parameters:
  • chat_id (int) – Target chat

  • from_chat_id (int) – Identifier for the chat this forwarded message came from

  • message_id (int) – Identifier of the message to forward

  • in_game_share (bool, optional) – True, if a game message is being shared from a launched game; applies only to game messages

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

Returns:

Message

async getSupergroupId(chat_id)[source]

Get supergroup id from chat id

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, int, None]

Returns:

int

async parseText(text, parse_mode='html')[source]

Parses Bold, Italic, Underline, Strikethrough, Spoiler, Code, Pre, PreCode, TextUrl and MentionName entities contained in the text

Parameters:
  • text (str) – The text to parse

  • parse_mode (str) – Text parse mode. Currently supported: markdown, markdownv2 and html. Default is “html”

Return type:

Union[Error, FormattedText]

Returns:

FormattedText

async sendAnimation(chat_id, animation, thumbnail=None, caption=None, caption_entities=None, parse_mode=None, added_sticker_file_ids=None, duration=0, width=0, height=0, disable_notification=False, protect_content=False, allow_paid_broadcast=False, has_spoiler=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send animation to chat

Parameters:
  • chat_id (int) – Target chat

  • animation (InputFileRemote | InputFileLocal | str) – Animation to send

  • thumbnail (InputThumbnail, optional) – Thumbnail of the animation to send

  • caption (str, optional) – Animation caption

  • caption_entities (list, optional) – List of MessageEntity objects to parse in the caption. If you want to send a caption with formatting, use parse_mode instead

  • parse_mode (str, optional) – Mode for parsing entities. Default is markdown

  • added_sticker_file_ids (list, optional) – File identifiers of the stickers added to the animation, if applicable

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

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

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

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • has_spoiler (bool, optional) – True, if the photo preview must be covered by a spoiler animation; not supported in secret chats

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendAudio(chat_id, audio, album_cover_thumbnail=None, caption=None, caption_entities=None, parse_mode=None, title=None, performer=None, duration=0, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send audio to chat

Parameters:
  • chat_id (int) – Target chat

  • audio (InputFileRemote | InputFileLocal | str) – Audio to send

  • album_cover_thumbnail (InputThumbnail, optional) – Thumbnail of the album cover to be set

  • caption (str, optional) – Audio caption

  • caption_entities (list, optional) – List of MessageEntity objects to parse in the caption. If you want to send a caption with formatting, use parse_mode instead

  • parse_mode (str, optional) – Mode for parsing entities. Default is markdown

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

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

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

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendCopy(chat_id, from_chat_id, message_id, in_game_share=None, replace_caption=None, new_caption=None, new_caption_entities=None, parse_mode=None, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0)[source]

Copy message to chat

Parameters:
  • chat_id (int) – Target chat

  • from_chat_id (int) – Identifier for the chat this forwarded message came from

  • message_id (int) – Identifier of the message to forward

  • in_game_share (bool, optional) – True, if a game message is being shared from a launched game; applies only to game messages

  • replace_caption (bool, optional) – True, if media caption of the message copy needs to be replaced

  • new_caption (str, optional) – New caption of the message copy

  • new_caption_entities (list, optional) – List of MessageEntity objects representing entities in the new caption

  • parse_mode (str, optional) – Mode for parsing entities in the new caption

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

Return type:

Union[Error, Message]

Returns:

Message

async sendDocument(chat_id, document, thumbnail=None, caption=None, caption_entities=None, parse_mode=None, disable_content_type_detection=True, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send document to chat

Parameters:
  • chat_id (int) – Target chat

  • document (InputFileRemote | InputFileLocal | str) – Document to send

  • thumbnail (InputThumbnail, optional) – Thumbnail of the document to be set

  • caption (str, optional) – Document caption

  • caption_entities (list, optional) – List of MessageEntity objects to parse in the caption. If you want to send a caption with formatting, use parse_mode instead

  • parse_mode (str, optional) – Mode for parsing entities. Default is markdown

  • disable_content_type_detection (bool, optional) – If true, automatic file type detection will be disabled and the document will be always sent as file. Always true for files sent to secret chats

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendMessageWithContent(chat_id, content, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]
Parameters:
async sendPhoto(chat_id, photo, thumbnail=None, caption=None, caption_entities=None, parse_mode=None, added_sticker_file_ids=None, width=0, height=0, self_destruct_type=None, disable_notification=False, protect_content=False, allow_paid_broadcast=False, has_spoiler=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send photo to chat

Parameters:
  • chat_id (int) – Target chat

  • photo (InputFileRemote | InputFileLocal | str) – Photo to send

  • thumbnail (InputThumbnail, optional) – Thumbnail of the photo to be set

  • caption (str, optional) – Photo caption

  • caption_entities (list, optional) – List of MessageEntity objects to parse in the caption. If you want to send a caption with formatting, use parse_mode instead

  • parse_mode (str, optional) – Mode for parsing entities. Default is markdown

  • added_sticker_file_ids (list, optional) – List of file identifiers of added stickers

  • width (int, optional) – Photo width

  • height (int, optional) – Photo height

  • self_destruct_type (MessageSelfDestructType, optional) – Photo self-destruct type; pass null if none; private chats only

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • has_spoiler (bool, optional) – True, if the photo preview must be covered by a spoiler animation; not supported in secret chats

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendSticker(chat_id, sticker, emoji=None, thumbnail=None, width=0, height=0, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send sticker to chat

Parameters:
  • chat_id (int) – Target chat

  • sticker (InputFileRemote | InputFileLocal | str) – Sticker to send

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

  • thumbnail (InputThumbnail, optional) – Sticker thumbnail

  • width (int, optional) – Sticker width

  • height (int, optional) – Sticker height

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendTextMessage(chat_id, text, entities=None, parse_mode=None, disable_web_page_preview=False, url=None, force_small_media=None, force_large_media=None, show_above_text=None, clear_draft=False, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send text message to chat

Parameters:
  • chat_id (int) – Target chat

  • text (str) – Text to send

  • entities (list, optional) – List of TextEntity objects to parse in the text. If you want to send a text with formatting, use `parse_mode` instead

  • parse_mode (str, optional) – Mode for parsing entities. Default is markdown

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

  • url (str, optional) – URL to use for link preview. If empty, then the first URL found in the message text will be used. Default is None

  • force_small_media (bool, optional) – True, if shown media preview must be small; ignored in secret chats or if the URL isn’t explicitly specified. Default is None

  • force_large_media (bool, optional) – True, if shown media preview must be large; ignored in secret chats or if the URL isn’t explicitly specified. Default is None

  • show_above_text (bool, optional) – True, if link preview must be shown above message text; otherwise, the link preview will be shown below the message text; ignored in secret chats. Default is None

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is None

  • clear_draft (bool, optional) – True, if a chat message draft must be deleted. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendVideo(chat_id, video, thumbnail=None, caption=None, caption_entities=None, parse_mode=None, added_sticker_file_ids=None, supports_streaming=None, duration=0, width=0, height=0, self_destruct_type=None, disable_notification=False, protect_content=False, allow_paid_broadcast=False, has_spoiler=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send video to chat

Parameters:
  • chat_id (int) – Target chat

  • video (InputFileRemote | InputFileLocal | str) – Video to send

  • thumbnail (InputThumbnail, optional) – Thumbnail of the video to be set

  • caption (str, optional) – Video caption

  • caption_entities (list, optional) – List of MessageEntity objects to parse in the caption. If you want to send a caption with formatting, use parse_mode instead

  • parse_mode (str, optional) – Mode for parsing entities. Default is markdown

  • added_sticker_file_ids (list, optional) – List of file identifiers of added stickers

  • supports_streaming (bool, optional) – True, if the video should be tried to be streamed

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

  • width (int, optional) – Video width

  • height (int, optional) – Video height

  • self_destruct_type (MessageSelfDestructType, optional) – Video self-destruct type; pass null if none; private chats only

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • has_spoiler (bool, optional) – True, if the photo preview must be covered by a spoiler animation; not supported in secret chats

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendVideoNote(chat_id, video_note, thumbnail=None, duration=0, length=0, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send video note to chat

Parameters:
  • chat_id (int) – Target chat

  • video_note (InputFileRemote | InputFileLocal | str) – Video note to send

  • thumbnail (InputThumbnail, optional) – Thumbnail of the video note to be set

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

  • length (int, optional) – Video width and height

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message

async sendVoice(chat_id, voice, caption=None, caption_entities=None, parse_mode=None, duration=0, waveform=None, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, reply_to=None, reply_to_message_id=0, reply_markup=None)[source]

Send voice to chat

Parameters:
  • chat_id (int) – Target chat

  • voice (InputFileRemote | InputFileLocal | str) – Voice to send

  • caption (str, optional) – Voice caption

  • caption_entities (list, optional) – List of MessageEntity objects to parse in the caption. If you want to send a caption without parsing entities, use parse_mode instead

  • parse_mode (str, optional) – Parse mode for the caption. Default is None

  • duration (int, optional) – Duration of sent voice in seconds

  • waveform (bytes, optional) – Waveform representation of the voice note, in 5-bit format

  • disable_notification (bool, optional) – If True, disable notification for the message. Default is False

  • protect_content (bool, optional) – If True, the content of the message must be protected from forwarding and saving

  • allow_paid_broadcast (bool, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default is False

  • message_thread_id (int, optional) – If not 0, a message thread identifier in which the message will be sent

  • quote (InputTextQuote, optional) – Chosen quote from the replied message; may be null if none

  • reply_to (InputMessageReplyTo, optional) – Information about the message or the story this message is replying to; may be null if none

  • reply_to_message_id (int, optional) – Identifier of the message to reply. Ignored if reply_to is specified

  • reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard, optional) – The message reply markup

Return type:

Union[Error, Message]

Returns:

Message