diff --git a/docs/source/resources/SmartPlugins.rst b/docs/source/resources/SmartPlugins.rst index ecb5dfdc..46c4e17a 100644 --- a/docs/source/resources/SmartPlugins.rst +++ b/docs/source/resources/SmartPlugins.rst @@ -5,15 +5,22 @@ Pyrogram embeds a **smart** (automatic) and lightweight plugin system that is me of large projects and to provide a way for creating pluggable components that can be **easily shared** across different Pyrogram applications with **minimal boilerplate code**. +.. tip:: + + Smart Plugins are completely optional and disabled by default. + Introduction ------------ Prior to the Smart Plugin system, pluggable handlers were already possible. For example, if you wanted to modularize your applications, you had to do something like this... -.. note:: This is an example application that replies in private chats with two messages: one containing the same - text message you sent and the other containing the reversed text message (e.g.: "pyrogram" -> "pyrogram" and - "margoryp"): +.. note:: + + This is an example application that replies in private chats with two messages: one containing the same + text message you sent and the other containing the reversed text message. + + Example: *"Pyrogram"* replies with *"Pyrogram"* and *"margoryP"* .. code-block:: text diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 3b4bd8d2..12bb85ca 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -31,7 +31,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès ` + :class:`Error ` 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") @@ -286,6 +287,9 @@ class Client(Methods, BaseClient): async def stop(self): """Use this method to manually stop the Client. Requires no parameters. + + Raises: + ``ConnectionError`` in case you try to stop an already stopped Client. """ if not self.is_started: raise ConnectionError("Client is already stopped") @@ -348,7 +352,7 @@ class Client(Methods, BaseClient): Pass a coroutine to run it until is complete. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ run = asyncio.get_event_loop().run_until_complete @@ -886,7 +890,7 @@ class Client(Methods, BaseClient): Args: data (``Object``): - The API Scheme function filled with proper arguments. + The API Schema function filled with proper arguments. retries (``int``): Number of retries. @@ -895,7 +899,7 @@ class Client(Methods, BaseClient): Timeout in seconds. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ if not self.is_started: raise ConnectionError("Client has not been started") @@ -1084,7 +1088,8 @@ class Client(Methods, BaseClient): On success, the resolved peer id is returned in form of an InputPeer object. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. + ``KeyError`` in case the peer doesn't exist in the internal database. """ if type(peer_id) is str: if peer_id in ("self", "me"): diff --git a/pyrogram/client/methods/bots/answer_callback_query.py b/pyrogram/client/methods/bots/answer_callback_query.py index 2636b131..6aaeafd8 100644 --- a/pyrogram/client/methods/bots/answer_callback_query.py +++ b/pyrogram/client/methods/bots/answer_callback_query.py @@ -50,6 +50,12 @@ class AnswerCallbackQuery(BaseClient): cache_time (``int``): The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. + + Returns: + True, on success. + + Raises: + :class:`Error ` in case of a Telegram RPC error. """ return await self.send( functions.messages.SetBotCallbackAnswer( diff --git a/pyrogram/client/methods/bots/get_inline_bot_results.py b/pyrogram/client/methods/bots/get_inline_bot_results.py index aa8995fa..5aa1ddda 100644 --- a/pyrogram/client/methods/bots/get_inline_bot_results.py +++ b/pyrogram/client/methods/bots/get_inline_bot_results.py @@ -54,8 +54,8 @@ class GetInlineBotResults(BaseClient): On Success, :obj:`BotResults ` is returned. Raises: - :class:`Error ` - ``TimeoutError``: If the bot fails to answer within 10 seconds + :class:`Error ` in case of a Telegram RPC error. + ``TimeoutError`` if the bot fails to answer within 10 seconds """ # TODO: Don't return the raw type diff --git a/pyrogram/client/methods/bots/request_callback_answer.py b/pyrogram/client/methods/bots/request_callback_answer.py index 8b3135b0..f22b2c4b 100644 --- a/pyrogram/client/methods/bots/request_callback_answer.py +++ b/pyrogram/client/methods/bots/request_callback_answer.py @@ -45,8 +45,8 @@ class RequestCallbackAnswer(BaseClient): or as an alert. Raises: - :class:`Error ` - ``TimeoutError``: If the bot fails to answer within 10 seconds + :class:`Error ` in case of a Telegram RPC error. + ``TimeoutError`` if the bot fails to answer within 10 seconds. """ return await self.send( functions.messages.GetBotCallbackAnswer( diff --git a/pyrogram/client/methods/bots/send_inline_bot_result.py b/pyrogram/client/methods/bots/send_inline_bot_result.py index 93d2d5cd..3b3d36aa 100644 --- a/pyrogram/client/methods/bots/send_inline_bot_result.py +++ b/pyrogram/client/methods/bots/send_inline_bot_result.py @@ -53,7 +53,7 @@ class SendInlineBotResult(BaseClient): On success, the sent Message is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ return await self.send( functions.messages.SendInlineBotResult( diff --git a/pyrogram/client/methods/chats/delete_chat_photo.py b/pyrogram/client/methods/chats/delete_chat_photo.py index aa29267d..b107aa3e 100644 --- a/pyrogram/client/methods/chats/delete_chat_photo.py +++ b/pyrogram/client/methods/chats/delete_chat_photo.py @@ -38,8 +38,8 @@ class DeleteChatPhoto(BaseClient): True on success. Raises: - :class:`Error ` - ``ValueError``: If a chat_id belongs to user. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id belongs to user. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py index 26febf1d..710679d5 100644 --- a/pyrogram/client/methods/chats/export_chat_invite_link.py +++ b/pyrogram/client/methods/chats/export_chat_invite_link.py @@ -35,7 +35,7 @@ class ExportChatInviteLink(BaseClient): On success, the exported invite link as string is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/get_chat.py b/pyrogram/client/methods/chats/get_chat.py index a88b2bfa..2b22fd67 100644 --- a/pyrogram/client/methods/chats/get_chat.py +++ b/pyrogram/client/methods/chats/get_chat.py @@ -33,7 +33,7 @@ class GetChat(BaseClient): On success, a :obj:`Chat ` object is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/get_chat_member.py b/pyrogram/client/methods/chats/get_chat_member.py index bd43808f..2943c8de 100644 --- a/pyrogram/client/methods/chats/get_chat_member.py +++ b/pyrogram/client/methods/chats/get_chat_member.py @@ -39,7 +39,7 @@ class GetChatMember(BaseClient): On success, a :obj:`ChatMember ` object is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ chat_id = await self.resolve_peer(chat_id) user_id = await self.resolve_peer(user_id) diff --git a/pyrogram/client/methods/chats/get_chat_members.py b/pyrogram/client/methods/chats/get_chat_members.py index aa1b0392..70f2c310 100644 --- a/pyrogram/client/methods/chats/get_chat_members.py +++ b/pyrogram/client/methods/chats/get_chat_members.py @@ -39,7 +39,7 @@ class GetChatMembers(BaseClient): """Use this method to get the members list of a chat. A chat can be either a basic group, a supergroup or a channel. - You must be admin to retrieve the members (also known as "subscribers") list of a channel. + You must be admin to retrieve the members list of a channel (also known as "subscribers"). Args: chat_id (``int`` | ``str``): @@ -51,7 +51,7 @@ class GetChatMembers(BaseClient): limit (``int``, *optional*): Limits the number of members to be retrieved. - Defaults to 200, which is also the maximum limit allowed per method call. + Defaults to 200, which is also the maximum server limit allowed per method call. query (``str``, *optional*): Query string to filter members based on their display names and usernames. @@ -68,9 +68,17 @@ class GetChatMembers(BaseClient): *"administrators"* - chat administrators only. Defaults to *"all"*. - .. [1] On supergroups and channels you can get up to 10,000 members for a single query string. + .. [1] Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members + on channels. .. [2] A query string is applicable only for *"all"*, *"kicked"* and *"restricted"* filters only. + + Returns: + On success, a :obj:`ChatMembers` object is returned. + + Raises: + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if you used an invalid filter or a chat_id that belongs to a user. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/get_chat_members_count.py b/pyrogram/client/methods/chats/get_chat_members_count.py index a8ce9780..f3344b96 100644 --- a/pyrogram/client/methods/chats/get_chat_members_count.py +++ b/pyrogram/client/methods/chats/get_chat_members_count.py @@ -32,8 +32,8 @@ class GetChatMembersCount(BaseClient): On success, an integer is returned. Raises: - :class:`Error ` - ``ValueError``: If a chat_id belongs to user. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id belongs to user. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/get_dialogs.py b/pyrogram/client/methods/chats/get_dialogs.py index 13d46787..5018dc1e 100644 --- a/pyrogram/client/methods/chats/get_dialogs.py +++ b/pyrogram/client/methods/chats/get_dialogs.py @@ -47,7 +47,7 @@ class GetDialogs(BaseClient): On success, a :obj:`Dialogs` object is returned. Raises: - :class:`Error` + :class:`Error ` in case of a Telegram RPC error. """ if pinned_only: diff --git a/pyrogram/client/methods/chats/join_chat.py b/pyrogram/client/methods/chats/join_chat.py index 75f8033f..6eb1a543 100644 --- a/pyrogram/client/methods/chats/join_chat.py +++ b/pyrogram/client/methods/chats/join_chat.py @@ -30,7 +30,7 @@ class JoinChat(BaseClient): channel/supergroup (in the format @username). Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ match = self.INVITE_LINK_RE.match(chat_id) diff --git a/pyrogram/client/methods/chats/kick_chat_member.py b/pyrogram/client/methods/chats/kick_chat_member.py index d63cd242..74a073bb 100644 --- a/pyrogram/client/methods/chats/kick_chat_member.py +++ b/pyrogram/client/methods/chats/kick_chat_member.py @@ -53,7 +53,7 @@ class KickChatMember(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ chat_peer = await self.resolve_peer(chat_id) user_peer = await self.resolve_peer(user_id) diff --git a/pyrogram/client/methods/chats/leave_chat.py b/pyrogram/client/methods/chats/leave_chat.py index 9d7dfcef..62af1781 100644 --- a/pyrogram/client/methods/chats/leave_chat.py +++ b/pyrogram/client/methods/chats/leave_chat.py @@ -33,7 +33,7 @@ class LeaveChat(BaseClient): Deletes the group chat dialog after leaving (for simple group chats, not supergroups). Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/pin_chat_message.py b/pyrogram/client/methods/chats/pin_chat_message.py index 495acc43..8df5dfde 100644 --- a/pyrogram/client/methods/chats/pin_chat_message.py +++ b/pyrogram/client/methods/chats/pin_chat_message.py @@ -41,8 +41,8 @@ class PinChatMessage(BaseClient): True on success. Raises: - :class:`Error ` - ``ValueError``: If a chat_id doesn't belong to a supergroup or a channel. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id doesn't belong to a supergroup or a channel. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/promote_chat_member.py b/pyrogram/client/methods/chats/promote_chat_member.py index 2afa5fe3..6703cf63 100644 --- a/pyrogram/client/methods/chats/promote_chat_member.py +++ b/pyrogram/client/methods/chats/promote_chat_member.py @@ -74,7 +74,7 @@ class PromoteChatMember(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ await self.send( functions.channels.EditAdmin( diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py index 14bd42f3..1828040a 100644 --- a/pyrogram/client/methods/chats/restrict_chat_member.py +++ b/pyrogram/client/methods/chats/restrict_chat_member.py @@ -64,7 +64,7 @@ class RestrictChatMember(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ send_messages = True send_media = True diff --git a/pyrogram/client/methods/chats/set_chat_description.py b/pyrogram/client/methods/chats/set_chat_description.py index 2a71b06e..33ed3d13 100644 --- a/pyrogram/client/methods/chats/set_chat_description.py +++ b/pyrogram/client/methods/chats/set_chat_description.py @@ -36,8 +36,8 @@ class SetChatDescription(BaseClient): True on success. Raises: - :class:`Error ` - ``ValueError``: If a chat_id doesn't belong to a supergroup or a channel. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id doesn't belong to a supergroup or a channel. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/set_chat_photo.py b/pyrogram/client/methods/chats/set_chat_photo.py index 53882323..dce78919 100644 --- a/pyrogram/client/methods/chats/set_chat_photo.py +++ b/pyrogram/client/methods/chats/set_chat_photo.py @@ -45,8 +45,8 @@ class SetChatPhoto(BaseClient): True on success. Raises: - :class:`Error ` - ``ValueError``: If a chat_id belongs to user. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id belongs to user. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/set_chat_title.py b/pyrogram/client/methods/chats/set_chat_title.py index 15f999e5..c3f507af 100644 --- a/pyrogram/client/methods/chats/set_chat_title.py +++ b/pyrogram/client/methods/chats/set_chat_title.py @@ -41,8 +41,8 @@ class SetChatTitle(BaseClient): True on success. Raises: - :class:`Error ` - ``ValueError``: If a chat_id belongs to user. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id belongs to user. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/unban_chat_member.py b/pyrogram/client/methods/chats/unban_chat_member.py index 87175c1f..27a10ce2 100644 --- a/pyrogram/client/methods/chats/unban_chat_member.py +++ b/pyrogram/client/methods/chats/unban_chat_member.py @@ -40,7 +40,7 @@ class UnbanChatMember(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ await self.send( functions.channels.EditBanned( diff --git a/pyrogram/client/methods/chats/unpin_chat_message.py b/pyrogram/client/methods/chats/unpin_chat_message.py index 101b7bff..baed8cd5 100644 --- a/pyrogram/client/methods/chats/unpin_chat_message.py +++ b/pyrogram/client/methods/chats/unpin_chat_message.py @@ -34,8 +34,8 @@ class UnpinChatMessage(BaseClient): True on success. Raises: - :class:`Error ` - ``ValueError``: If a chat_id doesn't belong to a supergroup or a channel. + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if a chat_id doesn't belong to a supergroup or a channel. """ peer = await self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/contacts/add_contacts.py b/pyrogram/client/methods/contacts/add_contacts.py index 75f4f8a8..e34dc160 100644 --- a/pyrogram/client/methods/contacts/add_contacts.py +++ b/pyrogram/client/methods/contacts/add_contacts.py @@ -32,7 +32,7 @@ class AddContacts(BaseClient): On success, the added contacts are returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ imported_contacts = await self.send( functions.contacts.ImportContacts( diff --git a/pyrogram/client/methods/contacts/delete_contacts.py b/pyrogram/client/methods/contacts/delete_contacts.py index ef133d8c..262af19c 100644 --- a/pyrogram/client/methods/contacts/delete_contacts.py +++ b/pyrogram/client/methods/contacts/delete_contacts.py @@ -34,7 +34,7 @@ class DeleteContacts(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ contacts = [] diff --git a/pyrogram/client/methods/contacts/get_contacts.py b/pyrogram/client/methods/contacts/get_contacts.py index b73a1f2c..2fff648a 100644 --- a/pyrogram/client/methods/contacts/get_contacts.py +++ b/pyrogram/client/methods/contacts/get_contacts.py @@ -36,7 +36,7 @@ class GetContacts(BaseClient): On success, the user's contacts are returned Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ while True: try: diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py index c4db5027..4ef19d35 100644 --- a/pyrogram/client/methods/messages/delete_messages.py +++ b/pyrogram/client/methods/messages/delete_messages.py @@ -53,7 +53,7 @@ class DeleteMessages(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ peer = await self.resolve_peer(chat_id) message_ids = list(message_ids) if not isinstance(message_ids, int) else [message_ids] diff --git a/pyrogram/client/methods/messages/edit_message_caption.py b/pyrogram/client/methods/messages/edit_message_caption.py index 38101182..5cc075b9 100644 --- a/pyrogram/client/methods/messages/edit_message_caption.py +++ b/pyrogram/client/methods/messages/edit_message_caption.py @@ -53,7 +53,7 @@ class EditMessageCaption(BaseClient): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index 7056aca2..6c512312 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -57,6 +57,12 @@ class EditMessageMedia(BaseClient): reply_markup (:obj:`InlineKeyboardMarkup`, *optional*): An InlineKeyboardMarkup object. + + Returns: + On success, the edited :obj:`Message ` is returned. + + Raises: + :class:`Error ` in case of a Telegram RPC error. """ style = self.html if media.parse_mode.lower() == "html" else self.markdown caption = media.caption diff --git a/pyrogram/client/methods/messages/edit_message_reply_markup.py b/pyrogram/client/methods/messages/edit_message_reply_markup.py index 440ee654..9a83d88a 100644 --- a/pyrogram/client/methods/messages/edit_message_reply_markup.py +++ b/pyrogram/client/methods/messages/edit_message_reply_markup.py @@ -44,7 +44,7 @@ class EditMessageReplyMarkup(BaseClient): :obj:`Message ` is returned, otherwise True is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send( diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py index edacefd2..fbae8d08 100644 --- a/pyrogram/client/methods/messages/edit_message_text.py +++ b/pyrogram/client/methods/messages/edit_message_text.py @@ -57,7 +57,7 @@ class EditMessageText(BaseClient): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/forward_messages.py b/pyrogram/client/methods/messages/forward_messages.py index 738a9203..f0626fbb 100644 --- a/pyrogram/client/methods/messages/forward_messages.py +++ b/pyrogram/client/methods/messages/forward_messages.py @@ -54,7 +54,7 @@ class ForwardMessages(BaseClient): is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ is_iterable = not isinstance(message_ids, int) message_ids = list(message_ids) if is_iterable else [message_ids] diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py index de041cca..bf012323 100644 --- a/pyrogram/client/methods/messages/get_history.py +++ b/pyrogram/client/methods/messages/get_history.py @@ -56,7 +56,7 @@ class GetHistory(BaseClient): On success, a :obj:`Messages ` object is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send( diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py index bb96f329..dae1df09 100644 --- a/pyrogram/client/methods/messages/get_messages.py +++ b/pyrogram/client/methods/messages/get_messages.py @@ -54,7 +54,7 @@ class GetMessages(BaseClient): :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ ids, ids_type = ( (message_ids, types.InputMessageID) if message_ids diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index f2adf708..5c696803 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -116,7 +116,7 @@ class SendAnimation(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index 25c5f38d..b7df78fa 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -117,7 +117,7 @@ class SendAudio(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/send_chat_action.py b/pyrogram/client/methods/messages/send_chat_action.py index ebcdbd85..ed12ce67 100644 --- a/pyrogram/client/methods/messages/send_chat_action.py +++ b/pyrogram/client/methods/messages/send_chat_action.py @@ -47,8 +47,8 @@ class SendChatAction(BaseClient): On success, True is returned. Raises: - :class:`Error ` - ``ValueError``: If the provided string is not a valid ChatAction + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if the provided string is not a valid ChatAction. """ # Resolve Enum type diff --git a/pyrogram/client/methods/messages/send_contact.py b/pyrogram/client/methods/messages/send_contact.py index ef9a0a75..67330dfd 100644 --- a/pyrogram/client/methods/messages/send_contact.py +++ b/pyrogram/client/methods/messages/send_contact.py @@ -64,7 +64,7 @@ class SendContact(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 992c548c..53e825f2 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -103,7 +103,7 @@ class SendDocument(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/send_location.py b/pyrogram/client/methods/messages/send_location.py index b795a8d5..565a7773 100644 --- a/pyrogram/client/methods/messages/send_location.py +++ b/pyrogram/client/methods/messages/send_location.py @@ -57,7 +57,7 @@ class SendLocation(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py index a92105cb..96e48c08 100644 --- a/pyrogram/client/methods/messages/send_message.py +++ b/pyrogram/client/methods/messages/send_message.py @@ -64,7 +64,7 @@ class SendMessage(BaseClient): On success, the sent :obj:`Message` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py index 859a8bf6..5edd89bf 100644 --- a/pyrogram/client/methods/messages/send_photo.py +++ b/pyrogram/client/methods/messages/send_photo.py @@ -102,7 +102,7 @@ class SendPhoto(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/send_sticker.py b/pyrogram/client/methods/messages/send_sticker.py index 481f47ab..411c634b 100644 --- a/pyrogram/client/methods/messages/send_sticker.py +++ b/pyrogram/client/methods/messages/send_sticker.py @@ -86,7 +86,7 @@ class SendSticker(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None diff --git a/pyrogram/client/methods/messages/send_venue.py b/pyrogram/client/methods/messages/send_venue.py index f54936be..4bdf0935 100644 --- a/pyrogram/client/methods/messages/send_venue.py +++ b/pyrogram/client/methods/messages/send_venue.py @@ -73,7 +73,7 @@ class SendVenue(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index 3f02ee6f..387b37fd 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -120,7 +120,7 @@ class SendVideo(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py index 93fdd8be..192ec3f4 100644 --- a/pyrogram/client/methods/messages/send_video_note.py +++ b/pyrogram/client/methods/messages/send_video_note.py @@ -101,7 +101,7 @@ class SendVideoNote(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py index 9fb8ad5e..ed5a1080 100644 --- a/pyrogram/client/methods/messages/send_voice.py +++ b/pyrogram/client/methods/messages/send_voice.py @@ -101,7 +101,7 @@ class SendVoice(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ file = None style = self.html if parse_mode.lower() == "html" else self.markdown diff --git a/pyrogram/client/methods/password/change_cloud_password.py b/pyrogram/client/methods/password/change_cloud_password.py index e066d8ba..0aa14c1f 100644 --- a/pyrogram/client/methods/password/change_cloud_password.py +++ b/pyrogram/client/methods/password/change_cloud_password.py @@ -41,7 +41,7 @@ class ChangeCloudPassword(BaseClient): True on success, False otherwise. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send(functions.account.GetPassword()) diff --git a/pyrogram/client/methods/password/enable_cloud_password.py b/pyrogram/client/methods/password/enable_cloud_password.py index 496430ad..7ba147b3 100644 --- a/pyrogram/client/methods/password/enable_cloud_password.py +++ b/pyrogram/client/methods/password/enable_cloud_password.py @@ -43,7 +43,7 @@ class EnableCloudPassword(BaseClient): True on success, False otherwise. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send(functions.account.GetPassword()) diff --git a/pyrogram/client/methods/password/remove_cloud_password.py b/pyrogram/client/methods/password/remove_cloud_password.py index 5392433f..dd8e8887 100644 --- a/pyrogram/client/methods/password/remove_cloud_password.py +++ b/pyrogram/client/methods/password/remove_cloud_password.py @@ -34,7 +34,7 @@ class RemoveCloudPassword(BaseClient): True on success, False otherwise. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send(functions.account.GetPassword()) diff --git a/pyrogram/client/methods/users/delete_user_profile_photos.py b/pyrogram/client/methods/users/delete_user_profile_photos.py index 1f403494..7ba40594 100644 --- a/pyrogram/client/methods/users/delete_user_profile_photos.py +++ b/pyrogram/client/methods/users/delete_user_profile_photos.py @@ -36,7 +36,7 @@ class DeleteUserProfilePhotos(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ id = id if isinstance(id, list) else [id] input_photos = [] diff --git a/pyrogram/client/methods/users/get_me.py b/pyrogram/client/methods/users/get_me.py index a8aac70f..d672bb08 100644 --- a/pyrogram/client/methods/users/get_me.py +++ b/pyrogram/client/methods/users/get_me.py @@ -28,7 +28,7 @@ class GetMe(BaseClient): Basic information about the user or bot in form of a :obj:`User` object Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ r = await self.send( functions.users.GetFullUser( diff --git a/pyrogram/client/methods/users/get_user_profile_photos.py b/pyrogram/client/methods/users/get_user_profile_photos.py index 1d711cf3..5e5c29e0 100644 --- a/pyrogram/client/methods/users/get_user_profile_photos.py +++ b/pyrogram/client/methods/users/get_user_profile_photos.py @@ -45,7 +45,7 @@ class GetUserProfilePhotos(BaseClient): On success, a :obj:`UserProfilePhotos` object is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ return utils.parse_profile_photos( await self.send( diff --git a/pyrogram/client/methods/users/get_users.py b/pyrogram/client/methods/users/get_users.py index 33c38900..decf933a 100644 --- a/pyrogram/client/methods/users/get_users.py +++ b/pyrogram/client/methods/users/get_users.py @@ -39,7 +39,7 @@ class GetUsers(BaseClient): *user_ids* was an integer, the single requested :obj:`User` is returned. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ is_iterable = not isinstance(user_ids, (int, str)) user_ids = list(user_ids) if is_iterable else [user_ids] diff --git a/pyrogram/client/methods/users/set_user_profile_photo.py b/pyrogram/client/methods/users/set_user_profile_photo.py index b107a968..b3ab66b1 100644 --- a/pyrogram/client/methods/users/set_user_profile_photo.py +++ b/pyrogram/client/methods/users/set_user_profile_photo.py @@ -36,7 +36,7 @@ class SetUserProfilePhoto(BaseClient): True on success. Raises: - :class:`Error ` + :class:`Error ` in case of a Telegram RPC error. """ return bool( diff --git a/pyrogram/client/methods/utilities/download_media.py b/pyrogram/client/methods/utilities/download_media.py index 91d865f6..5eebdab6 100644 --- a/pyrogram/client/methods/utilities/download_media.py +++ b/pyrogram/client/methods/utilities/download_media.py @@ -73,8 +73,8 @@ class DownloadMedia(BaseClient): On success, the absolute path of the downloaded file as string is returned, None otherwise. Raises: - :class:`Error ` - ``ValueError``: If the message doesn't contain any downloadable media + :class:`Error ` in case of a Telegram RPC error. + ``ValueError`` if the message doesn't contain any downloadable media """ error_message = "This message doesn't contain any downloadable media" diff --git a/pyrogram/client/types/bots/callback_query.py b/pyrogram/client/types/bots/callback_query.py index 083ab58a..843a9bb8 100644 --- a/pyrogram/client/types/bots/callback_query.py +++ b/pyrogram/client/types/bots/callback_query.py @@ -73,7 +73,9 @@ class CallbackQuery(Object): self.game_short_name = game_short_name # flags.3?string def answer(self, text: str = None, show_alert: bool = None, url: str = None, cache_time: int = 0): - """Use this method as a shortcut for: + """Bound method *answer* of :obj:`CallbackQuery `. + + Use this method as a shortcut for: .. code-block:: python diff --git a/pyrogram/client/types/bots/inline_keyboard_button.py b/pyrogram/client/types/bots/inline_keyboard_button.py index 001b105f..0f4779a9 100644 --- a/pyrogram/client/types/bots/inline_keyboard_button.py +++ b/pyrogram/client/types/bots/inline_keyboard_button.py @@ -50,16 +50,10 @@ class InlineKeyboardButton(Object): chat's input field. Can be empty, in which case only the bot's username will be inserted.This offers a quick way for the user to open your bot in inline mode in the same chat – good for selecting something from multiple options. - - callback_game (:obj:`CallbackGame `, *optional*): - Description of the game that will be launched when the user presses the button.NOTE: This type of button - must always be the first button in the first row. - - pay (``bool``, *optional*): - Specify True, to send a Pay button.NOTE: This type of button must always be the first button in the - first row. """ + # TODO: Add callback_game and pay fields + ID = 0xb0700019 def __init__( @@ -69,16 +63,16 @@ class InlineKeyboardButton(Object): url: str = None, switch_inline_query: str = None, switch_inline_query_current_chat: str = None, - callback_game=None, - pay: bool = None + # callback_game=None, + # pay: bool = None ): self.text = text self.url = url self.callback_data = callback_data self.switch_inline_query = switch_inline_query self.switch_inline_query_current_chat = switch_inline_query_current_chat - self.callback_game = callback_game - self.pay = pay + # self.callback_game = callback_game + # self.pay = pay @staticmethod def read(b, *args): diff --git a/pyrogram/client/types/bots/inline_keyboard_markup.py b/pyrogram/client/types/bots/inline_keyboard_markup.py index c21fabab..2a6993c4 100644 --- a/pyrogram/client/types/bots/inline_keyboard_markup.py +++ b/pyrogram/client/types/bots/inline_keyboard_markup.py @@ -27,7 +27,7 @@ class InlineKeyboardMarkup(Object): Args: inline_keyboard (List of List of :obj:`InlineKeyboardButton `): - Array of button rows, each represented by an Array of InlineKeyboardButton objects. + List of button rows, each represented by a List of InlineKeyboardButton objects. """ ID = 0xb0700020 diff --git a/pyrogram/client/types/bots/reply_keyboard_markup.py b/pyrogram/client/types/bots/reply_keyboard_markup.py index f6d42a2b..29fc1081 100644 --- a/pyrogram/client/types/bots/reply_keyboard_markup.py +++ b/pyrogram/client/types/bots/reply_keyboard_markup.py @@ -25,11 +25,11 @@ from . import KeyboardButton class ReplyKeyboardMarkup(Object): - """This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). + """This object represents a custom keyboard with reply options. Args: keyboard (List of List of :obj:`KeyboardButton `): - Array of button rows, each represented by an Array of KeyboardButton objects. + List of button rows, each represented by a List of KeyboardButton objects. resize_keyboard (``bool``, *optional*): Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if diff --git a/pyrogram/client/types/messages_and_media/animation.py b/pyrogram/client/types/messages_and_media/animation.py index 85d5a365..a8641e9e 100644 --- a/pyrogram/client/types/messages_and_media/animation.py +++ b/pyrogram/client/types/messages_and_media/animation.py @@ -48,7 +48,7 @@ class Animation(Object): File size. date (``int``, *optional*): - Date the Animation was sent in Unix time. + Date the animation was sent in Unix time. """ ID = 0xb0700025 diff --git a/pyrogram/client/types/messages_and_media/contact.py b/pyrogram/client/types/messages_and_media/contact.py index a7be558e..2569f03a 100644 --- a/pyrogram/client/types/messages_and_media/contact.py +++ b/pyrogram/client/types/messages_and_media/contact.py @@ -36,7 +36,7 @@ class Contact(Object): Contact's user identifier in Telegram. vcard (``str``, *optional*): - Additional data about the contact in the form of a vCard + Additional data about the contact in the form of a vCard. """ ID = 0xb0700011 diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index cd5b9cd8..3d2627be 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -164,20 +164,11 @@ class Message(Object): Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. - invoice (:obj:`Invoice `, *optional*): - Message is an invoice for a payment, information about the invoice. More about payments. - - successful_payment (:obj:`SuccessfulPayment `, *optional*): - Message is a service message about a successful payment, information about the payment. More about payments. - - connected_website (``str``, *optional*): - The domain name of the website on which the user has logged in. More about Telegram Login. - views (``int``, *optional*): Channel post views. via_bot (:obj:`User `): - Via bot. + The information of the bot that generated the message from an inline query of a user. outgoing (``bool``, *optional*): Whether the message is incoming or outgoing. @@ -199,6 +190,7 @@ class Message(Object): instructions to remove reply keyboard or to force a reply from the user. """ + # TODO: Add game missing field. Also invoice, successful_payment, connected_website ID = 0xb0700003 def __init__( @@ -243,9 +235,6 @@ class Message(Object): migrate_to_chat_id: int = None, migrate_from_chat_id: int = None, pinned_message=None, - invoice=None, - successful_payment=None, - connected_website=None, views: int = None, via_bot=None, outgoing: bool = None, @@ -293,9 +282,6 @@ class Message(Object): self.migrate_to_chat_id = migrate_to_chat_id # flags.33?int self.migrate_from_chat_id = migrate_from_chat_id # flags.34?int self.pinned_message = pinned_message # flags.35?Message - self.invoice = invoice # flags.36?Invoice - self.successful_payment = successful_payment # flags.37?SuccessfulPayment - self.connected_website = connected_website # flags.38?string self.views = views # flags.39?int self.via_bot = via_bot # flags.40?User self.outgoing = outgoing @@ -311,7 +297,9 @@ class Message(Object): disable_notification: bool = None, reply_to_message_id: int = None, reply_markup=None): - """Use this method as a shortcut for: + """Bound method *reply* of :obj:`Message `. + + Use as a shortcut for: .. code-block:: python @@ -379,7 +367,9 @@ class Message(Object): async def forward(self, chat_id: int or str, disable_notification: bool = None): - """Use this method as a shortcut for: + """Bound method *forward* of :obj:`Message `. + + Use as a shortcut for: .. code-block:: python @@ -418,7 +408,9 @@ class Message(Object): ) async def delete(self, revoke: bool = True): - """Use this method as a shortcut for: + """Bound method *delete* of :obj:`Message `. + + Use as a shortcut for: .. code-block:: python @@ -454,8 +446,9 @@ class Message(Object): return True async def click(self, x: int or str, y: int = None, quote: bool = None): - """Use this method to click a button attached to the message. - It's a shortcut for: + """Bound method *click* of :obj:`Message `. + + Use as a shortcut for clicking a button attached to the message instead of. - Clicking inline buttons: @@ -476,16 +469,17 @@ class Message(Object): text=message.reply_markup[i][j].text ) - This method can be used in three different ways: + Example: + This method can be used in three different ways: - 1. Pass one integer argument only (e.g.: ``.click(2)``, to click a button at index 2). - Buttons are counted left to right, starting from the top. + 1. Pass one integer argument only (e.g.: ``.click(2)``, to click a button at index 2). + Buttons are counted left to right, starting from the top. - 2. Pass two integer arguments (e.g.: ``.click(1, 0)``, to click a button at position (1, 0)). - The origin (0, 0) is top-left. + 2. Pass two integer arguments (e.g.: ``.click(1, 0)``, to click a button at position (1, 0)). + The origin (0, 0) is top-left. - 3. Pass one string argument only (e.g.: ``.click("Settings")``, to click a button by using its label). - Only the first matching button will be pressed. + 3. Pass one string argument only (e.g.: ``.click("Settings")``, to click a button by using its label). + Only the first matching button will be pressed. Args: x (``int`` | ``str``): @@ -567,7 +561,9 @@ class Message(Object): raise ValueError("The message doesn't contain any keyboard") async def download(self, file_name: str = "", block: bool = True): - """Use this method as a shortcut for: + """Bound method *download* of :obj:`Message `. + + Use as a shortcut for: .. code-block:: python diff --git a/pyrogram/client/types/messages_and_media/photo.py b/pyrogram/client/types/messages_and_media/photo.py index d9deed76..4037025b 100644 --- a/pyrogram/client/types/messages_and_media/photo.py +++ b/pyrogram/client/types/messages_and_media/photo.py @@ -20,7 +20,7 @@ from pyrogram.api.core import Object class Photo(Object): - """This object represents a Photo + """This object represents a Photo. Args: id (``str``): diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py index 2e7ac901..d2ff6731 100644 --- a/pyrogram/client/types/messages_and_media/sticker.py +++ b/pyrogram/client/types/messages_and_media/sticker.py @@ -52,11 +52,9 @@ class Sticker(Object): set_name (``str``, *optional*): Name of the sticker set to which the sticker belongs. - - mask_position (:obj:`MaskPosition `, *optional*): - For mask stickers, the position where the mask should be placed. """ + # TODO: Add mask position ID = 0xb0700017 def __init__( diff --git a/pyrogram/client/types/user_and_chats/__init__.py b/pyrogram/client/types/user_and_chats/__init__.py index f4742d83..0f814b92 100644 --- a/pyrogram/client/types/user_and_chats/__init__.py +++ b/pyrogram/client/types/user_and_chats/__init__.py @@ -22,5 +22,5 @@ from .chat_members import ChatMembers from .chat_photo import ChatPhoto from .dialog import Dialog from .dialogs import Dialogs -from .user_status import UserStatus from .user import User +from .user_status import UserStatus diff --git a/pyrogram/client/types/user_and_chats/dialog.py b/pyrogram/client/types/user_and_chats/dialog.py index fa5fb2b8..8107d363 100644 --- a/pyrogram/client/types/user_and_chats/dialog.py +++ b/pyrogram/client/types/user_and_chats/dialog.py @@ -20,7 +20,7 @@ from pyrogram.api.core import Object class Dialog(Object): - """This object represents a dialog + """This object represents a dialog. Args: chat (:obj:`Chat `): diff --git a/pyrogram/client/types/user_and_chats/user_status.py b/pyrogram/client/types/user_and_chats/user_status.py index b2974dbe..cc96df52 100644 --- a/pyrogram/client/types/user_and_chats/user_status.py +++ b/pyrogram/client/types/user_and_chats/user_status.py @@ -20,7 +20,7 @@ from pyrogram.api.core import Object class UserStatus(Object): - """This object represents a User status (Last Seen privacy) + """This object represents a User status (Last Seen privacy). .. note::