File: objects-reference.rst

package info (click to toggle)
python-telethon 1.40.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,508 kB
  • sloc: python: 16,125; javascript: 200; makefile: 16; sh: 11
file content (353 lines) | stat: -rw-r--r-- 6,898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
=================
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.

.. contents::


ChatGetter
==========

All events base `ChatGetter <telethon.tl.custom.chatgetter.ChatGetter>`,
and some of the objects below do too, so it's important to know its methods.

.. currentmodule:: telethon.tl.custom.chatgetter.ChatGetter

.. autosummary::
    :nosignatures:

    chat
    input_chat
    chat_id
    is_private
    is_group
    is_channel

    get_chat
    get_input_chat


SenderGetter
============

Similar to `ChatGetter <telethon.tl.custom.chatgetter.ChatGetter>`, a
`SenderGetter <telethon.tl.custom.sendergetter.SenderGetter>` is the same,
but it works for senders instead.

.. currentmodule:: telethon.tl.custom.sendergetter.SenderGetter

.. autosummary::
    :nosignatures:

    sender
    input_sender
    sender_id

    get_sender
    get_input_sender


Message
=======

.. currentmodule:: telethon.tl.custom.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 <telethon.tl.custom.chatgetter.ChatGetter>` and
`SenderGetter <telethon.tl.custom.sendergetter.SenderGetter>`.

Properties
----------

.. note::

    We document *custom properties* here, not all the attributes of the
    `Message` (which is the information Telegram actually returns).

.. currentmodule:: telethon.tl.custom.message.Message

.. autosummary::
    :nosignatures:

    text
    raw_text
    is_reply
    forward
    buttons
    button_count
    file
    photo
    document
    web_preview
    audio
    voice
    video
    video_note
    gif
    sticker
    contact
    game
    geo
    invoice
    poll
    venue
    action_entities
    via_bot
    via_input_bot
    client


Methods
-------

.. autosummary::
    :nosignatures:

    respond
    reply
    forward_to
    edit
    delete
    get_reply_message
    click
    mark_read
    pin
    download_media
    get_entities_text
    get_buttons


File
====

The `File <telethon.tl.custom.file.File>` type is a wrapper object
returned by `Message.file <telethon.tl.custom.message.Message.file>`,
and you can use it to easily access a document's attributes, such as
its name, bot-API style file ID, etc.

.. currentmodule:: telethon.tl.custom.file.File

.. autosummary::
    :nosignatures:

    id
    name
    ext
    mime_type
    width
    height
    size
    duration
    title
    performer
    emoji
    sticker_set


Conversation
============

The `Conversation <telethon.tl.custom.conversation.Conversation>` object
is returned by the `client.conversation()
<telethon.client.dialogs.DialogMethods.conversation>` method to easily
send and receive responses like a normal conversation.

It bases `ChatGetter <telethon.tl.custom.chatgetter.ChatGetter>`.

.. currentmodule:: telethon.tl.custom.conversation.Conversation

.. autosummary::
    :nosignatures:

    send_message
    send_file
    mark_read
    get_response
    get_reply
    get_edit
    wait_read
    wait_event
    cancel
    cancel_all


AdminLogEvent
=============

The `AdminLogEvent <telethon.tl.custom.adminlogevent.AdminLogEvent>` object
is returned by the `client.iter_admin_log()
<telethon.client.chats.ChatMethods.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:

.. currentmodule:: telethon.tl.custom.adminlogevent.AdminLogEvent

.. autosummary::
    :nosignatures:

    id
    date
    user_id
    action
    old
    new
    changed_about
    changed_title
    changed_username
    changed_photo
    changed_sticker_set
    changed_message
    deleted_message
    changed_admin
    changed_restrictions
    changed_invites
    joined
    joined_invite
    left
    changed_hide_history
    changed_signatures
    changed_pin
    changed_default_banned_rights
    stopped_poll


Button
======

The `Button <telethon.tl.custom.button.Button>` class is used when you login
as a bot account to send messages with reply markup, such as inline buttons
or custom keyboards.

These are the static methods you can use to create instances of the markup:

.. currentmodule:: telethon.tl.custom.button.Button

.. autosummary::
    :nosignatures:

    inline
    switch_inline
    url
    auth
    text
    request_location
    request_phone
    request_poll
    clear
    force_reply


InlineResult
============

The `InlineResult <telethon.tl.custom.inlineresult.InlineResult>` object
is returned inside a list by the `client.inline_query()
<telethon.client.bots.BotMethods.inline_query>` method to make an inline
query to a bot that supports being used in inline mode, such as
`@like <https://t.me/like>`_.

Note that the list returned is in fact a *subclass* of a list called
`InlineResults <telethon.tl.custom.inlineresults.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:

.. currentmodule:: telethon.tl.custom.inlineresult.InlineResult

.. autosummary::
    :nosignatures:

    ARTICLE
    PHOTO
    GIF
    VIDEO
    VIDEO_GIF
    AUDIO
    DOCUMENT
    LOCATION
    VENUE
    CONTACT
    GAME
    type
    message
    title
    description
    url
    photo
    document
    click
    download_media


Dialog
======

The `Dialog <telethon.tl.custom.dialog.Dialog>` object is returned when
you call `client.iter_dialogs() <telethon.client.dialogs.DialogMethods.iter_dialogs>`.

.. currentmodule:: telethon.tl.custom.dialog.Dialog

.. autosummary::
    :nosignatures:

    send_message
    archive
    delete


Draft
======

The `Draft <telethon.tl.custom.draft.Draft>` object is returned when
you call `client.iter_drafts() <telethon.client.dialogs.DialogMethods.iter_drafts>`.

.. currentmodule:: telethon.tl.custom.draft.Draft

.. autosummary::
    :nosignatures:

    entity
    input_entity
    get_entity
    get_input_entity
    text
    raw_text
    is_empty
    set_message
    send
    delete


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.

.. currentmodule:: telethon.utils

.. autosummary::
    :nosignatures:

    get_display_name
    get_extension
    get_inner_text
    get_peer_id
    resolve_id
    pack_bot_file_id
    resolve_bot_file_id
    resolve_invite_link