mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 17:36:34 +03:00
Clear-up documentation by separating reference from examples
This commit is contained in:
parent
8ae12fbb70
commit
81944262fb
|
@ -10,6 +10,14 @@ The library widely uses the concept of "entities". An entity will refer
|
||||||
to any ``User``, ``Chat`` or ``Channel`` object that the API may return
|
to any ``User``, ``Chat`` or ``Channel`` object that the API may return
|
||||||
in response to certain methods, such as ``GetUsersRequest``.
|
in response to certain methods, such as ``GetUsersRequest``.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
When something "entity-like" is required, it means that you need to
|
||||||
|
provide something that can be turned into an entity. These things include,
|
||||||
|
but are not limited to, usernames, exact titles, IDs, ``Peer`` objects,
|
||||||
|
or even entire ``User``, ``Chat`` and ``Channel`` objects and even phone
|
||||||
|
numbers from people you have in your contacts.
|
||||||
|
|
||||||
Getting entities
|
Getting entities
|
||||||
****************
|
****************
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@ TelegramClient
|
||||||
Introduction
|
Introduction
|
||||||
************
|
************
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Check the :ref:`telethon-package` if you're looking for the methods
|
||||||
|
reference instead of this tutorial.
|
||||||
|
|
||||||
The ``TelegramClient`` is the central class of the library, the one
|
The ``TelegramClient`` is the central class of the library, the one
|
||||||
you will be using most of the time. For this reason, it's important
|
you will be using most of the time. For this reason, it's important
|
||||||
to know what it offers.
|
to know what it offers.
|
||||||
|
@ -86,13 +91,7 @@ Please refer to :ref:`accessing-the-full-api` if these aren't enough,
|
||||||
and don't be afraid to read the source code of the InteractiveTelegramClient_
|
and don't be afraid to read the source code of the InteractiveTelegramClient_
|
||||||
or even the TelegramClient_ itself to learn how it works.
|
or even the TelegramClient_ itself to learn how it works.
|
||||||
|
|
||||||
|
To see the methods available in the client, see :ref:`telethon-package`.
|
||||||
|
|
||||||
.. _InteractiveTelegramClient: https://github.com/LonamiWebs/Telethon/blob/master/telethon_examples/interactive_telegram_client.py
|
.. _InteractiveTelegramClient: https://github.com/LonamiWebs/Telethon/blob/master/telethon_examples/interactive_telegram_client.py
|
||||||
.. _TelegramClient: https://github.com/LonamiWebs/Telethon/blob/master/telethon/telegram_client.py
|
.. _TelegramClient: https://github.com/LonamiWebs/Telethon/blob/master/telethon/telegram_client.py
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. automodule:: telethon.telegram_client
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ Working with Updates
|
||||||
|
|
||||||
The library comes with the :mod:`events` module. *Events* are an abstraction
|
The library comes with the :mod:`events` module. *Events* are an abstraction
|
||||||
over what Telegram calls `updates`__, and are meant to ease simple and common
|
over what Telegram calls `updates`__, and are meant to ease simple and common
|
||||||
usage when dealing with them, since there are many updates. Let's dive in!
|
usage when dealing with them, since there are many updates. If you're looking
|
||||||
|
for the method reference, check :ref:`telethon-events-package`, otherwise,
|
||||||
|
let's dive in!
|
||||||
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -114,12 +116,15 @@ for example:
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
|
||||||
@client.on(events.NewMessage(chats='TelethonOffTopic', incoming=True))
|
# Either a single item or a list of them will work for the chats.
|
||||||
|
# You can also use the IDs, Peers, or even User/Chat/Channel objects.
|
||||||
|
@client.on(events.NewMessage(chats=('TelethonChat', 'TelethonOffTopic')))
|
||||||
def normal_handler(event):
|
def normal_handler(event):
|
||||||
if 'roll' in event.raw_text:
|
if 'roll' in event.raw_text:
|
||||||
event.reply(str(random.randint(1, 6)))
|
event.reply(str(random.randint(1, 6)))
|
||||||
|
|
||||||
|
|
||||||
|
# Similarly, you can use incoming=True for messages that you receive
|
||||||
@client.on(events.NewMessage(chats='TelethonOffTopic', outgoing=True))
|
@client.on(events.NewMessage(chats='TelethonOffTopic', outgoing=True))
|
||||||
def admin_handler(event):
|
def admin_handler(event):
|
||||||
if event.raw_text.startswith('eval'):
|
if event.raw_text.startswith('eval'):
|
||||||
|
@ -162,14 +167,8 @@ propagation of the update through your handlers to stop:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
Events module
|
Remember to check :ref:`telethon-events-package` if you're looking for
|
||||||
*************
|
the methods reference.
|
||||||
|
|
||||||
.. automodule:: telethon.events
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__ https://lonamiwebs.github.io/Telethon/types/update.html
|
__ https://lonamiwebs.github.io/Telethon/types/update.html
|
||||||
|
|
|
@ -15,7 +15,8 @@ or use the menu on the left. Remember to read the :ref:`changelog`
|
||||||
when you upgrade!
|
when you upgrade!
|
||||||
|
|
||||||
.. important::
|
.. important::
|
||||||
If you're new here, you want to read :ref:`getting-started`.
|
If you're new here, you want to read :ref:`getting-started`. If you're
|
||||||
|
looking for the method reference, you should check :ref:`telethon-package`.
|
||||||
|
|
||||||
|
|
||||||
What is this?
|
What is this?
|
||||||
|
|
|
@ -42,14 +42,6 @@ telethon\.crypto\.factorization module
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
telethon\.crypto\.libssl module
|
|
||||||
-------------------------------
|
|
||||||
|
|
||||||
.. automodule:: telethon.crypto.libssl
|
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
telethon\.crypto\.rsa module
|
telethon\.crypto\.rsa module
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
.. _telethon-events-package:
|
||||||
|
|
||||||
telethon\.events package
|
telethon\.events package
|
||||||
========================
|
========================
|
||||||
|
|
||||||
|
.. automodule:: telethon.events
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
:show-inheritance:
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
.. _telethon-package:
|
||||||
|
|
||||||
|
|
||||||
telethon package
|
telethon package
|
||||||
================
|
================
|
||||||
|
|
||||||
|
|
||||||
telethon\.helpers module
|
telethon\.telegram\_client module
|
||||||
------------------------
|
---------------------------------
|
||||||
|
|
||||||
.. automodule:: telethon.helpers
|
.. automodule:: telethon.telegram_client
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
@ -18,10 +21,18 @@ telethon\.telegram\_bare\_client module
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
telethon\.telegram\_client module
|
telethon\.utils module
|
||||||
---------------------------------
|
----------------------
|
||||||
|
|
||||||
.. automodule:: telethon.telegram_client
|
.. automodule:: telethon.utils
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
:show-inheritance:
|
||||||
|
|
||||||
|
telethon\.helpers module
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
.. automodule:: telethon.helpers
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
@ -42,18 +53,10 @@ telethon\.update\_state module
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
||||||
telethon\.utils module
|
telethon\.sessions module
|
||||||
----------------------
|
-------------------------
|
||||||
|
|
||||||
.. automodule:: telethon.utils
|
.. automodule:: telethon.sessions
|
||||||
:members:
|
|
||||||
:undoc-members:
|
|
||||||
:show-inheritance:
|
|
||||||
|
|
||||||
telethon\.session module
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
.. automodule:: telethon.session
|
|
||||||
:members:
|
:members:
|
||||||
:undoc-members:
|
:undoc-members:
|
||||||
:show-inheritance:
|
:show-inheritance:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user