mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Update some out of date examples in the documentation
This commit is contained in:
parent
1fdf976c04
commit
755aa363ee
|
@ -11,10 +11,9 @@ Working with Chats and Channels
|
||||||
Joining a chat or channel
|
Joining a chat or channel
|
||||||
*************************
|
*************************
|
||||||
|
|
||||||
Note that `Chat`__\ s are normal groups, and `Channel`__\ s are a
|
Note that :tl:`Chat` are normal groups, and :tl:`Channel` are a
|
||||||
special form of `Chat`__\ s,
|
special form of ``Chat``, which can also be super-groups if
|
||||||
which can also be super-groups if their ``megagroup`` member is
|
their ``megagroup`` member is ``True``.
|
||||||
``True``.
|
|
||||||
|
|
||||||
|
|
||||||
Joining a public channel
|
Joining a public channel
|
||||||
|
@ -101,6 +100,13 @@ __ https://lonamiwebs.github.io/Telethon/methods/messages/check_chat_invite.html
|
||||||
Retrieving all chat members (channels too)
|
Retrieving all chat members (channels too)
|
||||||
******************************************
|
******************************************
|
||||||
|
|
||||||
|
You can use
|
||||||
|
:obj:`client.get_participants <telethon.telegram_client.TelegramClient.get_participants>``
|
||||||
|
to retrieve the participants (click it to see the relevant parameters).
|
||||||
|
Most of the time you will just need ``client.get_participants(entity)``.
|
||||||
|
|
||||||
|
This is what said method is doing behind the scenes as an example.
|
||||||
|
|
||||||
In order to get all the members from a mega-group or channel, you need
|
In order to get all the members from a mega-group or channel, you need
|
||||||
to use `GetParticipantsRequest`__. As we can see it needs an
|
to use `GetParticipantsRequest`__. As we can see it needs an
|
||||||
`InputChannel`__, (passing the mega-group or channel you're going to
|
`InputChannel`__, (passing the mega-group or channel you're going to
|
||||||
|
@ -134,9 +140,10 @@ a fixed limit:
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
It is **not** possible to get more than 10,000 members from a
|
If you need more than 10,000 members from a group you should use the
|
||||||
group. It's a hard limit impossed by Telegram and there is
|
mentioned ``client.get_participants(..., aggressive=True)``. It will
|
||||||
nothing you can do about it. Refer to `issue 573`__ for more.
|
do some tricks behind the scenes to get as many entities as possible.
|
||||||
|
Refer to `issue 573`__ for more on this.
|
||||||
|
|
||||||
|
|
||||||
Note that ``GetParticipantsRequest`` returns `ChannelParticipants`__,
|
Note that ``GetParticipantsRequest`` returns `ChannelParticipants`__,
|
||||||
|
|
|
@ -11,18 +11,27 @@ Working with messages
|
||||||
Forwarding messages
|
Forwarding messages
|
||||||
*******************
|
*******************
|
||||||
|
|
||||||
Note that ForwardMessageRequest_ (note it's Message, singular) will *not*
|
This request is available as a friendly method through
|
||||||
work if channels are involved. This is because channel (and megagroups) IDs
|
:obj:`client.forward_messages <telethon.telegram_client.TelegramClient.forward_messages>``,
|
||||||
are not unique, so you also need to know who the sender is (a parameter this
|
and can be used like shown below:
|
||||||
request doesn't have).
|
|
||||||
|
|
||||||
Either way, you are encouraged to use ForwardMessagesRequest_ (note it's
|
|
||||||
Message*s*, plural) *always*, since it is more powerful, as follows:
|
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
# If you only have the message IDs
|
||||||
|
client.forward_messages(
|
||||||
|
entity, # to which entity you are forwarding the messages
|
||||||
|
message_ids, # the IDs of the messages (or message) to forward
|
||||||
|
from_entity # who sent the messages?
|
||||||
|
)
|
||||||
|
|
||||||
|
# If you have ``Message`` objects
|
||||||
|
client.forward_messages(
|
||||||
|
entity, # to which entity you are forwarding the messages
|
||||||
|
messages # the messages (or message) to forward
|
||||||
|
)
|
||||||
|
|
||||||
|
# You can also do it manually if you prefer
|
||||||
from telethon.tl.functions.messages import ForwardMessagesRequest
|
from telethon.tl.functions.messages import ForwardMessagesRequest
|
||||||
# note the s ^
|
|
||||||
|
|
||||||
messages = foo() # retrieve a few messages (or even one, in a list)
|
messages = foo() # retrieve a few messages (or even one, in a list)
|
||||||
from_entity = bar()
|
from_entity = bar()
|
||||||
|
@ -119,7 +128,6 @@ send yourself the very first sticker you have:
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
.. _ForwardMessageRequest: https://lonamiwebs.github.io/Telethon/methods/messages/forward_message.html
|
|
||||||
.. _ForwardMessagesRequest: https://lonamiwebs.github.io/Telethon/methods/messages/forward_messages.html
|
.. _ForwardMessagesRequest: https://lonamiwebs.github.io/Telethon/methods/messages/forward_messages.html
|
||||||
.. _SearchRequest: https://lonamiwebs.github.io/Telethon/methods/messages/search.html
|
.. _SearchRequest: https://lonamiwebs.github.io/Telethon/methods/messages/search.html
|
||||||
.. _issues: https://github.com/LonamiWebs/Telethon/issues/215
|
.. _issues: https://github.com/LonamiWebs/Telethon/issues/215
|
||||||
|
|
Loading…
Reference in New Issue
Block a user