mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +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
|
.. _bot-like: https://core.telegram.org/bots/api#available-methods
|
Loading…
x
Reference in New Issue
Block a user