Skip to content

Commit 4512965

Browse files
committed
Revisit docstrings
1 parent 0c76774 commit 4512965

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+140
-125
lines changed

pyrogram/client/client.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class Client(Methods, BaseClient):
147147
plugins_dir (``str``, *optional*):
148148
Define a custom directory for your plugins. The plugins directory is the location in your
149149
filesystem where Pyrogram will automatically load your update handlers.
150-
Defaults to "./plugins". Set to None to completely disable plugins.
150+
Defaults to None (plugins disabled).
151151
"""
152152

153153
def __init__(self,
@@ -218,7 +218,8 @@ def start(self):
218218
Requires no parameters.
219219
220220
Raises:
221-
:class:`Error <pyrogram.Error>`
221+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
222+
``ConnectionError`` in case you try to start an already started Client.
222223
"""
223224
if self.is_started:
224225
raise ConnectionError("Client has already been started")
@@ -296,6 +297,9 @@ def start(self):
296297
def stop(self):
297298
"""Use this method to manually stop the Client.
298299
Requires no parameters.
300+
301+
Raises:
302+
``ConnectionError`` in case you try to stop an already stopped Client.
299303
"""
300304
if not self.is_started:
301305
raise ConnectionError("Client is already stopped")
@@ -355,7 +359,7 @@ def run(self):
355359
Requires no parameters.
356360
357361
Raises:
358-
:class:`Error <pyrogram.Error>`
362+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
359363
"""
360364
self.start()
361365
self.idle()
@@ -887,7 +891,7 @@ def send(self, data: Object, retries: int = Session.MAX_RETRIES, timeout: float
887891
888892
Args:
889893
data (``Object``):
890-
The API Scheme function filled with proper arguments.
894+
The API Schema function filled with proper arguments.
891895
892896
retries (``int``):
893897
Number of retries.
@@ -896,7 +900,7 @@ def send(self, data: Object, retries: int = Session.MAX_RETRIES, timeout: float
896900
Timeout in seconds.
897901
898902
Raises:
899-
:class:`Error <pyrogram.Error>`
903+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
900904
"""
901905
if not self.is_started:
902906
raise ConnectionError("Client has not been started")
@@ -1085,7 +1089,8 @@ def resolve_peer(self, peer_id: int or str):
10851089
On success, the resolved peer id is returned in form of an InputPeer object.
10861090
10871091
Raises:
1088-
:class:`Error <pyrogram.Error>`
1092+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
1093+
``KeyError`` in case the peer doesn't exist in the internal database.
10891094
"""
10901095
if type(peer_id) is str:
10911096
if peer_id in ("self", "me"):

pyrogram/client/methods/bots/answer_callback_query.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ def answer_callback_query(self,
5050
cache_time (``int``):
5151
The maximum amount of time in seconds that the result of the callback query may be cached client-side.
5252
Telegram apps will support caching starting in version 3.14. Defaults to 0.
53+
54+
Returns:
55+
True, on success.
56+
57+
Raises:
58+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
5359
"""
5460
return self.send(
5561
functions.messages.SetBotCallbackAnswer(

pyrogram/client/methods/bots/get_inline_bot_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def get_inline_bot_results(self,
5454
On Success, :obj:`BotResults <pyrogram.api.types.messages.BotResults>` is returned.
5555
5656
Raises:
57-
:class:`Error <pyrogram.Error>`
58-
``TimeoutError``: If the bot fails to answer within 10 seconds
57+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
58+
``TimeoutError`` if the bot fails to answer within 10 seconds
5959
"""
6060
# TODO: Don't return the raw type
6161

pyrogram/client/methods/bots/request_callback_answer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def request_callback_answer(self,
4545
or as an alert.
4646
4747
Raises:
48-
:class:`Error <pyrogram.Error>`
49-
``TimeoutError``: If the bot fails to answer within 10 seconds
48+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
49+
``TimeoutError`` if the bot fails to answer within 10 seconds.
5050
"""
5151
return self.send(
5252
functions.messages.GetBotCallbackAnswer(

pyrogram/client/methods/bots/send_inline_bot_result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def send_inline_bot_result(self,
5353
On success, the sent Message is returned.
5454
5555
Raises:
56-
:class:`Error <pyrogram.Error>`
56+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
5757
"""
5858
return self.send(
5959
functions.messages.SendInlineBotResult(

pyrogram/client/methods/chats/delete_chat_photo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def delete_chat_photo(self, chat_id: int or str):
3838
True on success.
3939
4040
Raises:
41-
:class:`Error <pyrogram.Error>`
42-
``ValueError``: If a chat_id belongs to user.
41+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
42+
``ValueError`` if a chat_id belongs to user.
4343
"""
4444
peer = self.resolve_peer(chat_id)
4545

pyrogram/client/methods/chats/export_chat_invite_link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def export_chat_invite_link(self, chat_id: int or str):
3535
On success, the exported invite link as string is returned.
3636
3737
Raises:
38-
:class:`Error <pyrogram.Error>`
38+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
3939
"""
4040
peer = self.resolve_peer(chat_id)
4141

pyrogram/client/methods/chats/get_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def get_chat(self, chat_id: int or str):
3333
On success, a :obj:`Chat <pyrogram.Chat>` object is returned.
3434
3535
Raises:
36-
:class:`Error <pyrogram.Error>`
36+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
3737
"""
3838
peer = self.resolve_peer(chat_id)
3939

pyrogram/client/methods/chats/get_chat_member.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_chat_member(self,
3939
On success, a :obj:`ChatMember <pyrogram.ChatMember>` object is returned.
4040
4141
Raises:
42-
:class:`Error <pyrogram.Error>`
42+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
4343
"""
4444
chat_id = self.resolve_peer(chat_id)
4545
user_id = self.resolve_peer(user_id)

pyrogram/client/methods/chats/get_chat_members.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_chat_members(self,
3939
"""Use this method to get the members list of a chat.
4040
4141
A chat can be either a basic group, a supergroup or a channel.
42-
You must be admin to retrieve the members (also known as "subscribers") list of a channel.
42+
You must be admin to retrieve the members list of a channel (also known as "subscribers").
4343
4444
Args:
4545
chat_id (``int`` | ``str``):
@@ -51,7 +51,7 @@ def get_chat_members(self,
5151
5252
limit (``int``, *optional*):
5353
Limits the number of members to be retrieved.
54-
Defaults to 200, which is also the maximum limit allowed per method call.
54+
Defaults to 200, which is also the maximum server limit allowed per method call.
5555
5656
query (``str``, *optional*):
5757
Query string to filter members based on their display names and usernames.
@@ -68,9 +68,17 @@ def get_chat_members(self,
6868
*"administrators"* - chat administrators only.
6969
Defaults to *"all"*.
7070
71-
.. [1] On supergroups and channels you can get up to 10,000 members for a single query string.
71+
.. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members
72+
on channels.
7273
7374
.. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only.
75+
76+
Returns:
77+
On success, a :obj:`ChatMembers` object is returned.
78+
79+
Raises:
80+
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
81+
``ValueError`` if you used an invalid filter or a chat_id that belongs to a user.
7482
"""
7583
peer = self.resolve_peer(chat_id)
7684

0 commit comments

Comments
 (0)