mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 12:57:52 +00:00
Update docs
This commit is contained in:
parent
6a5810134b
commit
7439e1e8f2
@ -26,6 +26,7 @@ Client
|
||||
send_video
|
||||
send_voice
|
||||
send_video_note
|
||||
send_media_group
|
||||
send_location
|
||||
send_venue
|
||||
send_contact
|
||||
@ -40,4 +41,5 @@ Client
|
||||
enable_cloud_password
|
||||
change_cloud_password
|
||||
remove_cloud_password
|
||||
send_media_group
|
||||
add_contacts
|
||||
delete_contacts
|
6
docs/source/pyrogram/InputPhoneContact.rst
Normal file
6
docs/source/pyrogram/InputPhoneContact.rst
Normal file
@ -0,0 +1,6 @@
|
||||
InputPhoneContact
|
||||
=================
|
||||
|
||||
.. autoclass:: pyrogram.InputPhoneContact
|
||||
:members:
|
||||
:undoc-members:
|
@ -13,6 +13,7 @@ the same parameters as well, thus offering a familiar look to Bot developers.
|
||||
ParseMode
|
||||
Emoji
|
||||
InputMedia
|
||||
InputPhoneContact
|
||||
Error
|
||||
|
||||
.. _Telegram Bot API: https://core.telegram.org/bots/api#available-methods
|
||||
|
@ -25,5 +25,26 @@ with your own settings:
|
||||
- ``1``, ``yes``, ``True`` or ``on``: Enables the proxy
|
||||
- ``0``, ``no``, ``False`` or ``off``: Disables the proxy
|
||||
|
||||
- If your proxy doesn't require authorization you can omit username and password by either leaving the values blank
|
||||
or completely delete the lines.
|
||||
Alternatively, you can setup your proxy without the need of the *config.ini* file by using the *proxy* parameter
|
||||
in the Client class:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from pyrogram import Client
|
||||
|
||||
client = Client(
|
||||
session_name="example",
|
||||
proxy=dict(
|
||||
hostname="11.22.33.44",
|
||||
port=1080,
|
||||
username="<your_username>",
|
||||
password="<your_password>"
|
||||
)
|
||||
)
|
||||
|
||||
client.start()
|
||||
|
||||
...
|
||||
|
||||
.. note:: If your proxy doesn't require authorization you can omit *username* and *password* by either leaving the
|
||||
values blank/empty or completely delete the lines.
|
@ -50,6 +50,8 @@ Here some examples:
|
||||
|
||||
from pyrogram.api import functions
|
||||
|
||||
...
|
||||
|
||||
client.send(
|
||||
functions.account.UpdateProfile(
|
||||
first_name="Dan", last_name="Tès",
|
||||
@ -63,6 +65,8 @@ Here some examples:
|
||||
|
||||
from pyrogram.api import functions, types
|
||||
|
||||
...
|
||||
|
||||
client.send(
|
||||
functions.account.SetPrivacy(
|
||||
key=types.InputPrivacyKeyStatusTimestamp(),
|
||||
@ -70,4 +74,91 @@ Here some examples:
|
||||
)
|
||||
)
|
||||
|
||||
- Invite users to your channel/supergroup:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from pyrogram.api import functions, types
|
||||
|
||||
...
|
||||
|
||||
client.send(
|
||||
functions.channels.InviteToChannel(
|
||||
channel=client.resolve_peer(123456789), # ID or Username of your channel
|
||||
users=[ # The users you want to invite
|
||||
client.resolve_peer(23456789), # By ID
|
||||
client.resolve_peer("username"), # By username
|
||||
client.resolve_peer("393281234567"), # By phone number
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
- 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.
|
||||
# In that case wait X seconds before continuing
|
||||
time.sleep(e.x)
|
||||
continue
|
||||
|
||||
if not participants.participants:
|
||||
break # No more participants left
|
||||
|
||||
users.extend(participants.users)
|
||||
offset += len(participants.users)
|
||||
|
||||
- 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 += len(messages.messages)
|
||||
|
||||
.. _bot-like: https://core.telegram.org/bots/api#available-methods
|
@ -19,14 +19,30 @@ If you already have one you can skip this, otherwise:
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Create a new ``config.ini`` file at the root of your working directory,
|
||||
copy-paste the following and replace the **api_id** and **api_hash** values with `your own <#api-keys>`_:
|
||||
There are two ways to configure a Pyrogram application project, and you can choose the one that fits better for you:
|
||||
|
||||
.. code-block:: ini
|
||||
- Create a new ``config.ini`` file at the root of your working directory,
|
||||
copy-paste the following and replace the **api_id** and **api_hash** values with `your own <#api-keys>`_:
|
||||
|
||||
[pyrogram]
|
||||
api_id = 12345
|
||||
api_hash = 0123456789abcdef0123456789abcdef
|
||||
.. code-block:: ini
|
||||
|
||||
[pyrogram]
|
||||
api_id = 12345
|
||||
api_hash = 0123456789abcdef0123456789abcdef
|
||||
|
||||
- Alternatively, you can pass your API key to Pyrogram by simply using the *api_key* parameter of the Client class:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from pyrogram import Client
|
||||
|
||||
client = Client(
|
||||
session_name="example",
|
||||
api_key=(12345, "0123456789abcdef0123456789abcdef")
|
||||
)
|
||||
|
||||
.. note:: The examples below will assume you have created a *config.ini* file, thus they won't show the *api_key*
|
||||
parameter usage in the Client class.
|
||||
|
||||
Authorization
|
||||
-------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user