From eb2799ed453af96def044d3bbafa5256082bf29a Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Mar 2019 18:32:02 +0100 Subject: [PATCH 1/7] Update API schema to Layer 97 --- compiler/api/source/main_api.tl | 34 ++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/compiler/api/source/main_api.tl b/compiler/api/source/main_api.tl index eb7777c8..581427b5 100644 --- a/compiler/api/source/main_api.tl +++ b/compiler/api/source/main_api.tl @@ -315,7 +315,7 @@ updateContactsReset#7084a7be = Update; updateChannelAvailableMessages#70db6837 channel_id:int available_min_id:int = Update; updateDialogUnreadMark#e16459c3 flags:# unread:flags.0?true peer:DialogPeer = Update; updateUserPinnedMessage#4c43da18 user_id:int id:int = Update; -updateChatPinnedMessage#22893b26 chat_id:int id:int = Update; +updateChatPinnedMessage#e10db349 chat_id:int id:int version:int = Update; updateMessagePoll#aca1657b flags:# poll_id:long poll:flags.0?Poll results:PollResults = Update; updateChatDefaultBannedRights#54c01850 peer:Peer default_banned_rights:ChatBannedRights version:int = Update; @@ -411,11 +411,15 @@ inputPrivacyKeyStatusTimestamp#4f96cb18 = InputPrivacyKey; inputPrivacyKeyChatInvite#bdfb0426 = InputPrivacyKey; inputPrivacyKeyPhoneCall#fabadc5f = InputPrivacyKey; inputPrivacyKeyPhoneP2P#db9e70d2 = InputPrivacyKey; +inputPrivacyKeyForwards#a4dd4c08 = InputPrivacyKey; +inputPrivacyKeyProfilePhoto#5719bacc = InputPrivacyKey; privacyKeyStatusTimestamp#bc2eab30 = PrivacyKey; privacyKeyChatInvite#500e6dfa = PrivacyKey; privacyKeyPhoneCall#3d662b7b = PrivacyKey; privacyKeyPhoneP2P#39491cc8 = PrivacyKey; +privacyKeyForwards#69ec56a3 = PrivacyKey; +privacyKeyProfilePhoto#96151fed = PrivacyKey; inputPrivacyValueAllowContacts#d09e07b = InputPrivacyRule; inputPrivacyValueAllowAll#184b35ce = InputPrivacyRule; @@ -487,7 +491,7 @@ inputStickerSetEmpty#ffb62b95 = InputStickerSet; inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet; inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet; -stickerSet#5585a139 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string count:int hash:int = StickerSet; +stickerSet#6a90bcb7 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumb:flags.4?PhotoSize count:int hash:int = StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; @@ -595,7 +599,7 @@ messages.botResults#947ca848 flags:# gallery:flags.0?true query_id:long next_off exportedMessageLink#5dab1af4 link:string html:string = ExportedMessageLink; -messageFwdHeader#559ebe6d flags:# from_id:flags.0?int date:int channel_id:flags.1?int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int = MessageFwdHeader; +messageFwdHeader#ec338270 flags:# from_id:flags.0?int from_name:flags.5?string date:int channel_id:flags.1?int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int = MessageFwdHeader; auth.codeTypeSms#72a3158c = auth.CodeType; auth.codeTypeCall#741cd3e3 = auth.CodeType; @@ -985,6 +989,17 @@ codeSettings#302f59f3 flags:# allow_flashcall:flags.0?true current_number:flags. wallPaperSettings#a12f40b8 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int intensity:flags.3?int = WallPaperSettings; +autoDownloadSettings#d246fd47 flags:# disabled:flags.0?true video_preload_large:flags.1?true audio_preload_next:flags.2?true phonecalls_less_data:flags.3?true photo_size_max:int video_size_max:int file_size_max:int = AutoDownloadSettings; + +account.autoDownloadSettings#63cacf26 low:AutoDownloadSettings medium:AutoDownloadSettings high:AutoDownloadSettings = account.AutoDownloadSettings; + +emojiKeyword#d5b3b9f9 keyword:string emoticons:Vector = EmojiKeyword; +emojiKeywordDeleted#236df622 keyword:string emoticons:Vector = EmojiKeyword; + +emojiKeywordsDifference#5cc761bd lang_code:string from_version:int version:int keywords:Vector = EmojiKeywordsDifference; + +emojiURL#a575739d url:string = EmojiURL; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1064,6 +1079,8 @@ account.uploadWallPaper#dd853661 file:InputFile mime_type:string settings:WallPa account.saveWallPaper#6c5a5b37 wallpaper:InputWallPaper unsave:Bool settings:WallPaperSettings = Bool; account.installWallPaper#feed5769 wallpaper:InputWallPaper settings:WallPaperSettings = Bool; account.resetWallPapers#bb3b9804 = Bool; +account.getAutoDownloadSettings#56da0b3f = account.AutoDownloadSettings; +account.saveAutoDownloadSettings#76f36233 flags:# low:flags.0?true high:flags.1?true settings:AutoDownloadSettings = Bool; users.getUsers#d91a548 id:Vector = Vector; users.getFullUser#ca30a5b1 id:InputUser = UserFull; @@ -1092,7 +1109,7 @@ messages.getDialogs#b098aee6 flags:# exclude_pinned:flags.0?true offset_date:int messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; messages.search#8614ef68 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; -messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true peer:InputPeer max_id:int = messages.AffectedHistory; +messages.deleteHistory#1c015b09 flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int = messages.AffectedHistory; messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector = messages.AffectedMessages; messages.receivedMessages#5a954c0 max_id:int = Vector; messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool; @@ -1190,9 +1207,12 @@ messages.updatePinnedMessage#d2aaf7ec flags:# silent:flags.0?true peer:InputPeer messages.sendVote#10ea6184 peer:InputPeer msg_id:int options:Vector = Updates; messages.getPollResults#73bb643b peer:InputPeer msg_id:int = Updates; messages.getOnlines#6e2be050 peer:InputPeer = ChatOnlines; -messages.getStatsURL#83f6c0cd peer:InputPeer = StatsURL; +messages.getStatsURL#812c2ae6 flags:# dark:flags.0?true peer:InputPeer params:string = StatsURL; messages.editChatAbout#def60797 peer:InputPeer about:string = Bool; messages.editChatDefaultBannedRights#a5866b41 peer:InputPeer banned_rights:ChatBannedRights = Updates; +messages.getEmojiKeywords#35a0e062 lang_code:string = EmojiKeywordsDifference; +messages.getEmojiKeywordsDifference#1508b6af lang_code:string from_version:int = EmojiKeywordsDifference; +messages.getEmojiURL#d5b10c26 lang_code:string = EmojiURL; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1283,7 +1303,7 @@ phone.acceptCall#3bd2b4a0 peer:InputPhoneCall g_b:bytes protocol:PhoneCallProtoc phone.confirmCall#2efe1722 peer:InputPhoneCall g_a:bytes key_fingerprint:long protocol:PhoneCallProtocol = phone.PhoneCall; phone.receivedCall#17d54f61 peer:InputPhoneCall = Bool; phone.discardCall#78d413a6 peer:InputPhoneCall duration:int reason:PhoneCallDiscardReason connection_id:long = Updates; -phone.setCallRating#1c536a34 peer:InputPhoneCall rating:int comment:string = Updates; +phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhoneCall rating:int comment:string = Updates; phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool; langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference; @@ -1292,4 +1312,4 @@ langpack.getDifference#cd984aa5 lang_pack:string lang_code:string from_version:i langpack.getLanguages#42c6978f lang_pack:string = Vector; langpack.getLanguage#6a596502 lang_pack:string lang_code:string = LangPackLanguage; -// LAYER 95 +// LAYER 97 From ce0173e7cd5920ec080514e609606b1d1aa28712 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Mar 2019 18:51:04 +0100 Subject: [PATCH 2/7] Add support for hidden users in forwarded messages --- .../types/messages_and_media/message.py | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 08e20975..04f200a2 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -79,6 +79,9 @@ class Message(PyrogramType, Update): forward_from (:obj:`User `, *optional*): For forwarded messages, sender of the original message. + forward_from_name (``str``, *optional*): + For messages forwarded from users who have hidden their accounts, name of the user. + forward_from_chat (:obj:`Chat `, *optional*): For messages forwarded from channels, information about the original channel. @@ -264,12 +267,12 @@ class Message(PyrogramType, Update): # TODO: Add game missing field. Also invoice, successful_payment, connected_website __slots__ = [ - "message_id", "date", "chat", "from_user", "forward_from", "forward_from_chat", "forward_from_message_id", - "forward_signature", "forward_date", "reply_to_message", "mentioned", "empty", "service", "media", "edit_date", - "media_group_id", "author_signature", "text", "entities", "caption_entities", "audio", "document", "photo", - "sticker", "animation", "game", "video", "voice", "video_note", "caption", "contact", "location", "venue", - "web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title", "new_chat_photo", - "delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created", + "message_id", "date", "chat", "from_user", "forward_from", "forward_from_name", "forward_from_chat", + "forward_from_message_id", "forward_signature", "forward_date", "reply_to_message", "mentioned", "empty", + "service", "media", "edit_date", "media_group_id", "author_signature", "text", "entities", "caption_entities", + "audio", "document", "photo", "sticker", "animation", "game", "video", "voice", "video_note", "caption", + "contact", "location", "venue", "web_page", "poll", "new_chat_members", "left_chat_member", "new_chat_title", + "new_chat_photo", "delete_chat_photo", "group_chat_created", "supergroup_chat_created", "channel_chat_created", "migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "game_high_score", "views", "via_bot", "outgoing", "matches", "command", "reply_markup" ] @@ -283,6 +286,7 @@ class Message(PyrogramType, Update): chat: Chat = None, from_user: User = None, forward_from: User = None, + forward_from_name: str = None, forward_from_chat: Chat = None, forward_from_message_id: int = None, forward_signature: str = None, @@ -344,6 +348,7 @@ class Message(PyrogramType, Update): self.chat = chat self.from_user = from_user self.forward_from = forward_from + self.forward_from_name = forward_from_name self.forward_from_chat = forward_from_chat self.forward_from_message_id = forward_from_message_id self.forward_signature = forward_signature @@ -482,18 +487,21 @@ class Message(PyrogramType, Update): entities = list(filter(lambda x: x is not None, entities)) forward_from = None + forward_from_name = None forward_from_chat = None forward_from_message_id = None forward_signature = None forward_date = None - forward_header = message.fwd_from + forward_header = message.fwd_from # type: types.MessageFwdHeader if forward_header: forward_date = forward_header.date if forward_header.from_id: forward_from = User._parse(client, users[forward_header.from_id]) + elif forward_header.from_name: + forward_from_name = forward_header.from_name else: forward_from_chat = Chat._parse_channel_chat(client, chats[forward_header.channel_id]) forward_from_message_id = forward_header.channel_post @@ -599,6 +607,7 @@ class Message(PyrogramType, Update): caption_entities=entities or None if media is not None else None, author_signature=message.post_author, forward_from=forward_from, + forward_from_name=forward_from_name, forward_from_chat=forward_from_chat, forward_from_message_id=forward_from_message_id, forward_signature=forward_signature, From 78686d39fa1e036b8758069a45a6c31d580156e4 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 24 Mar 2019 18:59:56 +0100 Subject: [PATCH 3/7] Update docs --- README.rst | 6 +++--- docs/source/index.rst | 4 ++-- docs/source/start/Setup.rst | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 2bb0725b..dfb03abc 100644 --- a/README.rst +++ b/README.rst @@ -32,7 +32,7 @@ Features - **Fast**: Crypto parts are boosted up by TgCrypto_, a high-performance library written in pure C. - **Documented**: Pyrogram API methods, types and public interfaces are well documented. - **Type-hinted**: Exposed Pyrogram types and method parameters are all type-hinted. -- **Updated**, to the latest Telegram API version, currently Layer 95 on top of `MTProto 2.0`_. +- **Updated**, to the latest Telegram API version, currently Layer 97 on top of `MTProto 2.0`_. - **Pluggable**: The Smart Plugin system allows to write components with minimal boilerplate code. - **Comprehensive**: Execute any advanced action an official client is able to do, and even more. @@ -107,7 +107,7 @@ Copyright & License
- Schema Layer @@ -122,7 +122,7 @@ Copyright & License .. |description| replace:: **Telegram MTProto API Framework for Python** -.. |schema| image:: https://img.shields.io/badge/schema-layer%2095-eda738.svg?longCache=true&colorA=262b30 +.. |schema| image:: https://img.shields.io/badge/schema-layer%2097-eda738.svg?longCache=true&colorA=262b30 :target: compiler/api/source/main_api.tl :alt: Schema Layer diff --git a/docs/source/index.rst b/docs/source/index.rst index c3b082db..bd62547e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -26,7 +26,7 @@ Welcome to Pyrogram
- Schema Layer @@ -67,7 +67,7 @@ Features - **Fast**: Crypto parts are boosted up by TgCrypto_, a high-performance library written in pure C. - **Documented**: Pyrogram API methods, types and public interfaces are well documented. - **Type-hinted**: Exposed Pyrogram types and method parameters are all type-hinted. -- **Updated**, to the latest Telegram API version, currently Layer 95 on top of `MTProto 2.0`_. +- **Updated**, to the latest Telegram API version, currently Layer 97 on top of `MTProto 2.0`_. - **Pluggable**: The Smart Plugin system allows to write components with minimal boilerplate code. - **Comprehensive**: Execute any advanced action an official client is able to do, and even more. diff --git a/docs/source/start/Setup.rst b/docs/source/start/Setup.rst index 26d9d1c6..e004aaf8 100644 --- a/docs/source/start/Setup.rst +++ b/docs/source/start/Setup.rst @@ -97,7 +97,7 @@ BotFather_. Bot tokens replace the Users' phone numbers only — you still need `configure a Telegram API key <#configuration>`_ with Pyrogram, even when using Bots. The authorization process is automatically managed. All you need to do is choose a ``session_name`` (can be anything, -but is usually your bot username) and pass your bot token using the ``bot_token`` parameter. +usually your bot username) and pass your bot token using the ``bot_token`` parameter. The session file will be named after the session name, which will be ``pyrogrambot.session`` for the example below. .. code-block:: python From 066633ce457949b649be44fe56529b416f39669a Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Mar 2019 09:45:37 +0100 Subject: [PATCH 4/7] Move dispatcher.py inside ext folder --- pyrogram/client/dispatcher/__init__.py | 19 ------------------- pyrogram/client/ext/__init__.py | 1 + .../client/{dispatcher => ext}/dispatcher.py | 1 - 3 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 pyrogram/client/dispatcher/__init__.py rename pyrogram/client/{dispatcher => ext}/dispatcher.py (99%) diff --git a/pyrogram/client/dispatcher/__init__.py b/pyrogram/client/dispatcher/__init__.py deleted file mode 100644 index e2e67b70..00000000 --- a/pyrogram/client/dispatcher/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2019 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from .dispatcher import Dispatcher diff --git a/pyrogram/client/ext/__init__.py b/pyrogram/client/ext/__init__.py index ce80958a..18c28ac3 100644 --- a/pyrogram/client/ext/__init__.py +++ b/pyrogram/client/ext/__init__.py @@ -18,6 +18,7 @@ from .base_client import BaseClient from .chat_action import ChatAction +from .dispatcher import Dispatcher from .emoji import Emoji from .parse_mode import ParseMode from .syncer import Syncer diff --git a/pyrogram/client/dispatcher/dispatcher.py b/pyrogram/client/ext/dispatcher.py similarity index 99% rename from pyrogram/client/dispatcher/dispatcher.py rename to pyrogram/client/ext/dispatcher.py index 43f80ebb..7552b034 100644 --- a/pyrogram/client/dispatcher/dispatcher.py +++ b/pyrogram/client/ext/dispatcher.py @@ -24,7 +24,6 @@ from threading import Thread import pyrogram from pyrogram.api import types -from ..ext import utils from ..handlers import ( CallbackQueryHandler, MessageHandler, DeletedMessagesHandler, UserStatusHandler, RawUpdateHandler, InlineQueryHandler From b5c6db6db01b016ba772874c9adab90556e71643 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Mar 2019 11:10:46 +0100 Subject: [PATCH 5/7] Refactor project and move errors namespace out from pyrogram.api --- compiler/api/compiler.py | 2 +- compiler/error/compiler.py | 4 +- compiler/error/template/class.txt | 6 +- compiler/error/template/sub_class.txt | 2 +- docs/source/errors/BadRequest.rst | 5 +- docs/source/errors/Flood.rst | 5 +- docs/source/errors/Forbidden.rst | 5 +- docs/source/errors/InternalServerError.rst | 5 +- docs/source/errors/NotAcceptable.rst | 5 +- docs/source/errors/SeeOther.rst | 5 +- docs/source/errors/Unauthorized.rst | 5 +- docs/source/errors/UnknownError.rst | 5 +- .../pyrogram/{Error.rst => RPCError.rst} | 7 +-- docs/source/pyrogram/index.rst | 2 +- pyrogram/__init__.py | 37 ++++-------- pyrogram/api/core/object.py | 9 --- pyrogram/client/__init__.py | 10 ++-- pyrogram/client/client.py | 15 +++-- pyrogram/client/handlers/__init__.py | 5 ++ .../methods/bots/answer_callback_query.py | 2 +- .../methods/bots/get_game_high_scores.py | 2 +- .../methods/bots/get_inline_bot_results.py | 4 +- .../methods/bots/request_callback_answer.py | 2 +- pyrogram/client/methods/bots/send_game.py | 2 +- .../methods/bots/send_inline_bot_result.py | 2 +- .../client/methods/bots/set_game_score.py | 2 +- .../client/methods/chats/delete_chat_photo.py | 2 +- .../methods/chats/export_chat_invite_link.py | 2 +- pyrogram/client/methods/chats/get_chat.py | 2 +- .../client/methods/chats/get_chat_member.py | 7 ++- .../client/methods/chats/get_chat_members.py | 2 +- .../methods/chats/get_chat_members_count.py | 2 +- .../client/methods/chats/get_chat_preview.py | 2 +- pyrogram/client/methods/chats/get_dialogs.py | 4 +- .../client/methods/chats/iter_chat_members.py | 2 +- pyrogram/client/methods/chats/iter_dialogs.py | 2 +- pyrogram/client/methods/chats/join_chat.py | 2 +- .../client/methods/chats/kick_chat_member.py | 2 +- pyrogram/client/methods/chats/leave_chat.py | 2 +- .../client/methods/chats/pin_chat_message.py | 2 +- .../methods/chats/promote_chat_member.py | 2 +- .../client/methods/chats/restrict_chat.py | 2 +- .../methods/chats/restrict_chat_member.py | 2 +- .../methods/chats/set_chat_description.py | 2 +- .../client/methods/chats/set_chat_photo.py | 2 +- .../client/methods/chats/set_chat_title.py | 2 +- .../client/methods/chats/unban_chat_member.py | 2 +- .../methods/chats/unpin_chat_message.py | 2 +- .../methods/chats/update_chat_username.py | 2 +- .../client/methods/contacts/add_contacts.py | 2 +- .../methods/contacts/delete_contacts.py | 4 +- .../client/methods/contacts/get_contacts.py | 4 +- .../client/methods/messages/close_poll.py | 2 +- .../methods/messages/delete_messages.py | 2 +- .../client/methods/messages/download_media.py | 2 +- .../methods/messages/edit_message_caption.py | 2 +- .../methods/messages/edit_message_media.py | 4 +- .../messages/edit_message_reply_markup.py | 2 +- .../methods/messages/edit_message_text.py | 2 +- .../methods/messages/forward_messages.py | 2 +- .../client/methods/messages/get_history.py | 4 +- .../client/methods/messages/get_messages.py | 4 +- .../client/methods/messages/iter_history.py | 2 +- .../client/methods/messages/retract_vote.py | 2 +- .../client/methods/messages/send_animation.py | 4 +- .../client/methods/messages/send_audio.py | 4 +- .../methods/messages/send_cached_media.py | 4 +- .../methods/messages/send_chat_action.py | 2 +- .../client/methods/messages/send_contact.py | 2 +- .../client/methods/messages/send_document.py | 4 +- .../client/methods/messages/send_location.py | 2 +- .../methods/messages/send_media_group.py | 4 +- .../client/methods/messages/send_message.py | 2 +- .../client/methods/messages/send_photo.py | 4 +- pyrogram/client/methods/messages/send_poll.py | 2 +- .../client/methods/messages/send_sticker.py | 4 +- .../client/methods/messages/send_venue.py | 2 +- .../client/methods/messages/send_video.py | 4 +- .../methods/messages/send_video_note.py | 4 +- .../client/methods/messages/send_voice.py | 4 +- pyrogram/client/methods/messages/vote_poll.py | 2 +- .../methods/password/change_cloud_password.py | 2 +- .../methods/password/enable_cloud_password.py | 2 +- .../methods/password/remove_cloud_password.py | 2 +- .../users/delete_user_profile_photos.py | 2 +- pyrogram/client/methods/users/get_me.py | 2 +- .../methods/users/get_user_profile_photos.py | 2 +- pyrogram/client/methods/users/get_users.py | 2 +- .../methods/users/set_user_profile_photo.py | 2 +- .../client/methods/users/update_username.py | 2 +- pyrogram/client/types/__init__.py | 32 +++-------- pyrogram/client/types/bots/__init__.py | 5 ++ pyrogram/client/types/inline_mode/__init__.py | 4 ++ .../todo/inline_query_result_cached_audio.py | 2 +- pyrogram/client/types/input_media/__init__.py | 5 ++ .../types/input_message_content/__init__.py | 4 ++ .../types/messages_and_media/__init__.py | 5 ++ .../types/messages_and_media/message.py | 56 +++++++++---------- .../types/messages_and_media/messages.py | 2 +- .../types/messages_and_media/sticker.py | 2 +- .../client/types/user_and_chats/__init__.py | 5 ++ pyrogram/{api => }/errors/__init__.py | 2 +- .../errors/error.py => errors/rpc_error.py} | 12 ++-- pyrogram/session/session.py | 10 ++-- 104 files changed, 223 insertions(+), 243 deletions(-) rename docs/source/pyrogram/{Error.rst => RPCError.rst} (77%) rename pyrogram/{api => }/errors/__init__.py (95%) rename pyrogram/{api/errors/error.py => errors/rpc_error.py} (88%) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index 122ce843..6be16ba5 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -335,7 +335,7 @@ def start(): docstring_args = "Attributes:\n ID: ``{}``\n\n ".format(c.id) + docstring_args if c.section == "functions": - docstring_args += "\n\n Raises:\n :obj:`Error `" + docstring_args += "\n\n Raises:\n :obj:`RPCError `" docstring_args += "\n\n Returns:\n " + get_docstring_arg_type(c.return_type) else: references = get_references(".".join(filter(None, [c.namespace, c.name]))) diff --git a/compiler/error/compiler.py b/compiler/error/compiler.py index 751db1bc..996c4981 100644 --- a/compiler/error/compiler.py +++ b/compiler/error/compiler.py @@ -22,7 +22,7 @@ import re import shutil HOME = "compiler/error" -DEST = "pyrogram/api/errors/exceptions" +DEST = "pyrogram/errors/exceptions" NOTICE_PATH = "NOTICE" @@ -134,7 +134,7 @@ def start(): if "__main__" == __name__: HOME = "." - DEST = "../../pyrogram/api/errors/exceptions" + DEST = "../../pyrogram/errors/exceptions" NOTICE_PATH = "../../NOTICE" start() diff --git a/compiler/error/template/class.txt b/compiler/error/template/class.txt index e520d80c..718472b1 100644 --- a/compiler/error/template/class.txt +++ b/compiler/error/template/class.txt @@ -1,12 +1,12 @@ {notice} -from ..error import Error +from ..rpc_error import RPCError -class {super_class}(Error): +class {super_class}(RPCError): {docstring} CODE = {code} - """``int``: Error Code""" + """``int``: RPC Error Code""" NAME = __doc__ diff --git a/compiler/error/template/sub_class.txt b/compiler/error/template/sub_class.txt index e13e4cf2..c8551838 100644 --- a/compiler/error/template/sub_class.txt +++ b/compiler/error/template/sub_class.txt @@ -1,7 +1,7 @@ class {sub_class}({super_class}): {docstring} ID = {id} - """``str``: Error ID""" + """``str``: RPC Error ID""" MESSAGE = __doc__ diff --git a/docs/source/errors/BadRequest.rst b/docs/source/errors/BadRequest.rst index c51a7d54..2d56434c 100644 --- a/docs/source/errors/BadRequest.rst +++ b/docs/source/errors/BadRequest.rst @@ -1,8 +1,7 @@ 400 - Bad Request ================= -.. module:: pyrogram.api.errors.BadRequest +.. module:: pyrogram.errors.BadRequest -.. automodule:: pyrogram.api.errors.exceptions.bad_request_400 +.. automodule:: pyrogram.errors.exceptions.bad_request_400 :members: - :show-inheritance: diff --git a/docs/source/errors/Flood.rst b/docs/source/errors/Flood.rst index 72f819ea..55098cbb 100644 --- a/docs/source/errors/Flood.rst +++ b/docs/source/errors/Flood.rst @@ -1,8 +1,7 @@ 420 - Flood =========== -.. module:: pyrogram.api.errors.Flood +.. module:: pyrogram.errors.Flood -.. automodule:: pyrogram.api.errors.exceptions.flood_420 +.. automodule:: pyrogram.errors.exceptions.flood_420 :members: - :show-inheritance: diff --git a/docs/source/errors/Forbidden.rst b/docs/source/errors/Forbidden.rst index aaaceaff..cd794979 100644 --- a/docs/source/errors/Forbidden.rst +++ b/docs/source/errors/Forbidden.rst @@ -1,8 +1,7 @@ 403 - Forbidden =============== -.. module:: pyrogram.api.errors.Forbidden +.. module:: pyrogram.errors.Forbidden -.. automodule:: pyrogram.api.errors.exceptions.forbidden_403 +.. automodule:: pyrogram.errors.exceptions.forbidden_403 :members: - :show-inheritance: diff --git a/docs/source/errors/InternalServerError.rst b/docs/source/errors/InternalServerError.rst index 5e506fc9..7f78d519 100644 --- a/docs/source/errors/InternalServerError.rst +++ b/docs/source/errors/InternalServerError.rst @@ -1,8 +1,7 @@ 500 - Internal Server Error =========================== -.. module:: pyrogram.api.errors.InternalServerError +.. module:: pyrogram.errors.InternalServerError -.. automodule:: pyrogram.api.errors.exceptions.internal_server_error_500 +.. automodule:: pyrogram.errors.exceptions.internal_server_error_500 :members: - :show-inheritance: diff --git a/docs/source/errors/NotAcceptable.rst b/docs/source/errors/NotAcceptable.rst index e9301396..5a8365fc 100644 --- a/docs/source/errors/NotAcceptable.rst +++ b/docs/source/errors/NotAcceptable.rst @@ -1,8 +1,7 @@ 406 - Not Acceptable ==================== -.. module:: pyrogram.api.errors.NotAcceptable +.. module:: pyrogram.errors.NotAcceptable -.. automodule:: pyrogram.api.errors.exceptions.not_acceptable_406 +.. automodule:: pyrogram.errors.exceptions.not_acceptable_406 :members: - :show-inheritance: diff --git a/docs/source/errors/SeeOther.rst b/docs/source/errors/SeeOther.rst index a916e779..f90902d0 100644 --- a/docs/source/errors/SeeOther.rst +++ b/docs/source/errors/SeeOther.rst @@ -1,8 +1,7 @@ 303 - See Other =============== -.. module:: pyrogram.api.errors.SeeOther +.. module:: pyrogram.errors.SeeOther -.. automodule:: pyrogram.api.errors.exceptions.see_other_303 +.. automodule:: pyrogram.errors.exceptions.see_other_303 :members: - :show-inheritance: diff --git a/docs/source/errors/Unauthorized.rst b/docs/source/errors/Unauthorized.rst index 6de3ff67..d47ed3fb 100644 --- a/docs/source/errors/Unauthorized.rst +++ b/docs/source/errors/Unauthorized.rst @@ -1,8 +1,7 @@ 401 - Unauthorized ================== -.. module:: pyrogram.api.errors.Unauthorized +.. module:: pyrogram.errors.Unauthorized -.. automodule:: pyrogram.api.errors.exceptions.unauthorized_401 +.. automodule:: pyrogram.errors.exceptions.unauthorized_401 :members: - :show-inheritance: diff --git a/docs/source/errors/UnknownError.rst b/docs/source/errors/UnknownError.rst index 767f19c3..21495957 100644 --- a/docs/source/errors/UnknownError.rst +++ b/docs/source/errors/UnknownError.rst @@ -1,8 +1,7 @@ 520 - Unknown Error =================== -.. module:: pyrogram.api.errors.UnknownError +.. module:: pyrogram.errors.UnknownError -.. autoexception:: pyrogram.api.errors.error.UnknownError +.. autoexception:: pyrogram.errors.rpc_error.UnknownError :members: - :show-inheritance: diff --git a/docs/source/pyrogram/Error.rst b/docs/source/pyrogram/RPCError.rst similarity index 77% rename from docs/source/pyrogram/Error.rst rename to docs/source/pyrogram/RPCError.rst index 2ec1159d..a47c9b9c 100644 --- a/docs/source/pyrogram/Error.rst +++ b/docs/source/pyrogram/RPCError.rst @@ -1,9 +1,8 @@ -Error -===== +RPCError +======== -.. autoexception:: pyrogram.Error +.. autoexception:: pyrogram.RPCError :members: - :show-inheritance: .. toctree:: ../errors/SeeOther diff --git a/docs/source/pyrogram/index.rst b/docs/source/pyrogram/index.rst index 20e7c918..286b5db1 100644 --- a/docs/source/pyrogram/index.rst +++ b/docs/source/pyrogram/index.rst @@ -15,6 +15,6 @@ after the well established `Telegram Bot API`_ methods, thus offering a familiar Filters ChatAction ParseMode - Error + RPCError .. _Telegram Bot API: https://core.telegram.org/bots/api#available-methods diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 4b155c65..bbb6557b 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -18,34 +18,19 @@ import sys +__version__ = "0.12.0.develop" +__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)" +__copyright__ = "Copyright (C) 2017-2019 Dan Tès ".replace( + "\xe8", "e" if sys.getfilesystemencoding() != "utf-8" else "\xe8" +) + +from .errors import RPCError +from .client import * +from .client.handlers import * +from .client.types import * + if sys.version_info[:3] in [(3, 5, 0), (3, 5, 1), (3, 5, 2)]: from .vendor import typing # Monkey patch the standard "typing" module because Python versions from 3.5.0 to 3.5.2 have a broken one. sys.modules["typing"] = typing - -__copyright__ = "Copyright (C) 2017-2019 Dan Tès ".replace( - "\xe8", - "e" if sys.getfilesystemencoding() != "utf-8" else "\xe8" -) -__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)" -__version__ = "0.12.0.develop" - -from .api.errors import Error -from .client.types import ( - Audio, Chat, ChatMember, ChatMembers, ChatPhoto, Contact, Document, InputMedia, InputMediaPhoto, - InputMediaVideo, InputMediaDocument, InputMediaAudio, InputMediaAnimation, InputPhoneContact, - Location, Message, MessageEntity, Dialog, Dialogs, Photo, PhotoSize, Sticker, User, UserStatus, - UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply, - InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, - InlineQuery, InlineQueryResult, InlineQueryResultArticle, InputMessageContent, InputTextMessageContent, - InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, Poll, - PollOption, ChatPreview, StopPropagation, ContinuePropagation, Game, CallbackGame, GameHighScore, GameHighScores, - ChatPermissions -) -from .client import ( - Client, ChatAction, ParseMode, Emoji, - MessageHandler, DeletedMessagesHandler, CallbackQueryHandler, - RawUpdateHandler, DisconnectHandler, UserStatusHandler, Filters, - InlineQueryHandler -) diff --git a/pyrogram/api/core/object.py b/pyrogram/api/core/object.py index d4715d3c..a479fb6e 100644 --- a/pyrogram/api/core/object.py +++ b/pyrogram/api/core/object.py @@ -39,18 +39,9 @@ class Object: def __str__(self) -> str: return dumps(self, indent=4, default=default, ensure_ascii=False) - def __bool__(self) -> bool: - return True - - def __eq__(self, other) -> bool: - return self.__dict__ == other.__dict__ - def __len__(self) -> int: return len(self.write()) - def __call__(self): - pass - def __getitem__(self, item): return getattr(self, item) diff --git a/pyrogram/client/__init__.py b/pyrogram/client/__init__.py index 125d1469..d43511d2 100644 --- a/pyrogram/client/__init__.py +++ b/pyrogram/client/__init__.py @@ -19,9 +19,7 @@ from .client import Client from .ext import BaseClient, ChatAction, Emoji, ParseMode from .filters import Filters -from .handlers import ( - MessageHandler, DeletedMessagesHandler, - CallbackQueryHandler, RawUpdateHandler, - DisconnectHandler, UserStatusHandler, - InlineQueryHandler -) + +__all__ = [ + "Client", "BaseClient", "ChatAction", "Emoji", "ParseMode", "Filters", +] diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index ca74e25b..d2d3cec5 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -41,7 +41,7 @@ from typing import Union, List from pyrogram.api import functions, types from pyrogram.api.core import Object -from pyrogram.api.errors import ( +from pyrogram.errors import ( PhoneMigrate, NetworkMigrate, PhoneNumberInvalid, PhoneNumberUnoccupied, PhoneCodeInvalid, PhoneCodeHashEmpty, PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded, @@ -54,8 +54,7 @@ from pyrogram.client.handlers.handler import Handler from pyrogram.client.methods.password.utils import compute_check from pyrogram.crypto import AES from pyrogram.session import Auth, Session -from .dispatcher import Dispatcher -from .ext import utils, Syncer, BaseClient +from .ext import utils, Syncer, BaseClient, Dispatcher from .methods import Methods log = logging.getLogger(__name__) @@ -267,7 +266,7 @@ class Client(Methods, BaseClient): Requires no parameters. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ConnectionError`` in case you try to start an already started Client. """ if self.is_started: @@ -437,7 +436,7 @@ class Client(Methods, BaseClient): Requires no parameters. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ self.start() self.idle() @@ -1039,7 +1038,7 @@ class Client(Methods, BaseClient): Timeout in seconds. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if not self.is_started: raise ConnectionError("Client has not been started") @@ -1329,7 +1328,7 @@ class Client(Methods, BaseClient): On success, the resolved peer id is returned in form of an InputPeer object. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``KeyError`` in case the peer doesn't exist in the internal database. """ try: @@ -1434,7 +1433,7 @@ class Client(Methods, BaseClient): On success, the uploaded file is returned in form of an InputFile object. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ part_size = 512 * 1024 file_size = os.path.getsize(path) diff --git a/pyrogram/client/handlers/__init__.py b/pyrogram/client/handlers/__init__.py index 54c98f7f..5e392949 100644 --- a/pyrogram/client/handlers/__init__.py +++ b/pyrogram/client/handlers/__init__.py @@ -23,3 +23,8 @@ from .inline_query_handler import InlineQueryHandler from .message_handler import MessageHandler from .raw_update_handler import RawUpdateHandler from .user_status_handler import UserStatusHandler + +__all__ = [ + "MessageHandler", "DeletedMessagesHandler", "CallbackQueryHandler", "RawUpdateHandler", "DisconnectHandler", + "UserStatusHandler", "InlineQueryHandler" +] diff --git a/pyrogram/client/methods/bots/answer_callback_query.py b/pyrogram/client/methods/bots/answer_callback_query.py index 87fc458a..33458db9 100644 --- a/pyrogram/client/methods/bots/answer_callback_query.py +++ b/pyrogram/client/methods/bots/answer_callback_query.py @@ -57,7 +57,7 @@ class AnswerCallbackQuery(BaseClient): True, on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return self.send( functions.messages.SetBotCallbackAnswer( diff --git a/pyrogram/client/methods/bots/get_game_high_scores.py b/pyrogram/client/methods/bots/get_game_high_scores.py index e782dadc..bb2e99db 100644 --- a/pyrogram/client/methods/bots/get_game_high_scores.py +++ b/pyrogram/client/methods/bots/get_game_high_scores.py @@ -52,7 +52,7 @@ class GetGameHighScores(BaseClient): On success, a :obj:`GameHighScores ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ # TODO: inline_message_id diff --git a/pyrogram/client/methods/bots/get_inline_bot_results.py b/pyrogram/client/methods/bots/get_inline_bot_results.py index 7c94bcf3..b12c0439 100644 --- a/pyrogram/client/methods/bots/get_inline_bot_results.py +++ b/pyrogram/client/methods/bots/get_inline_bot_results.py @@ -19,7 +19,7 @@ from typing import Union from pyrogram.api import functions, types -from pyrogram.api.errors import UnknownError +from pyrogram.errors import UnknownError from pyrogram.client.ext import BaseClient @@ -58,7 +58,7 @@ class GetInlineBotResults(BaseClient): On Success, :obj:`BotResults ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 87247126..7b37f51a 100644 --- a/pyrogram/client/methods/bots/request_callback_answer.py +++ b/pyrogram/client/methods/bots/request_callback_answer.py @@ -49,7 +49,7 @@ class RequestCallbackAnswer(BaseClient): or as an alert. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``TimeoutError`` if the bot fails to answer within 10 seconds. """ return self.send( diff --git a/pyrogram/client/methods/bots/send_game.py b/pyrogram/client/methods/bots/send_game.py index c396ee85..a690c960 100644 --- a/pyrogram/client/methods/bots/send_game.py +++ b/pyrogram/client/methods/bots/send_game.py @@ -63,7 +63,7 @@ class SendGame(BaseClient): On success, the sent :obj:`Message` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ r = self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/bots/send_inline_bot_result.py b/pyrogram/client/methods/bots/send_inline_bot_result.py index 6cfc6295..9b375a0a 100644 --- a/pyrogram/client/methods/bots/send_inline_bot_result.py +++ b/pyrogram/client/methods/bots/send_inline_bot_result.py @@ -61,7 +61,7 @@ class SendInlineBotResult(BaseClient): On success, the sent Message is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return self.send( functions.messages.SendInlineBotResult( diff --git a/pyrogram/client/methods/bots/set_game_score.py b/pyrogram/client/methods/bots/set_game_score.py index 337576a9..434720c6 100644 --- a/pyrogram/client/methods/bots/set_game_score.py +++ b/pyrogram/client/methods/bots/set_game_score.py @@ -67,7 +67,7 @@ class SetGameScore(BaseClient): otherwise returns True. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. :class:`BotScoreNotModified` if the new score is not greater than the user's current score in the chat and force is False. """ r = self.send( diff --git a/pyrogram/client/methods/chats/delete_chat_photo.py b/pyrogram/client/methods/chats/delete_chat_photo.py index 2473e123..c11a0d13 100644 --- a/pyrogram/client/methods/chats/delete_chat_photo.py +++ b/pyrogram/client/methods/chats/delete_chat_photo.py @@ -43,7 +43,7 @@ class DeleteChatPhoto(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if a chat_id belongs to user. """ peer = 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 88056344..b84b1d3c 100644 --- a/pyrogram/client/methods/chats/export_chat_invite_link.py +++ b/pyrogram/client/methods/chats/export_chat_invite_link.py @@ -40,7 +40,7 @@ class ExportChatInviteLink(BaseClient): On success, the exported invite link as string is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ peer = self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/get_chat.py b/pyrogram/client/methods/chats/get_chat.py index 31e0a293..38653459 100644 --- a/pyrogram/client/methods/chats/get_chat.py +++ b/pyrogram/client/methods/chats/get_chat.py @@ -42,7 +42,7 @@ class GetChat(BaseClient): On success, a :obj:`Chat ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` in case the chat invite link refers to a chat you haven't joined yet. """ match = self.INVITE_LINK_RE.match(str(chat_id)) diff --git a/pyrogram/client/methods/chats/get_chat_member.py b/pyrogram/client/methods/chats/get_chat_member.py index d8315010..aec4d233 100644 --- a/pyrogram/client/methods/chats/get_chat_member.py +++ b/pyrogram/client/methods/chats/get_chat_member.py @@ -19,7 +19,8 @@ from typing import Union import pyrogram -from pyrogram.api import functions, types, errors +from pyrogram.api import functions, types +from pyrogram.errors import UserNotParticipant from ...ext import BaseClient @@ -44,7 +45,7 @@ class GetChatMember(BaseClient): On success, a :obj:`ChatMember ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ chat_id = self.resolve_peer(chat_id) user_id = self.resolve_peer(user_id) @@ -60,7 +61,7 @@ class GetChatMember(BaseClient): if member.user.is_self: return member else: - raise errors.UserNotParticipant + raise UserNotParticipant elif isinstance(chat_id, types.InputPeerChannel): r = self.send( functions.channels.GetParticipant( diff --git a/pyrogram/client/methods/chats/get_chat_members.py b/pyrogram/client/methods/chats/get_chat_members.py index 0b07f674..f69674c4 100644 --- a/pyrogram/client/methods/chats/get_chat_members.py +++ b/pyrogram/client/methods/chats/get_chat_members.py @@ -84,7 +84,7 @@ class GetChatMembers(BaseClient): On success, a :obj:`ChatMembers` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if you used an invalid filter or a chat_id that belongs to a user. """ peer = 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 9e79d5fa..fc13ac39 100644 --- a/pyrogram/client/methods/chats/get_chat_members_count.py +++ b/pyrogram/client/methods/chats/get_chat_members_count.py @@ -37,7 +37,7 @@ class GetChatMembersCount(BaseClient): On success, an integer is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if a chat_id belongs to user. """ peer = self.resolve_peer(chat_id) diff --git a/pyrogram/client/methods/chats/get_chat_preview.py b/pyrogram/client/methods/chats/get_chat_preview.py index 28e84c79..9b6c6955 100644 --- a/pyrogram/client/methods/chats/get_chat_preview.py +++ b/pyrogram/client/methods/chats/get_chat_preview.py @@ -38,7 +38,7 @@ class GetChatPreview(BaseClient): Either :obj:`Chat` or :obj:`ChatPreview`, depending on whether you already joined the chat or not. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` in case of an invalid invite_link. """ match = self.INVITE_LINK_RE.match(invite_link) diff --git a/pyrogram/client/methods/chats/get_dialogs.py b/pyrogram/client/methods/chats/get_dialogs.py index e062a00b..3bcf223f 100644 --- a/pyrogram/client/methods/chats/get_dialogs.py +++ b/pyrogram/client/methods/chats/get_dialogs.py @@ -21,7 +21,7 @@ import time import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FloodWait +from pyrogram.errors import FloodWait from ...ext import BaseClient log = logging.getLogger(__name__) @@ -56,7 +56,7 @@ class GetDialogs(BaseClient): On success, a :obj:`Dialogs` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ while True: diff --git a/pyrogram/client/methods/chats/iter_chat_members.py b/pyrogram/client/methods/chats/iter_chat_members.py index 0886d6c6..2f41763e 100644 --- a/pyrogram/client/methods/chats/iter_chat_members.py +++ b/pyrogram/client/methods/chats/iter_chat_members.py @@ -78,7 +78,7 @@ class IterChatMembers(BaseClient): A generator yielding :obj:`ChatMember ` objects. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ current = 0 yielded = set() diff --git a/pyrogram/client/methods/chats/iter_dialogs.py b/pyrogram/client/methods/chats/iter_dialogs.py index a5fdb35e..99437cb4 100644 --- a/pyrogram/client/methods/chats/iter_dialogs.py +++ b/pyrogram/client/methods/chats/iter_dialogs.py @@ -46,7 +46,7 @@ class IterDialogs(BaseClient): A generator yielding :obj:`Dialog ` objects. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ current = 0 total = limit or (1 << 31) - 1 diff --git a/pyrogram/client/methods/chats/join_chat.py b/pyrogram/client/methods/chats/join_chat.py index 1ee680bf..a7933bea 100644 --- a/pyrogram/client/methods/chats/join_chat.py +++ b/pyrogram/client/methods/chats/join_chat.py @@ -37,7 +37,7 @@ class JoinChat(BaseClient): On success, a :obj:`Chat ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 ef0d7d55..7b10ddea 100644 --- a/pyrogram/client/methods/chats/kick_chat_member.py +++ b/pyrogram/client/methods/chats/kick_chat_member.py @@ -57,7 +57,7 @@ class KickChatMember(BaseClient): On success, either True or a service :obj:`Message ` will be returned (when applicable). Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ chat_peer = self.resolve_peer(chat_id) user_peer = self.resolve_peer(user_id) diff --git a/pyrogram/client/methods/chats/leave_chat.py b/pyrogram/client/methods/chats/leave_chat.py index 9f41a0cc..8ba3a3d1 100644 --- a/pyrogram/client/methods/chats/leave_chat.py +++ b/pyrogram/client/methods/chats/leave_chat.py @@ -39,7 +39,7 @@ class LeaveChat(BaseClient): Deletes the group chat dialog after leaving (for simple group chats, not supergroups). Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ peer = 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 682f595d..1d5466ba 100644 --- a/pyrogram/client/methods/chats/pin_chat_message.py +++ b/pyrogram/client/methods/chats/pin_chat_message.py @@ -48,7 +48,7 @@ class PinChatMessage(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ self.send( functions.messages.UpdatePinnedMessage( diff --git a/pyrogram/client/methods/chats/promote_chat_member.py b/pyrogram/client/methods/chats/promote_chat_member.py index f3359c5f..26d49516 100644 --- a/pyrogram/client/methods/chats/promote_chat_member.py +++ b/pyrogram/client/methods/chats/promote_chat_member.py @@ -79,7 +79,7 @@ class PromoteChatMember(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ self.send( functions.channels.EditAdmin( diff --git a/pyrogram/client/methods/chats/restrict_chat.py b/pyrogram/client/methods/chats/restrict_chat.py index ca3e8055..40d46d34 100644 --- a/pyrogram/client/methods/chats/restrict_chat.py +++ b/pyrogram/client/methods/chats/restrict_chat.py @@ -73,7 +73,7 @@ class RestrictChat(BaseClient): On success, a :obj:`Chat ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ send_messages = True send_media = True diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py index 72788188..8688ecca 100644 --- a/pyrogram/client/methods/chats/restrict_chat_member.py +++ b/pyrogram/client/methods/chats/restrict_chat_member.py @@ -86,7 +86,7 @@ class RestrictChatMember(BaseClient): On success, a :obj:`Chat ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 795c0504..ebe15bf2 100644 --- a/pyrogram/client/methods/chats/set_chat_description.py +++ b/pyrogram/client/methods/chats/set_chat_description.py @@ -42,7 +42,7 @@ class SetChatDescription(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if a chat_id doesn't belong to a supergroup or a channel. """ peer = 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 e2fdaab2..87fe1b72 100644 --- a/pyrogram/client/methods/chats/set_chat_photo.py +++ b/pyrogram/client/methods/chats/set_chat_photo.py @@ -50,7 +50,7 @@ class SetChatPhoto(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if a chat_id belongs to user. """ peer = 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 1c953ee1..e94f16a8 100644 --- a/pyrogram/client/methods/chats/set_chat_title.py +++ b/pyrogram/client/methods/chats/set_chat_title.py @@ -47,7 +47,7 @@ class SetChatTitle(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if a chat_id belongs to user. """ peer = 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 3000648f..0576c028 100644 --- a/pyrogram/client/methods/chats/unban_chat_member.py +++ b/pyrogram/client/methods/chats/unban_chat_member.py @@ -44,7 +44,7 @@ class UnbanChatMember(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ 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 8030d966..9753d656 100644 --- a/pyrogram/client/methods/chats/unpin_chat_message.py +++ b/pyrogram/client/methods/chats/unpin_chat_message.py @@ -39,7 +39,7 @@ class UnpinChatMessage(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ self.send( functions.messages.UpdatePinnedMessage( diff --git a/pyrogram/client/methods/chats/update_chat_username.py b/pyrogram/client/methods/chats/update_chat_username.py index cc6416a9..39cdfaeb 100644 --- a/pyrogram/client/methods/chats/update_chat_username.py +++ b/pyrogram/client/methods/chats/update_chat_username.py @@ -42,7 +42,7 @@ class UpdateChatUsername(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if a chat_id belongs to a user or chat. """ diff --git a/pyrogram/client/methods/contacts/add_contacts.py b/pyrogram/client/methods/contacts/add_contacts.py index aa98fef2..d1a97c99 100644 --- a/pyrogram/client/methods/contacts/add_contacts.py +++ b/pyrogram/client/methods/contacts/add_contacts.py @@ -38,7 +38,7 @@ class AddContacts(BaseClient): On success, the added contacts are returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ imported_contacts = self.send( functions.contacts.ImportContacts( diff --git a/pyrogram/client/methods/contacts/delete_contacts.py b/pyrogram/client/methods/contacts/delete_contacts.py index 7ac6d02a..af8f453e 100644 --- a/pyrogram/client/methods/contacts/delete_contacts.py +++ b/pyrogram/client/methods/contacts/delete_contacts.py @@ -19,7 +19,7 @@ from typing import List from pyrogram.api import functions, types -from pyrogram.api.errors import PeerIdInvalid +from pyrogram.errors import PeerIdInvalid from ...ext import BaseClient @@ -39,7 +39,7 @@ class DeleteContacts(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 30310913..e62847c8 100644 --- a/pyrogram/client/methods/contacts/get_contacts.py +++ b/pyrogram/client/methods/contacts/get_contacts.py @@ -21,7 +21,7 @@ import time import pyrogram from pyrogram.api import functions -from pyrogram.api.errors import FloodWait +from pyrogram.errors import FloodWait from ...ext import BaseClient log = logging.getLogger(__name__) @@ -35,7 +35,7 @@ class GetContacts(BaseClient): On success, a list of :obj:`User` objects is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ while True: try: diff --git a/pyrogram/client/methods/messages/close_poll.py b/pyrogram/client/methods/messages/close_poll.py index ac4fc197..1b1164c2 100644 --- a/pyrogram/client/methods/messages/close_poll.py +++ b/pyrogram/client/methods/messages/close_poll.py @@ -45,7 +45,7 @@ class ClosePoll(BaseClient): On success, True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ poll = self.get_messages(chat_id, message_id).poll diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py index df26aff6..d1835ad7 100644 --- a/pyrogram/client/methods/messages/delete_messages.py +++ b/pyrogram/client/methods/messages/delete_messages.py @@ -59,7 +59,7 @@ class DeleteMessages(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ peer = 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/download_media.py b/pyrogram/client/methods/messages/download_media.py index 6fc47601..35959d4a 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -77,7 +77,7 @@ class DownloadMedia(BaseClient): In case the download is deliberately stopped with :meth:`stop_transmission`, None is returned as well. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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/methods/messages/edit_message_caption.py b/pyrogram/client/methods/messages/edit_message_caption.py index ce393319..c7bcbd70 100644 --- a/pyrogram/client/methods/messages/edit_message_caption.py +++ b/pyrogram/client/methods/messages/edit_message_caption.py @@ -58,7 +58,7 @@ class EditMessageCaption(BaseClient): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 57600ead..ea5870fc 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid +from pyrogram.errors import FileIdInvalid from pyrogram.client.ext import BaseClient, utils from pyrogram.client.types import ( InputMediaPhoto, InputMediaVideo, InputMediaAudio, @@ -66,7 +66,7 @@ class EditMessageMedia(BaseClient): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 68455131..e3495476 100644 --- a/pyrogram/client/methods/messages/edit_message_reply_markup.py +++ b/pyrogram/client/methods/messages/edit_message_reply_markup.py @@ -49,7 +49,7 @@ class EditMessageReplyMarkup(BaseClient): :obj:`Message ` is returned, otherwise True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ r = self.send( diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py index f4c5f6cf..8e23b1de 100644 --- a/pyrogram/client/methods/messages/edit_message_text.py +++ b/pyrogram/client/methods/messages/edit_message_text.py @@ -62,7 +62,7 @@ class EditMessageText(BaseClient): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 dad01a7f..5540b38a 100644 --- a/pyrogram/client/methods/messages/forward_messages.py +++ b/pyrogram/client/methods/messages/forward_messages.py @@ -70,7 +70,7 @@ class ForwardMessages(BaseClient): is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ is_iterable = not isinstance(message_ids, int) diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py index ca357204..fda8f11f 100644 --- a/pyrogram/client/methods/messages/get_history.py +++ b/pyrogram/client/methods/messages/get_history.py @@ -22,7 +22,7 @@ from typing import Union import pyrogram from pyrogram.api import functions -from pyrogram.api.errors import FloodWait +from pyrogram.errors import FloodWait from ...ext import BaseClient log = logging.getLogger(__name__) @@ -70,7 +70,7 @@ class GetHistory(BaseClient): On success, a :obj:`Messages ` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ while True: diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py index 63fee163..c018a9eb 100644 --- a/pyrogram/client/methods/messages/get_messages.py +++ b/pyrogram/client/methods/messages/get_messages.py @@ -22,7 +22,7 @@ from typing import Union, Iterable import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FloodWait +from pyrogram.errors import FloodWait from ...ext import BaseClient log = logging.getLogger(__name__) @@ -63,7 +63,7 @@ class GetMessages(BaseClient): *reply_to_message_ids* was an integer, the single requested :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ ids, ids_type = ( (message_ids, types.InputMessageID) if message_ids diff --git a/pyrogram/client/methods/messages/iter_history.py b/pyrogram/client/methods/messages/iter_history.py index 92dc7584..f7a8a74e 100644 --- a/pyrogram/client/methods/messages/iter_history.py +++ b/pyrogram/client/methods/messages/iter_history.py @@ -64,7 +64,7 @@ class IterHistory(BaseClient): A generator yielding :obj:`Message ` objects. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ offset_id = offset_id or (1 if reverse else 0) current = 0 diff --git a/pyrogram/client/methods/messages/retract_vote.py b/pyrogram/client/methods/messages/retract_vote.py index e7ffe19b..8fa8996c 100644 --- a/pyrogram/client/methods/messages/retract_vote.py +++ b/pyrogram/client/methods/messages/retract_vote.py @@ -43,7 +43,7 @@ class RetractVote(BaseClient): On success, True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ self.send( functions.messages.SendVote( diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index 454d25ff..798d236d 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -125,7 +125,7 @@ class SendAnimation(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 d99cf744..d514b737 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -127,7 +127,7 @@ class SendAudio(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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_cached_media.py b/pyrogram/client/methods/messages/send_cached_media.py index 90c9b09f..f0c690d9 100644 --- a/pyrogram/client/methods/messages/send_cached_media.py +++ b/pyrogram/client/methods/messages/send_cached_media.py @@ -22,7 +22,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid +from pyrogram.errors import FileIdInvalid from pyrogram.client.ext import BaseClient, utils @@ -81,7 +81,7 @@ class SendCachedMedia(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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_chat_action.py b/pyrogram/client/methods/messages/send_chat_action.py index bfddf90b..cdd61df3 100644 --- a/pyrogram/client/methods/messages/send_chat_action.py +++ b/pyrogram/client/methods/messages/send_chat_action.py @@ -51,7 +51,7 @@ class SendChatAction(BaseClient): On success, True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if the provided string is not a valid ChatAction. """ diff --git a/pyrogram/client/methods/messages/send_contact.py b/pyrogram/client/methods/messages/send_contact.py index 14ce61ec..9143440e 100644 --- a/pyrogram/client/methods/messages/send_contact.py +++ b/pyrogram/client/methods/messages/send_contact.py @@ -75,7 +75,7 @@ class SendContact(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ r = self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 343a63a3..a36a0fbb 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -113,7 +113,7 @@ class SendDocument(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 c59ea380..f3ed81df 100644 --- a/pyrogram/client/methods/messages/send_location.py +++ b/pyrogram/client/methods/messages/send_location.py @@ -67,7 +67,7 @@ class SendLocation(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ r = self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py index a546e114..4fdc1132 100644 --- a/pyrogram/client/methods/messages/send_media_group.py +++ b/pyrogram/client/methods/messages/send_media_group.py @@ -25,7 +25,7 @@ from typing import Union, List import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FloodWait +from pyrogram.errors import FileIdInvalid, FloodWait from pyrogram.client.ext import BaseClient, utils log = logging.getLogger(__name__) @@ -64,7 +64,7 @@ class SendMediaGroup(BaseClient): single messages sent. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ multi_media = [] diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py index 3913e97d..b45b7192 100644 --- a/pyrogram/client/methods/messages/send_message.py +++ b/pyrogram/client/methods/messages/send_message.py @@ -73,7 +73,7 @@ class SendMessage(BaseClient): On success, the sent :obj:`Message` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ style = self.html if parse_mode.lower() == "html" else self.markdown message, entities = style.parse(text).values() diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py index 6892f92d..7e327cbd 100644 --- a/pyrogram/client/methods/messages/send_photo.py +++ b/pyrogram/client/methods/messages/send_photo.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -112,7 +112,7 @@ class SendPhoto(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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_poll.py b/pyrogram/client/methods/messages/send_poll.py index c9525c83..13e55b08 100644 --- a/pyrogram/client/methods/messages/send_poll.py +++ b/pyrogram/client/methods/messages/send_poll.py @@ -67,7 +67,7 @@ class SendPoll(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ r = self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_sticker.py b/pyrogram/client/methods/messages/send_sticker.py index b4441cb1..e556aae3 100644 --- a/pyrogram/client/methods/messages/send_sticker.py +++ b/pyrogram/client/methods/messages/send_sticker.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -96,7 +96,7 @@ class SendSticker(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 cc98eb28..1c9ca630 100644 --- a/pyrogram/client/methods/messages/send_venue.py +++ b/pyrogram/client/methods/messages/send_venue.py @@ -84,7 +84,7 @@ class SendVenue(BaseClient): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ r = self.send( functions.messages.SendMedia( diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index bb90bdf6..08d8b7ab 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -129,7 +129,7 @@ class SendVideo(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 349b76a6..4844dd65 100644 --- a/pyrogram/client/methods/messages/send_video_note.py +++ b/pyrogram/client/methods/messages/send_video_note.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -111,7 +111,7 @@ class SendVideoNote(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 10b3c906..110b0704 100644 --- a/pyrogram/client/methods/messages/send_voice.py +++ b/pyrogram/client/methods/messages/send_voice.py @@ -23,7 +23,7 @@ from typing import Union import pyrogram from pyrogram.api import functions, types -from pyrogram.api.errors import FileIdInvalid, FilePartMissing +from pyrogram.errors import FileIdInvalid, FilePartMissing from pyrogram.client.ext import BaseClient, utils @@ -110,7 +110,7 @@ class SendVoice(BaseClient): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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/vote_poll.py b/pyrogram/client/methods/messages/vote_poll.py index bf44c831..2a9de874 100644 --- a/pyrogram/client/methods/messages/vote_poll.py +++ b/pyrogram/client/methods/messages/vote_poll.py @@ -47,7 +47,7 @@ class VotePoll(BaseClient): On success, True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ poll = self.get_messages(chat_id, message_id).poll diff --git a/pyrogram/client/methods/password/change_cloud_password.py b/pyrogram/client/methods/password/change_cloud_password.py index 163144bf..2f8cfbd6 100644 --- a/pyrogram/client/methods/password/change_cloud_password.py +++ b/pyrogram/client/methods/password/change_cloud_password.py @@ -46,7 +46,7 @@ class ChangeCloudPassword(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` in case there is no cloud password to change. """ r = 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 6e7a0bc9..b29dcfd3 100644 --- a/pyrogram/client/methods/password/enable_cloud_password.py +++ b/pyrogram/client/methods/password/enable_cloud_password.py @@ -48,7 +48,7 @@ class EnableCloudPassword(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` in case there is already a cloud password enabled. """ r = 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 e7c7ed2d..6e9a0ab4 100644 --- a/pyrogram/client/methods/password/remove_cloud_password.py +++ b/pyrogram/client/methods/password/remove_cloud_password.py @@ -36,7 +36,7 @@ class RemoveCloudPassword(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` in case there is no cloud password to remove. """ r = 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 6c0eb8d2..bd9fc98e 100644 --- a/pyrogram/client/methods/users/delete_user_profile_photos.py +++ b/pyrogram/client/methods/users/delete_user_profile_photos.py @@ -40,7 +40,7 @@ class DeleteUserProfilePhotos(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 fdceeaba..c8b6c1f1 100644 --- a/pyrogram/client/methods/users/get_me.py +++ b/pyrogram/client/methods/users/get_me.py @@ -29,7 +29,7 @@ class GetMe(BaseClient): Basic information about the user or bot in form of a :obj:`User` object Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return pyrogram.User._parse( self, diff --git a/pyrogram/client/methods/users/get_user_profile_photos.py b/pyrogram/client/methods/users/get_user_profile_photos.py index d23ec48d..ac7a872e 100644 --- a/pyrogram/client/methods/users/get_user_profile_photos.py +++ b/pyrogram/client/methods/users/get_user_profile_photos.py @@ -50,7 +50,7 @@ class GetUserProfilePhotos(BaseClient): On success, a :obj:`UserProfilePhotos` object is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return pyrogram.UserProfilePhotos._parse( self, diff --git a/pyrogram/client/methods/users/get_users.py b/pyrogram/client/methods/users/get_users.py index d3822dc9..7e6ebd6b 100644 --- a/pyrogram/client/methods/users/get_users.py +++ b/pyrogram/client/methods/users/get_users.py @@ -43,7 +43,7 @@ class GetUsers(BaseClient): *user_ids* was an integer or string, the single requested :obj:`User` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` 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 705631fd..af02a12d 100644 --- a/pyrogram/client/methods/users/set_user_profile_photo.py +++ b/pyrogram/client/methods/users/set_user_profile_photo.py @@ -39,7 +39,7 @@ class SetUserProfilePhoto(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return bool( diff --git a/pyrogram/client/methods/users/update_username.py b/pyrogram/client/methods/users/update_username.py index 5fd1a711..d0c87eb2 100644 --- a/pyrogram/client/methods/users/update_username.py +++ b/pyrogram/client/methods/users/update_username.py @@ -41,7 +41,7 @@ class UpdateUsername(BaseClient): True on success. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return bool( diff --git a/pyrogram/client/types/__init__.py b/pyrogram/client/types/__init__.py index c70ec83f..120c7ff5 100644 --- a/pyrogram/client/types/__init__.py +++ b/pyrogram/client/types/__init__.py @@ -16,28 +16,10 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from .bots import ( - ForceReply, InlineKeyboardButton, InlineKeyboardMarkup, - KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, CallbackGame, - GameHighScore, GameHighScores, CallbackQuery -) -from .inline_mode import ( - InlineQuery, InlineQueryResult, InlineQueryResultArticle -) -from .input_media import ( - InputMedia, InputMediaAudio, InputPhoneContact, InputMediaVideo, InputMediaPhoto, - InputMediaDocument, InputMediaAnimation -) -from .input_message_content import ( - InputMessageContent, InputTextMessageContent -) -from .messages_and_media import ( - Audio, Contact, Document, Animation, Location, Photo, PhotoSize, - Sticker, Venue, Video, VideoNote, Voice, UserProfilePhotos, - Message, Messages, MessageEntity, Poll, PollOption, Game -) -from .update import StopPropagation, ContinuePropagation -from .user_and_chats import ( - Chat, ChatMember, ChatMembers, ChatPhoto, - Dialog, Dialogs, User, UserStatus, ChatPreview, ChatPermissions -) +from .bots import * +from .inline_mode import * +from .input_media import * +from .input_message_content import * +from .messages_and_media import * +from .update import * +from .user_and_chats import * diff --git a/pyrogram/client/types/bots/__init__.py b/pyrogram/client/types/bots/__init__.py index 81767945..dae33e10 100644 --- a/pyrogram/client/types/bots/__init__.py +++ b/pyrogram/client/types/bots/__init__.py @@ -26,3 +26,8 @@ from .inline_keyboard_markup import InlineKeyboardMarkup from .keyboard_button import KeyboardButton from .reply_keyboard_markup import ReplyKeyboardMarkup from .reply_keyboard_remove import ReplyKeyboardRemove + +__all__ = [ + "CallbackGame", "CallbackQuery", "ForceReply", "GameHighScore", "GameHighScores", "InlineKeyboardButton", + "InlineKeyboardMarkup", "KeyboardButton", "ReplyKeyboardMarkup", "ReplyKeyboardRemove" +] diff --git a/pyrogram/client/types/inline_mode/__init__.py b/pyrogram/client/types/inline_mode/__init__.py index a7cb93d3..7a3b3023 100644 --- a/pyrogram/client/types/inline_mode/__init__.py +++ b/pyrogram/client/types/inline_mode/__init__.py @@ -19,3 +19,7 @@ from .inline_query import InlineQuery from .inline_query_result import InlineQueryResult from .inline_query_result_article import InlineQueryResultArticle + +__all__ = [ + "InlineQuery", "InlineQueryResult", "InlineQueryResultArticle" +] diff --git a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py index 1f3a1963..f6ed1f15 100644 --- a/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py +++ b/pyrogram/client/types/inline_mode/todo/inline_query_result_cached_audio.py @@ -20,7 +20,7 @@ import binascii import struct from pyrogram.api import types -from pyrogram.api.errors import FileIdInvalid +from pyrogram.errors import FileIdInvalid from pyrogram.client.ext import utils, BaseClient from pyrogram.client.style import HTML, Markdown from pyrogram.client.types.pyrogram_type import PyrogramType diff --git a/pyrogram/client/types/input_media/__init__.py b/pyrogram/client/types/input_media/__init__.py index e2e0b0f6..c97b9539 100644 --- a/pyrogram/client/types/input_media/__init__.py +++ b/pyrogram/client/types/input_media/__init__.py @@ -23,3 +23,8 @@ from .input_media_document import InputMediaDocument from .input_media_photo import InputMediaPhoto from .input_media_video import InputMediaVideo from .input_phone_contact import InputPhoneContact + +__all__ = [ + "InputMedia", "InputMediaAnimation", "InputMediaAudio", "InputMediaDocument", "InputMediaPhoto", "InputMediaVideo", + "InputPhoneContact" +] diff --git a/pyrogram/client/types/input_message_content/__init__.py b/pyrogram/client/types/input_message_content/__init__.py index 39081574..5c53fd2e 100644 --- a/pyrogram/client/types/input_message_content/__init__.py +++ b/pyrogram/client/types/input_message_content/__init__.py @@ -18,3 +18,7 @@ from .input_message_content import InputMessageContent from .input_text_message_content import InputTextMessageContent + +__all__ = [ + "InputMessageContent", "InputTextMessageContent" +] diff --git a/pyrogram/client/types/messages_and_media/__init__.py b/pyrogram/client/types/messages_and_media/__init__.py index 604b68b9..ae4386d0 100644 --- a/pyrogram/client/types/messages_and_media/__init__.py +++ b/pyrogram/client/types/messages_and_media/__init__.py @@ -35,3 +35,8 @@ from .venue import Venue from .video import Video from .video_note import VideoNote from .voice import Voice + +__all__ = [ + "Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo", + "PhotoSize", "Poll", "PollOption", "Sticker", "UserProfilePhotos", "Venue", "Video", "VideoNote", "Voice" +] diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 04f200a2..fc2cb8fb 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -21,7 +21,7 @@ from typing import List, Match, Union import pyrogram from pyrogram.api import types -from pyrogram.api.errors import MessageIdsEmpty +from pyrogram.errors import MessageIdsEmpty from pyrogram.client.ext import ChatAction, ParseMode from pyrogram.client.types.input_media import InputMedia from .contact import Contact @@ -708,7 +708,7 @@ class Message(PyrogramType, Update): On success, the sent Message is returned. Raises: - :class:`Error ` + :class:`RPCError ` """ if quote is None: quote = self.chat.type != "private" @@ -837,7 +837,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` + :class:`RPCError ` """ if quote is None: quote = self.chat.type != "private" @@ -972,7 +972,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` + :class:`RPCError ` """ if quote is None: quote = self.chat.type != "private" @@ -1060,7 +1060,7 @@ class Message(PyrogramType, Update): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` + :class:`RPCError ` """ if quote is None: quote = self.chat.type != "private" @@ -1114,7 +1114,7 @@ class Message(PyrogramType, Update): On success, True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. ``ValueError`` if the provided string is not a valid ChatAction. """ return self._client.send_chat_action( @@ -1189,7 +1189,7 @@ class Message(PyrogramType, Update): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1307,7 +1307,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1381,7 +1381,7 @@ class Message(PyrogramType, Update): On success, the sent :obj:`Message` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1449,7 +1449,7 @@ class Message(PyrogramType, Update): On success, the sent Message is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1524,7 +1524,7 @@ class Message(PyrogramType, Update): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1587,7 +1587,7 @@ class Message(PyrogramType, Update): single messages sent. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1700,7 +1700,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1779,7 +1779,7 @@ class Message(PyrogramType, Update): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1878,7 +1878,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -1973,7 +1973,7 @@ class Message(PyrogramType, Update): On success, the sent :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -2109,7 +2109,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -2231,7 +2231,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -2348,7 +2348,7 @@ class Message(PyrogramType, Update): In case the upload is deliberately stopped with :meth:`stop_transmission`, None is returned instead. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ if quote is None: quote = self.chat.type != "private" @@ -2417,7 +2417,7 @@ class Message(PyrogramType, Update): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return self._client.edit_message_text( chat_id=self.chat.id, @@ -2472,7 +2472,7 @@ class Message(PyrogramType, Update): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return self._client.edit_message_caption( chat_id=self.chat.id, @@ -2511,7 +2511,7 @@ class Message(PyrogramType, Update): On success, the edited :obj:`Message ` is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return self._client.edit_message_media( chat_id=self.chat.id, @@ -2547,7 +2547,7 @@ class Message(PyrogramType, Update): :obj:`Message ` is returned, otherwise True is returned. Raises: - :class:`Error ` in case of a Telegram RPC error. + :class:`RPCError ` in case of a Telegram RPC error. """ return self._client.edit_message_reply_markup( chat_id=self.chat.id, @@ -2602,7 +2602,7 @@ class Message(PyrogramType, Update): On success, the forwarded Message is returned. Raises: - :class:`Error ` + :class:`RPCError ` """ if as_copy: if self.service: @@ -2732,7 +2732,7 @@ class Message(PyrogramType, Update): True on success. Raises: - :class:`Error ` + :class:`RPCError ` """ self._client.delete_messages( chat_id=self.chat.id, @@ -2797,7 +2797,7 @@ class Message(PyrogramType, Update): button. Raises: - :class:`Error ` + :class:`RPCError ` ``ValueError``: If the provided index or position is out of range or the button label was not found ``TimeoutError``: If, after clicking an inline button, the bot fails to answer within 10 seconds """ @@ -2898,7 +2898,7 @@ class Message(PyrogramType, Update): On success, the absolute path of the downloaded file as string is returned, None otherwise. Raises: - :class:`Error ` + :class:`RPCError ` ``ValueError``: If the message doesn't contain any downloadable media """ return self._client.download_media( @@ -2935,7 +2935,7 @@ class Message(PyrogramType, Update): True on success. Raises: - :class:`Error ` + :class:`RPCError ` """ return self._client.pin_chat_message( chat_id=self.chat.id, diff --git a/pyrogram/client/types/messages_and_media/messages.py b/pyrogram/client/types/messages_and_media/messages.py index aae31a82..da1a2676 100644 --- a/pyrogram/client/types/messages_and_media/messages.py +++ b/pyrogram/client/types/messages_and_media/messages.py @@ -149,7 +149,7 @@ class Messages(PyrogramType, Update): On success, a :class:`Messages ` containing forwarded messages is returned. Raises: - :class:`Error ` + :class:`RPCError ` """ forwarded_messages = [] diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py index 18dc5e13..1ae2c23e 100644 --- a/pyrogram/client/types/messages_and_media/sticker.py +++ b/pyrogram/client/types/messages_and_media/sticker.py @@ -21,7 +21,7 @@ from struct import pack import pyrogram from pyrogram.api import types, functions -from pyrogram.api.errors import StickersetInvalid +from pyrogram.errors import StickersetInvalid from .photo_size import PhotoSize from ..pyrogram_type import PyrogramType from ...ext.utils import encode diff --git a/pyrogram/client/types/user_and_chats/__init__.py b/pyrogram/client/types/user_and_chats/__init__.py index 9c9c0beb..2059589a 100644 --- a/pyrogram/client/types/user_and_chats/__init__.py +++ b/pyrogram/client/types/user_and_chats/__init__.py @@ -26,3 +26,8 @@ from .dialog import Dialog from .dialogs import Dialogs from .user import User from .user_status import UserStatus + +__all__ = [ + "Chat", "ChatMember", "ChatMembers", "ChatPermissions", "ChatPhoto", "ChatPreview", "Dialog", "Dialogs", "User", + "UserStatus" +] diff --git a/pyrogram/api/errors/__init__.py b/pyrogram/errors/__init__.py similarity index 95% rename from pyrogram/api/errors/__init__.py rename to pyrogram/errors/__init__.py index ca65619c..a34d7078 100644 --- a/pyrogram/api/errors/__init__.py +++ b/pyrogram/errors/__init__.py @@ -17,4 +17,4 @@ # along with Pyrogram. If not, see . from .exceptions import * -from .error import UnknownError +from .rpc_error import UnknownError diff --git a/pyrogram/api/errors/error.py b/pyrogram/errors/rpc_error.py similarity index 88% rename from pyrogram/api/errors/error.py rename to pyrogram/errors/rpc_error.py index 5f92a369..c1799f50 100644 --- a/pyrogram/api/errors/error.py +++ b/pyrogram/errors/rpc_error.py @@ -19,11 +19,11 @@ import re from importlib import import_module -from pyrogram.api.types import RpcError +from pyrogram.api.types import RpcError as RawRPCError from .exceptions.all import exceptions -class Error(Exception): +class RPCError(Exception): """This is the base exception class for all Telegram API related errors. For a finer grained control, see the specific errors below. """ @@ -32,7 +32,7 @@ class Error(Exception): NAME = None MESSAGE = None - def __init__(self, x: int or RpcError = None, query_type: type = None): + def __init__(self, x: int or RawRPCError = None, query_type: type = None): super().__init__("[{} {}]: {}".format( self.CODE, self.ID or self.NAME, @@ -50,7 +50,7 @@ class Error(Exception): f.write("{}\t{}\t{}\n".format(x.error_code, x.error_message, query_type)) @staticmethod - def raise_it(rpc_error: RpcError, query_type: type): + def raise_it(rpc_error: RawRPCError, query_type: type): code = rpc_error.error_code if code not in exceptions: @@ -66,12 +66,12 @@ class Error(Exception): x = x.group(1) if x is not None else x raise getattr( - import_module("pyrogram.api.errors"), + import_module("pyrogram.errors"), exceptions[code][id] )(x=x) -class UnknownError(Error): +class UnknownError(RPCError): """This object represents an Unknown Error, that is, an error which Pyrogram does not know anything about, yet. """ diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 4ebdf4fc..66207037 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -31,9 +31,9 @@ from pyrogram import __copyright__, __license__, __version__ from pyrogram.api import functions, types, core from pyrogram.api.all import layer from pyrogram.api.core import Message, Object, MsgContainer, Long, FutureSalt, Int -from pyrogram.api.errors import Error, InternalServerError, AuthKeyDuplicated from pyrogram.connection import Connection from pyrogram.crypto import AES, KDF +from pyrogram.errors import RPCError, InternalServerError, AuthKeyDuplicated from .internals import MsgId, MsgFactory log = logging.getLogger(__name__) @@ -171,7 +171,7 @@ class Session: except AuthKeyDuplicated as e: self.stop() raise e - except (OSError, TimeoutError, Error): + except (OSError, TimeoutError, RPCError): self.stop() except Exception as e: self.stop() @@ -337,7 +337,7 @@ class Session: self._send(functions.PingDelayDisconnect( ping_id=0, disconnect_delay=self.WAIT_TIMEOUT + 10 ), False) - except (OSError, TimeoutError, Error): + except (OSError, TimeoutError, RPCError): pass log.debug("PingThread stopped") @@ -366,7 +366,7 @@ class Session: try: self.current_salt = self._send(functions.GetFutureSalts(num=1)).salts[0] - except (OSError, TimeoutError, Error): + except (OSError, TimeoutError, RPCError): self.connection.close() break @@ -412,7 +412,7 @@ class Session: if result is None: raise TimeoutError elif isinstance(result, types.RpcError): - Error.raise_it(result, type(data)) + RPCError.raise_it(result, type(data)) elif isinstance(result, types.BadMsgNotification): raise Exception(self.BAD_MSG_DESCRIPTION.get( result.error_code, From b8341a9869498afbee8a24af8508f673a87b3156 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Mar 2019 11:34:47 +0100 Subject: [PATCH 6/7] Remove delete_messages limitations --- pyrogram/client/methods/messages/delete_messages.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py index d1835ad7..bbd838ee 100644 --- a/pyrogram/client/methods/messages/delete_messages.py +++ b/pyrogram/client/methods/messages/delete_messages.py @@ -31,14 +31,6 @@ class DeleteMessages(BaseClient): ) -> bool: """Use this method to delete messages, including service messages. - Deleting messages have the following limitations: - - - A message can only be deleted if it was sent less than 48 hours ago. - - Users can delete outgoing messages in groups and supergroups. - - Users granted *can_post_messages* permissions can delete outgoing messages in channels. - - If the user is an administrator of a group, it can delete any message there. - - If the user has *can_delete_messages* permission in a supergroup or a channel, it can delete any message there. - Args: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. From f4cb31d7b86f8e7d13959cf9465b8908f84bb07b Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 25 Mar 2019 11:34:58 +0100 Subject: [PATCH 7/7] Add missing methods in docs --- docs/source/pyrogram/Client.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/source/pyrogram/Client.rst b/docs/source/pyrogram/Client.rst index b27f0397..dcf8bb79 100644 --- a/docs/source/pyrogram/Client.rst +++ b/docs/source/pyrogram/Client.rst @@ -31,6 +31,7 @@ Decorators on_message on_callback_query + on_inline_query on_deleted_messages on_user_status on_disconnect @@ -56,6 +57,7 @@ Messages send_location send_venue send_contact + send_cached_media send_chat_action edit_message_text edit_message_caption @@ -67,6 +69,7 @@ Messages iter_history send_poll vote_poll + close_poll retract_vote download_media @@ -97,6 +100,8 @@ Chats iter_chat_members get_dialogs iter_dialogs + restrict_chat + update_chat_username Users ----- @@ -109,6 +114,7 @@ Users get_user_profile_photos set_user_profile_photo delete_user_profile_photos + update_username Contacts -------- @@ -139,6 +145,7 @@ Bots get_inline_bot_results send_inline_bot_result answer_callback_query + answer_inline_query request_callback_answer send_game set_game_score