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 identifiermessage_id (
int
) – Message identifier in the chat specified in chat_idtext (
str
) – New text of the messageparse_mode (
str
, optional) – Mode for parsing entities in the message textentities (
list
, optional) – List ofMessageEntity
objects representing entities that may appear in the message textdisable_web_page_preview (
bool
, optional) – Disables link previews for links in this message. Default isFalse
url (
str
, optional) – URL to use for link preview. If empty, then the first URL found in the message text will be used. Default isNone
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 isNone
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 isNone
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 isNone
reply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chatfrom_chat_id (
int
) – Identifier for the chat this forwarded message came frommessage_id (
int
) – Identifier of the message to forwardin_game_share (
bool
, optional) – True, if a game message is being shared from a launched game; applies only to game messagesdisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
- Returns:
- 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 parseparse_mode (
str
) – Text parse mode. Currently supported: markdown, markdownv2 and html. Default is “html”
- Return type:
Union
[Error
,FormattedText
]- Returns:
- 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 chatanimation (
InputFileRemote
|InputFileLocal
|str
) – Animation to sendthumbnail (
InputThumbnail
, optional) – Thumbnail of the animation to sendcaption (
str
, optional) – Animation captioncaption_entities (
list
, optional) – List ofMessageEntity
objects to parse in the caption. If you want to send a caption with formatting, useparse_mode
insteadparse_mode (
str
, optional) – Mode for parsing entities. Default ismarkdown
added_sticker_file_ids (
list
, optional) – File identifiers of the stickers added to the animation, if applicableduration (
int
, optional) – Duration of the animation, in secondswidth (
int
, optional) – Width of the animationheight (
int
, optional) – Height of the animationdisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
has_spoiler (
bool
, optional) – True, if the photo preview must be covered by a spoiler animation; not supported in secret chatsmessage_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chataudio (
InputFileRemote
|InputFileLocal
|str
) – Audio to sendalbum_cover_thumbnail (
InputThumbnail
, optional) – Thumbnail of the album cover to be setcaption (
str
, optional) – Audio captioncaption_entities (
list
, optional) – List ofMessageEntity
objects to parse in the caption. If you want to send a caption with formatting, useparse_mode
insteadparse_mode (
str
, optional) – Mode for parsing entities. Default ismarkdown
title (
str
, optional) – Title of the audioperformer (
str
, optional) – Performer of the audioduration (
int
, optional) – Duration of the audio, in secondsdisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chatfrom_chat_id (
int
) – Identifier for the chat this forwarded message came frommessage_id (
int
) – Identifier of the message to forwardin_game_share (
bool
, optional) – True, if a game message is being shared from a launched game; applies only to game messagesreplace_caption (
bool
, optional) – True, if media caption of the message copy needs to be replacednew_caption (
str
, optional) – New caption of the message copynew_caption_entities (
list
, optional) – List ofMessageEntity
objects representing entities in the new captionparse_mode (
str
, optional) – Mode for parsing entities in the new captiondisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specified
- Return type:
- Returns:
- 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 chatdocument (
InputFileRemote
|InputFileLocal
|str
) – Document to sendthumbnail (
InputThumbnail
, optional) – Thumbnail of the document to be setcaption (
str
, optional) – Document captioncaption_entities (
list
, optional) – List ofMessageEntity
objects to parse in the caption. If you want to send a caption with formatting, useparse_mode
insteadparse_mode (
str
, optional) – Mode for parsing entities. Default ismarkdown
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 chatsdisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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:
chat_id (int)
content (InputMessageContent)
disable_notification (bool)
protect_content (bool)
allow_paid_broadcast (bool)
message_thread_id (int)
quote (InputTextQuote | None)
reply_to (InputMessageReplyTo | None)
reply_to_message_id (int)
reply_markup (ReplyMarkupInlineKeyboard | ReplyMarkupShowKeyboard | ReplyMarkupForceReply | ReplyMarkupRemoveKeyboard | None)
- 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 chatphoto (
InputFileRemote
|InputFileLocal
|str
) – Photo to sendthumbnail (
InputThumbnail
, optional) – Thumbnail of the photo to be setcaption (
str
, optional) – Photo captioncaption_entities (
list
, optional) – List ofMessageEntity
objects to parse in the caption. If you want to send a caption with formatting, useparse_mode
insteadparse_mode (
str
, optional) – Mode for parsing entities. Default ismarkdown
added_sticker_file_ids (
list
, optional) – List of file identifiers of added stickerswidth (
int
, optional) – Photo widthheight (
int
, optional) – Photo heightself_destruct_type (
MessageSelfDestructType
, optional) – Photo self-destruct type; pass null if none; private chats onlydisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
has_spoiler (
bool
, optional) – True, if the photo preview must be covered by a spoiler animation; not supported in secret chatsmessage_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chatsticker (
InputFileRemote
|InputFileLocal
|str
) – Sticker to sendemoji (
str
, optional) – Emoji associated with the stickerthumbnail (
InputThumbnail
, optional) – Sticker thumbnailwidth (
int
, optional) – Sticker widthheight (
int
, optional) – Sticker heightdisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chattext (
str
) – Text to sendentities (
list
, optional) – List ofTextEntity
objects to parse in the text. If you want to send a text with formatting, use`parse_mode`
insteadparse_mode (
str
, optional) – Mode for parsing entities. Default ismarkdown
disable_web_page_preview (
bool
, optional) – Disables link previews for links in this message. Default isFalse
url (
str
, optional) – URL to use for link preview. If empty, then the first URL found in the message text will be used. Default isNone
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 isNone
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 isNone
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 isNone
disable_notification (
bool
, optional) – If True, disable notification for the message. Default isNone
clear_draft (
bool
, optional) – True, if a chat message draft must be deleted. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chatvideo (
InputFileRemote
|InputFileLocal
|str
) – Video to sendthumbnail (
InputThumbnail
, optional) – Thumbnail of the video to be setcaption (
str
, optional) – Video captioncaption_entities (
list
, optional) – List ofMessageEntity
objects to parse in the caption. If you want to send a caption with formatting, useparse_mode
insteadparse_mode (
str
, optional) – Mode for parsing entities. Default ismarkdown
added_sticker_file_ids (
list
, optional) – List of file identifiers of added stickerssupports_streaming (
bool
, optional) – True, if the video should be tried to be streamedduration (
int
, optional) – Duration of sent video in secondswidth (
int
, optional) – Video widthheight (
int
, optional) – Video heightself_destruct_type (
MessageSelfDestructType
, optional) – Video self-destruct type; pass null if none; private chats onlydisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
has_spoiler (
bool
, optional) – True, if the photo preview must be covered by a spoiler animation; not supported in secret chatsmessage_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chatvideo_note (
InputFileRemote
|InputFileLocal
|str
) – Video note to sendthumbnail (
InputThumbnail
, optional) – Thumbnail of the video note to be setduration (
int
, optional) – Duration of sent video note in secondslength (
int
, optional) – Video width and heightdisable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns:
- 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 chatvoice (
InputFileRemote
|InputFileLocal
|str
) – Voice to sendcaption (
str
, optional) – Voice captioncaption_entities (
list
, optional) – List ofMessageEntity
objects to parse in the caption. If you want to send a caption without parsing entities, useparse_mode
insteadparse_mode (
str
, optional) – Parse mode for the caption. Default is Noneduration (
int
, optional) – Duration of sent voice in secondswaveform (bytes, optional) – Waveform representation of the voice note, in 5-bit format
disable_notification (
bool
, optional) – If True, disable notification for the message. Default isFalse
protect_content (
bool
, optional) – If True, the content of the message must be protected from forwarding and savingallow_paid_broadcast (
bool
, optional) – Pass true to allow the message to ignore regular broadcast limits for a small fee; for bots only. Default isFalse
message_thread_id (
int
, optional) – If not 0, a message thread identifier in which the message will be sentquote (
InputTextQuote
, optional) – Chosen quote from the replied message; may be null if nonereply_to (
InputMessageReplyTo
, optional) – Information about the message or the story this message is replying to; may be null if nonereply_to_message_id (
int
, optional) – Identifier of the message to reply. Ignored ifreply_to
is specifiedreply_markup (
ReplyMarkupInlineKeyboard
|ReplyMarkupShowKeyboard
|ReplyMarkupForceReply
|ReplyMarkupRemoveKeyboard
, optional) – The message reply markup
- Return type:
- Returns: