mirror of
https://github.com/pyrogram/pyrogram
synced 2025-09-09 18:55:51 +00:00
Revamp docs about the main Pyrogram package
This commit is contained in:
@@ -64,7 +64,7 @@ class Client(Methods, BaseClient):
|
||||
It exposes bot-like methods for an easy access to the API as well as a simple way to
|
||||
invoke every single Telegram API method available.
|
||||
|
||||
Args:
|
||||
Parameters:
|
||||
session_name (``str``):
|
||||
Name to uniquely identify a session of either a User or a Bot, e.g.: "my_account". This name will be used
|
||||
to save a file to disk that stores details needed for reconnecting without asking again for credentials.
|
||||
@@ -264,8 +264,8 @@ class Client(Methods, BaseClient):
|
||||
"""Use this method to start the Client.
|
||||
|
||||
Raises:
|
||||
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
|
||||
``ConnectionError`` in case you try to start an already started Client.
|
||||
RPCError: In case of a Telegram RPC error.
|
||||
ConnectionError: In case you try to start an already started Client.
|
||||
"""
|
||||
if self.is_started:
|
||||
raise ConnectionError("Client has already been started")
|
||||
@@ -357,7 +357,7 @@ class Client(Methods, BaseClient):
|
||||
"""Use this method to stop the Client.
|
||||
|
||||
Raises:
|
||||
``ConnectionError`` in case you try to stop an already stopped Client.
|
||||
ConnectionError: In case you try to stop an already stopped Client.
|
||||
"""
|
||||
if not self.is_started:
|
||||
raise ConnectionError("Client is already stopped")
|
||||
@@ -399,7 +399,7 @@ class Client(Methods, BaseClient):
|
||||
"""Use this method to restart the Client.
|
||||
|
||||
Raises:
|
||||
``ConnectionError`` in case you try to restart a stopped Client.
|
||||
ConnectionError: In case you try to restart a stopped Client.
|
||||
"""
|
||||
self.stop()
|
||||
self.start()
|
||||
@@ -416,7 +416,7 @@ class Client(Methods, BaseClient):
|
||||
the main script; calling idle() will ensure the client(s) will be kept alive by not letting the main script to
|
||||
end, until you decide to quit.
|
||||
|
||||
Args:
|
||||
Parameters:
|
||||
stop_signals (``tuple``, *optional*):
|
||||
Iterable containing signals the signal handler will listen to.
|
||||
Defaults to (SIGINT, SIGTERM, SIGABRT).
|
||||
@@ -445,7 +445,7 @@ class Client(Methods, BaseClient):
|
||||
since :meth:`idle` will block.
|
||||
|
||||
Raises:
|
||||
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
|
||||
RPCError: In case of a Telegram RPC error.
|
||||
"""
|
||||
self.start()
|
||||
self.idle()
|
||||
@@ -457,7 +457,7 @@ class Client(Methods, BaseClient):
|
||||
will be used for a single update. To handle the same update more than once, register
|
||||
your handler using a different group id (lower group id == higher priority).
|
||||
|
||||
Args:
|
||||
Parameters:
|
||||
handler (``Handler``):
|
||||
The handler to be registered.
|
||||
|
||||
@@ -465,7 +465,7 @@ class Client(Methods, BaseClient):
|
||||
The group identifier, defaults to 0.
|
||||
|
||||
Returns:
|
||||
A tuple of (handler, group)
|
||||
``tuple``: A tuple consisting of (handler, group).
|
||||
"""
|
||||
if isinstance(handler, DisconnectHandler):
|
||||
self.disconnect_handler = handler.callback
|
||||
@@ -481,7 +481,7 @@ class Client(Methods, BaseClient):
|
||||
the return value of the :meth:`add_handler` method, a tuple of (handler, group), and
|
||||
pass it directly.
|
||||
|
||||
Args:
|
||||
Parameters:
|
||||
handler (``Handler``):
|
||||
The handler to be removed.
|
||||
|
||||
@@ -1048,8 +1048,8 @@ class Client(Methods, BaseClient):
|
||||
:obj:`functions <pyrogram.api.functions>` (i.e: a Telegram API method you wish to use which is not
|
||||
available yet in the Client class as an easy-to-use method).
|
||||
|
||||
Args:
|
||||
data (``Object``):
|
||||
Parameters:
|
||||
data (``RawFunction``):
|
||||
The API Schema function filled with proper arguments.
|
||||
|
||||
retries (``int``):
|
||||
@@ -1058,8 +1058,11 @@ class Client(Methods, BaseClient):
|
||||
timeout (``float``):
|
||||
Timeout in seconds.
|
||||
|
||||
Returns:
|
||||
``RawType``: The raw type response generated by the query.
|
||||
|
||||
Raises:
|
||||
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
|
||||
RPCError: In case of a Telegram RPC error.
|
||||
"""
|
||||
if not self.is_started:
|
||||
raise ConnectionError("Client has not been started")
|
||||
@@ -1347,17 +1350,17 @@ class Client(Methods, BaseClient):
|
||||
:obj:`functions <pyrogram.api.functions>` (i.e: a Telegram API method you wish to use which is not
|
||||
available yet in the Client class as an easy-to-use method).
|
||||
|
||||
Args:
|
||||
Parameters:
|
||||
peer_id (``int`` | ``str``):
|
||||
The peer id you want to extract the InputPeer from.
|
||||
Can be a direct id (int), a username (str) or a phone number (str).
|
||||
|
||||
Returns:
|
||||
On success, the resolved peer id is returned in form of an InputPeer object.
|
||||
``InputPeer``: On success, the resolved peer id is returned in form of an InputPeer object.
|
||||
|
||||
Raises:
|
||||
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
|
||||
``KeyError`` in case the peer doesn't exist in the internal database.
|
||||
RPCError: In case of a Telegram RPC error.
|
||||
KeyError: In case the peer doesn't exist in the internal database.
|
||||
"""
|
||||
try:
|
||||
return self.peers_by_id[peer_id]
|
||||
@@ -1429,7 +1432,7 @@ class Client(Methods, BaseClient):
|
||||
:obj:`functions <pyrogram.api.functions>` (i.e: a Telegram API method you wish to use which is not
|
||||
available yet in the Client class as an easy-to-use method).
|
||||
|
||||
Args:
|
||||
Parameters:
|
||||
path (``str``):
|
||||
The path of the file you want to upload that exists on your local machine.
|
||||
|
||||
@@ -1449,7 +1452,7 @@ class Client(Methods, BaseClient):
|
||||
a chat_id and a message_id in order to edit a message with the updated progress.
|
||||
|
||||
Other Parameters:
|
||||
client (:obj:`Client <pyrogram.Client>`):
|
||||
client (:obj:`Client`):
|
||||
The Client itself, useful when you want to call other API methods inside the callback function.
|
||||
|
||||
current (``int``):
|
||||
@@ -1463,10 +1466,10 @@ class Client(Methods, BaseClient):
|
||||
You can either keep *\*args* or add every single extra argument in your function signature.
|
||||
|
||||
Returns:
|
||||
On success, the uploaded file is returned in form of an InputFile object.
|
||||
``InputFile``: On success, the uploaded file is returned in form of an InputFile object.
|
||||
|
||||
Raises:
|
||||
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
|
||||
RPCError: In case of a Telegram RPC error.
|
||||
"""
|
||||
part_size = 512 * 1024
|
||||
file_size = os.path.getsize(path)
|
||||
|
Reference in New Issue
Block a user