Objects Reference
This is the quick reference for those objects returned by client methods or other useful modules that the library has to offer. They are kept in a separate page to help finding and discovering them.
Remember that this page only shows properties and methods, not attributes. Make sure to open the full documentation to find out about the attributes.
ChatGetter
All events base ChatGetter
,
and some of the objects below do too, so it’s important to know its methods.
Returns the User, Chat or Channel where this object belongs to. |
|
This InputPeer is the input version of the chat where the message was sent. |
|
Returns the marked chat integer ID. |
|
|
|
True if the message was sent on a group or megagroup. |
|
|
|
Returns |
|
Returns |
SenderGetter
Similar to ChatGetter
, a
SenderGetter
is the same,
but it works for senders instead.
This InputPeer is the input version of the user/channel who sent the message. |
|
Returns the marked sender integer ID, if present. |
|
Returns |
|
Returns |
Message
The Message
type is very important, mostly because we are working
with a library for a messaging platform, so messages are widely used:
in events, when fetching history, replies, etc.
It bases ChatGetter
and
SenderGetter
.
Properties
Note
We document custom properties here, not all the attributes of the
Message
(which is the information Telegram actually returns).
The message text, formatted using the client's default parse mode. |
|
The raw message text, ignoring any formatting. |
|
|
|
The |
|
Returns a list of lists of |
|
Returns the total button count (sum of all |
|
Returns a |
|
The Photo media in this message, if any. |
|
The Document media in this message, if any. |
|
The WebPage media in this message, if any. |
|
The Document media in this message, if it's an audio file. |
|
The Document media in this message, if it's a voice note. |
|
The Document media in this message, if it's a video. |
|
The Document media in this message, if it's a video note. |
|
The Document media in this message, if it's a "gif". |
|
The Document media in this message, if it's a sticker. |
|
The MessageMediaContact in this message, if it's a contact. |
|
The Game media in this message, if it's a game. |
|
The GeoPoint media in this message, if it has a location. |
|
The MessageMediaInvoice in this message, if it's an invoice. |
|
The MessageMediaPoll in this message, if it's a poll. |
|
The MessageMediaVenue in this message, if it's a venue. |
|
Returns a list of entities that took part in this action. |
|
The bot User if the message was sent via said bot. |
|
Returns the input variant of |
|
Returns the |
Methods
Responds to the message (not as a reply). |
|
Replies to the message (as a reply). |
|
Forwards the message. |
|
Edits the message if it's outgoing. |
|
Deletes the message. |
|
The |
|
Calls SendVote with the specified poll option or |
|
Marks the message as read. |
|
Pins the message. |
|
Downloads the media contained in the message, if any. |
|
Returns a list of |
|
Returns |
File
The File
type is a wrapper object
returned by Message.file
,
and you can use it to easily access a document’s attributes, such as
its name, bot-API style file ID, etc.
The old bot-API style |
|
The file name of this document. |
|
The extension from the mime type of this file. |
|
The mime-type of this file. |
|
The width in pixels of this media if it's a photo or a video. |
|
The height in pixels of this media if it's a photo or a video. |
|
The size in bytes of this file. |
|
The duration in seconds of the audio or video. |
|
The title of the song. |
|
The performer of the song. |
|
A string with all emoji that represent the current sticker. |
|
The InputStickerSet to which the sticker file belongs. |
Conversation
The Conversation
object
is returned by the client.conversation()
method to easily
send and receive responses like a normal conversation.
It bases ChatGetter
.
Sends a message in the context of this conversation. |
|
Sends a file in the context of this conversation. |
|
Marks as read the latest received message if |
|
Gets the next message that responds to a previous one. |
|
Gets the next message that explicitly replies to a previous one. |
|
Awaits for an edit after the last message to arrive. |
|
Awaits for the sent message to be marked as read. |
|
Waits for a custom event to occur. |
|
Cancels the current conversation. |
|
Calls |
AdminLogEvent
The AdminLogEvent
object
is returned by the client.iter_admin_log()
method to easily iterate
over past “events” (deleted messages, edits, title changes, leaving members…)
These are all the properties you can find in it:
The ID of this event. |
|
The date when this event occurred. |
|
The ID of the user that triggered this event. |
|
The original ChannelAdminLogEventAction. |
|
The old value from the event. |
|
The new value present in the event. |
|
Whether the channel's about was changed or not. |
|
Whether the channel's title was changed or not. |
|
Whether the channel's username was changed or not. |
|
Whether the channel's photo was changed or not. |
|
Whether the channel's sticker set was changed or not. |
|
Whether a message in this channel was edited or not. |
|
Whether a message in this channel was deleted or not. |
|
Whether the permissions for an admin in this channel changed or not. |
|
Whether a message in this channel was edited or not. |
|
Whether the invites in the channel were toggled or not. |
|
Whether |
|
Whether a new user joined through an invite link to the channel or not. |
|
Whether |
|
Whether hiding the previous message history for new members in the channel was toggled or not. |
|
Whether the message signatures in the channel were toggled or not. |
|
Whether a new message in this channel was pinned or not. |
|
Whether the default banned rights were changed or not. |
|
Whether a poll was stopped or not. |
InlineResult
The InlineResult
object
is returned inside a list by the client.inline_query()
method to make an inline
query to a bot that supports being used in inline mode, such as
@like.
Note that the list returned is in fact a subclass of a list called
InlineResults
, which,
in addition of being a list (iterator, indexed access, etc.), has extra
attributes and methods.
These are the constants for the types, properties and methods you can find the individual results:
The always-present type of this result. |
|
The always-present BotInlineMessage that will be sent if |
|
The title for this inline result. |
|
The description for this inline result. |
|
The URL present in this inline results. |
|
Returns either the WebDocument thumbnail for normal results or the Photo for media results. |
|
Returns either the WebDocument content for normal results or the Document for media results. |
|
Clicks this result and sends the associated |
|
Downloads the media in this result (if there is a document, the document will be downloaded; otherwise, the photo will if present). |
Dialog
The Dialog
object is returned when
you call client.iter_dialogs()
.
Sends a message to this dialog. |
|
Archives (or un-archives) this dialog. |
|
Deletes the dialog from your dialog list. |
Draft
The Draft
object is returned when
you call client.iter_drafts()
.
The entity that belongs to this dialog (user, chat or channel). |
|
Input version of the entity. |
|
Returns |
|
Returns |
|
The markdown text contained in the draft. |
|
The raw (text without formatting) contained in the draft. |
|
Convenience bool to determine if the draft is empty or not. |
|
Changes the draft message on the Telegram servers. |
|
Sends the contents of this draft to the dialog. |
|
Deletes this draft, and returns |
Utils
The telethon.utils
module has plenty of methods that make using the
library a lot easier. Only the interesting ones will be listed here.
Gets the corresponding extension for any Telegram media. |
|
Gets the inner text that's surrounded by the given entities. |
|
Convert the given peer into its marked ID by default. |
|
Given a marked ID, returns the original ID and its Peer type. |
|
Inverse operation for |
|
Given a Bot API-style |
|
Resolves the given invite link. |