mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Remove some redundant examples
This commit is contained in:
parent
48f13229bb
commit
33ea5d8641
@ -93,72 +93,4 @@ Here some examples:
|
||||
)
|
||||
)
|
||||
|
||||
- Get channel/supergroup participants:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import time
|
||||
from pyrogram.api import types, functions
|
||||
|
||||
...
|
||||
|
||||
users = []
|
||||
limit = 200
|
||||
offset = 0
|
||||
|
||||
while True:
|
||||
try:
|
||||
participants = client.send(
|
||||
functions.channels.GetParticipants(
|
||||
channel=client.resolve_peer("username"), # ID or username
|
||||
filter=types.ChannelParticipantsSearch(""), # Filter by empty string (search for all)
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
hash=0
|
||||
)
|
||||
)
|
||||
except FloodWait as e:
|
||||
# Very large channels will trigger FloodWait.
|
||||
# When happens, wait X seconds before continuing
|
||||
time.sleep(e.x)
|
||||
continue
|
||||
|
||||
if not participants.participants:
|
||||
break # No more participants left
|
||||
|
||||
users.extend(participants.users)
|
||||
offset += limit
|
||||
|
||||
- Get history of a chat:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import time
|
||||
from pyrogram.api import types, functions
|
||||
|
||||
...
|
||||
|
||||
history = []
|
||||
limit = 100
|
||||
offset = 0
|
||||
|
||||
while True:
|
||||
try:
|
||||
messages = client.send(
|
||||
functions.messages.GetHistory(
|
||||
client.resolve_peer("me"), # Get your own history
|
||||
0, 0, offset, limit, 0, 0, 0
|
||||
)
|
||||
)
|
||||
except FloodWait as e:
|
||||
# For very large histories the method call can raise a FloodWait
|
||||
time.sleep(e.x)
|
||||
continue
|
||||
|
||||
if not messages.messages:
|
||||
break # No more messages left
|
||||
|
||||
history.extend(messages.messages)
|
||||
offset += limit
|
||||
|
||||
.. _bot-like: https://core.telegram.org/bots/api#available-methods
|
Loading…
Reference in New Issue
Block a user