pytdbot.types.bound_methods

class pytdbot.types.bound_methods.CallbackQueryBoundMethods[source]

Bases: object

__init__()[source]
async answer(text, show_alert=None, url=None, cache_time=None)[source]

Answer to callback query. Shortcut for answerCallbackQuery()

Return type:

Union[Error, Ok]

Parameters:
  • text (str)

  • show_alert (bool | None)

  • url (str | None)

  • cache_time (int | None)

async edit_message_caption(caption, caption_entities=None, parse_mode=None, show_caption_above_media=None, reply_markup=None)[source]

Edit message caption

Return type:

Union[Error, Message]

Parameters:
  • caption (str)

  • caption_entities (List[TextEntity] | None)

  • parse_mode (str | None)

  • show_caption_above_media (bool | None)

  • reply_markup (ReplyMarkup | None)

async edit_message_reply_markup(reply_markup)[source]

Edit message reply markup. Shortcut for editMessageReplyMarkup()

Return type:

Union[Error, Message]

Parameters:

reply_markup (ReplyMarkup)

async edit_message_text(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 callback query message text. Shortcut for editTextMessage()

Return type:

Union[Error, Message]

Parameters:
  • text (str)

  • parse_mode (str | None)

  • entities (list | None)

  • disable_web_page_preview (bool)

  • url (str | None)

  • force_small_media (bool | None)

  • force_large_media (bool | None)

  • show_above_text (bool | None)

  • reply_markup (ReplyMarkup | None)

async getMessage()[source]

Get callback query message

Return type:

Union[Error, Message]

property callback_data: CallbackData

Callback data that was set by callback_data()

Parameters:
  • action (Any) – Action name

  • data (Any, optional) – Callback data

property text: str

Callback data decoded as str

class pytdbot.types.bound_methods.FileBoundMethods[source]

Bases: object

__init__()[source]
async download(priority=1, offset=0, limit=0, synchronous=True)[source]

Downloads a file. Shortcut for downloadFile()

Return type:

Union[Error, File]

Parameters:
  • priority (int)

  • offset (int)

  • limit (int)

  • synchronous (bool)

class pytdbot.types.bound_methods.MessageBoundMethods[source]

Bases: object

__init__()[source]
action(action, message_thread_id=None)[source]

Sends a chat action to a specific chat. Supporting context manager (with statement)

Example:

Return type:

ChatActions

async with update.action("record_video") as action:
    ## Any blocking operation
    await asyncio.sleep(10)
    action.setAction("upload_video") # change the action to uploading a video

Parameters:
  • action (Literal['typing', 'upload_photo', 'record_video', 'upload_video', 'record_voice', 'upload_voice', 'upload_document', 'choose_sticker', 'find_location', 'record_video_note', 'upload_video_note', 'cancel'])

  • message_thread_id (int | None)

Or

await update.action("typing")
## Any blocking operation
await asyncio.sleep(2)
await update.reply_text("Hello?")
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, choose_sticker for stickers, find_location` for location data, ``record_video_note or upload_video_note for video notes

message_thread_id (int, optional):

If not 0, a message thread identifier in which the action was performed. Default is None

async ban(banned_until_date=0)[source]

Ban the message sender

Parameters:

banned_until_date (int) – Point in time (Unix timestamp) when the user will be unbanned; 0 if never. If the user is banned for more than 366 days or for less than 30 seconds from the current time, the user is considered to be banned forever. Always 0 in basic groups

Return type:

Union[Error, Ok]

async copy(chat_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_message_id=0)[source]

Copy message to chat. Shortcut for sendCopy().

Return type:

Union[Error, Message]

Parameters:
  • chat_id (int)

  • in_game_share (bool | None)

  • replace_caption (bool | None)

  • new_caption (str | None)

  • new_caption_entities (list | None)

  • parse_mode (str | None)

  • disable_notification (bool)

  • protect_content (bool)

  • allow_paid_broadcast (bool)

  • message_thread_id (int)

  • quote (InputTextQuote | None)

  • reply_to_message_id (int)

async delete(revoke=True)[source]

Delete the received message

Parameters:

revoke (bool, optional) – Pass true to delete messages for all chat members. Always true for supergroups, channels and secret chats

Return type:

Union[Error, Ok]

async download(priority=1, offset=0, limit=0, synchronous=True)[source]

Download the media file and returns LocalFile object. Shortcut for downloadFile().

Return type:

Union[Error, LocalFile]

Parameters:
  • priority (int)

  • offset (int)

  • limit (int)

  • synchronous (bool)

async edit_text(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. Shortcut for editTextMessage().

Return type:

Union[Error, Message]

Parameters:
  • text (str)

  • parse_mode (str | None)

  • entities (list | None)

  • disable_web_page_preview (bool)

  • url (str | None)

  • force_small_media (bool | None)

  • force_large_media (bool | None)

  • show_above_text (bool | None)

  • reply_markup (ReplyMarkup | None)

async forward(chat_id, in_game_share=False, disable_notification=False)[source]

Forward message to chat. Shortcut for forwardMessage().

Return type:

Union[Error, Message]

Parameters:
  • chat_id (int)

  • in_game_share (bool)

  • disable_notification (bool)

async getChat()[source]

Get chat info

Return type:

Union[Error, Chat]

async getChatMember()[source]

Get member info in the current chat

Return type:

Union[Error, ChatMember]

async getMessageLink(media_timestamp=0, for_album=False, in_message_thread=False)[source]

Get message link

Parameters:
  • media_timestamp (int) – If not 0, timestamp from which the video/audio/video note/voice note/story playing must start, in seconds. The media can be in the message content or in its link preview

  • for_album (bool) – Pass true to create a link for the whole media album

  • in_message_thread (bool) – Pass true to create a link to the message as a channel post comment, in a message thread, or a forum topic

Return type:

Union[Error, MessageLink]

async getMessageProperties()[source]

Get the message properties

Return type:

Union[Error, MessageProperties]

async getRepliedMessage()[source]

Get the replied message

Return type:

Union[Error, Message]

async getUser()[source]

Get user info

Return type:

Union[Error, User]

async leaveChat()[source]

Leave the current chat

Return type:

Union[Error, Ok]

async mention(parse_mode='html')[source]

Get the text_mention of the message sender

Parameters:

parse_mode (str, optional) – The parse mode of the mention. Default is html

Return type:

Optional[str]

async pin(disable_notification=False, only_for_self=False)[source]

Pin the message

Parameters:
  • disable_notification (bool, optional) – If True, disable notification for the message

  • only_for_self (bool, optional) – True, if the message needs to be pinned for one side only; private chats only

Return type:

Union[Error, Ok]

async react(emoji='👍', is_big=False)[source]

React to the current message

Parameters:
  • emoji (str, optional) – Text representation of the reaction; pass None to remove the current reaction. Default is 👍

  • is_big (bool, optional) – Pass true if the reactions are added with a big animation. Default is False

Return type:

Union[Error, Ok]

async reply_animation(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, no_reply=False, reply_markup=None)[source]

Reply to the message with animation. Shortcut for sendAnimation().

Return type:

Union[Error, Message]

Parameters:
async reply_audio(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, no_reply=False, reply_markup=None)[source]

Reply to the message with audio. Shortcut for sendAudio().

Return type:

Union[Error, Message]

Parameters:
async reply_document(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, no_reply=False, reply_markup=None)[source]

Reply to the message with a document. Shortcut for sendDocument().

Return type:

Union[Error, Message]

Parameters:
async reply_photo(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, no_reply=None, reply_markup=None)[source]

Reply to the message with a photo. Shortcut for sendPhoto().

Return type:

Union[Error, Message]

Parameters:
async reply_sticker(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, no_reply=None, reply_markup=None)[source]

Reply to the message with a sticker. Shortcut for sendSticker().

Return type:

Union[Error, Message]

Parameters:
async reply_text(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, no_reply=False, reply_markup=None)[source]

Reply to the message with text. Shortcut for sendTextMessage().

Return type:

Union[Error, Message]

Parameters:
async reply_video(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, no_reply=None, reply_markup=None)[source]

Reply to the message with a video. Shortcut for sendVideo().

Return type:

Union[Error, Message]

Parameters:
async reply_video_note(video_note, thumbnail=None, duration=0, length=0, disable_notification=False, protect_content=False, allow_paid_broadcast=False, message_thread_id=0, quote=None, no_reply=None, reply_markup=None)[source]

Reply to the message with a video note. Shortcut for sendVideoNote().

Return type:

Union[Error, Message]

Parameters:
async reply_voice(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, no_reply=None, reply_markup=None)[source]

Reply to the message with a voice note. Shortcut for sendVoice().

Return type:

Union[Error, Message]

Parameters:
async setChatMemberStatus(status)[source]

Set chat member status

Return type:

Union[Error, Ok]

Parameters:

status (ChatMemberStatus)

async unpin()[source]

Unpin the message

Return type:

Union[Error, Ok]

property caption: str | None

Caption of the received media

property caption_entities: List[TextEntity] | None

Caption entities of the received media

property entities: List[TextEntity] | None

Entities of the message

property from_id: int | None

Message Sender ID

property remote_file_id: str | None

Remote file id

property remote_unique_file_id: str | None

Remote unique file id

property reply_to_message_id: int

Replied message ID

property text: str

Text of the message

class pytdbot.types.bound_methods.MessageSenderBoundMethods[source]

Bases: object

__init__()[source]
property from_id: int | None

Returns the message sender’s ID. None if not found

property is_chat: bool

Returns True if the message sender is a chat

property is_user: bool

Returns True if the message sender is a user

Modules