From 5be5446a777fb7d7f6b1657f130d28cf290b1c71 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 13:58:57 +0100 Subject: [PATCH 01/15] Update restrict_chat_member with new permissions --- .../methods/chats/restrict_chat_member.py | 60 +++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py index f3e43df3..f585a1b0 100644 --- a/pyrogram/client/methods/chats/restrict_chat_member.py +++ b/pyrogram/client/methods/chats/restrict_chat_member.py @@ -23,14 +23,20 @@ from ...ext import BaseClient class RestrictChatMember(BaseClient): - def restrict_chat_member(self, - chat_id: Union[int, str], - user_id: Union[int, str], - until_date: int = 0, - can_send_messages: bool = False, - can_send_media_messages: bool = False, - can_send_other_messages: bool = False, - can_add_web_page_previews: bool = False) -> bool: + def restrict_chat_member( + self, + chat_id: Union[int, str], + user_id: Union[int, str], + until_date: int = 0, + can_send_messages: bool = False, + can_send_media_messages: bool = False, + can_send_other_messages: bool = False, + can_add_web_page_previews: bool = False, + can_send_polls: bool = False, + can_change_info: bool = False, + can_invite_users: bool = False, + can_pin_messages: bool = False, + ) -> bool: """Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. @@ -60,8 +66,19 @@ class RestrictChatMember(BaseClient): implies can_send_media_messages. can_add_web_page_previews (``bool``, *optional*): - Pass True, if the user may add web page previews to their messages, implies can_send_media_messages + Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. + can_send_polls (``bool``, *optional*): + Pass True, if the user can send polls, implies can_send_media_messages. + + can_change_info (``bool``, *optional*): + Pass True, if the user can change the chat title, photo and other settings. + + can_invite_users (``bool``, *optional*): + Pass True, if the user can invite new users to the chat. + + can_pin_messages (``bool``, *optional*): + Pass True, if the user can pin messages. Returns: True on success. @@ -75,6 +92,10 @@ class RestrictChatMember(BaseClient): send_games = True send_inline = True embed_links = True + send_polls = True + change_info = True + invite_users = True + pin_messages = True if can_send_messages: send_messages = None @@ -84,6 +105,7 @@ class RestrictChatMember(BaseClient): send_media = None if can_send_other_messages: + send_messages = None send_media = None send_stickers = None send_gifs = None @@ -91,9 +113,23 @@ class RestrictChatMember(BaseClient): send_inline = None if can_add_web_page_previews: + send_messages = None send_media = None embed_links = None + if can_send_polls: + send_messages = None + send_polls = None + + if can_change_info: + change_info = None + + if can_invite_users: + invite_users = None + + if can_pin_messages: + pin_messages = None + self.send( functions.channels.EditBanned( channel=self.resolve_peer(chat_id), @@ -106,7 +142,11 @@ class RestrictChatMember(BaseClient): send_gifs=send_gifs, send_games=send_games, send_inline=send_inline, - embed_links=embed_links + embed_links=embed_links, + send_polls=send_polls, + change_info=change_info, + invite_users=invite_users, + pin_messages=pin_messages ) ) ) From 6d0396441807f0bad4e4a130ea375e00ffa8eb29 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:04:35 +0100 Subject: [PATCH 02/15] Add CHAT_NOT_MODIFIED error --- compiler/error/source/400_BAD_REQUEST.tsv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/error/source/400_BAD_REQUEST.tsv b/compiler/error/source/400_BAD_REQUEST.tsv index 0b9804a7..a2bbd345 100644 --- a/compiler/error/source/400_BAD_REQUEST.tsv +++ b/compiler/error/source/400_BAD_REQUEST.tsv @@ -92,4 +92,5 @@ USERNAME_NOT_MODIFIED The username was not modified CALL_ALREADY_ACCEPTED The call is already accepted CALL_ALREADY_DECLINED The call is already declined PHOTO_EXT_INVALID The photo extension is invalid -EXTERNAL_URL_INVALID The external media URL is invalid \ No newline at end of file +EXTERNAL_URL_INVALID The external media URL is invalid +CHAT_NOT_MODIFIED The chat settings were not modified \ No newline at end of file From b01caf10a9c60235671d30d3fc99465803ef306a Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:47:39 +0100 Subject: [PATCH 03/15] Rename default_permissions to just permissions --- pyrogram/client/types/user_and_chats/chat.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index 96b80bc4..db15db58 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -16,6 +16,8 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from typing import Union + import pyrogram from pyrogram.api import types from .chat_permissions import ChatPermissions @@ -73,6 +75,9 @@ class Chat(PyrogramType): restriction_reason (``str``, *optional*): The reason why this chat might be unavailable to some users. + + permissions (:obj:`ChatPermissions ` *optional*): + Information about the chat default permissions. """ def __init__(self, @@ -92,7 +97,7 @@ class Chat(PyrogramType): can_set_sticker_set: bool = None, members_count: int = None, restriction_reason: str = None, - default_permissions: "pyrogram.ChatPermissions" = None): + permissions: "pyrogram.ChatPermissions" = None): super().__init__(client) self.id = id @@ -109,7 +114,7 @@ class Chat(PyrogramType): self.can_set_sticker_set = can_set_sticker_set self.members_count = members_count self.restriction_reason = restriction_reason - self.default_permissions = default_permissions + self.permissions = permissions @staticmethod def _parse_user_chat(client, user: types.User) -> "Chat": @@ -131,7 +136,7 @@ class Chat(PyrogramType): type="group", title=chat.title, photo=ChatPhoto._parse(client, getattr(chat, "photo", None)), - default_permissions=ChatPermissions._parse(chat.default_banned_rights), + permissions=ChatPermissions._parse(chat.default_banned_rights), client=client ) @@ -144,7 +149,7 @@ class Chat(PyrogramType): username=getattr(channel, "username", None), photo=ChatPhoto._parse(client, getattr(channel, "photo", None)), restriction_reason=getattr(channel, "restriction_reason", None), - default_permissions=ChatPermissions._parse(channel.default_banned_rights), + permissions=ChatPermissions._parse(channel.default_banned_rights), client=client ) @@ -205,9 +210,7 @@ class Chat(PyrogramType): return parsed_chat @staticmethod - def _parse_chat(client, chat): - # A wrapper around each entity parser: User, Chat and Channel. - # Currently unused, might become useful in future. + def _parse_chat(client, chat: Union[types.Chat, types.User, types.Channel]) -> "Chat": if isinstance(chat, types.Chat): return Chat._parse_chat_chat(client, chat) elif isinstance(chat, types.User): From 0c8b5f02fcf34a9baf750be7169f229d87c5dbcf Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:48:30 +0100 Subject: [PATCH 04/15] Make restrict_chat_member return Chat instead of a simple boolean --- .../client/methods/chats/restrict_chat_member.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py index f585a1b0..f4545cb1 100644 --- a/pyrogram/client/methods/chats/restrict_chat_member.py +++ b/pyrogram/client/methods/chats/restrict_chat_member.py @@ -20,6 +20,7 @@ from typing import Union from pyrogram.api import functions, types from ...ext import BaseClient +from ...types.user_and_chats import Chat class RestrictChatMember(BaseClient): @@ -35,8 +36,8 @@ class RestrictChatMember(BaseClient): can_send_polls: bool = False, can_change_info: bool = False, can_invite_users: bool = False, - can_pin_messages: bool = False, - ) -> bool: + can_pin_messages: bool = False + ) -> Chat: """Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. @@ -79,8 +80,9 @@ class RestrictChatMember(BaseClient): can_pin_messages (``bool``, *optional*): Pass True, if the user can pin messages. + Returns: - True on success. + On success, a :obj:`Chat ` object is returned. Raises: :class:`Error ` in case of a Telegram RPC error. @@ -130,7 +132,7 @@ class RestrictChatMember(BaseClient): if can_pin_messages: pin_messages = None - self.send( + r = self.send( functions.channels.EditBanned( channel=self.resolve_peer(chat_id), user_id=self.resolve_peer(user_id), @@ -151,4 +153,4 @@ class RestrictChatMember(BaseClient): ) ) - return True + return Chat._parse_chat(self, r.chats[0]) From ad42b4c236d154e8fe0f9ac7fb836e9fea5a07dc Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:48:55 +0100 Subject: [PATCH 05/15] Add restrict_chat method --- pyrogram/client/methods/chats/__init__.py | 4 +- .../client/methods/chats/restrict_chat.py | 143 ++++++++++++++++++ 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 pyrogram/client/methods/chats/restrict_chat.py diff --git a/pyrogram/client/methods/chats/__init__.py b/pyrogram/client/methods/chats/__init__.py index 961038a8..c708453f 100644 --- a/pyrogram/client/methods/chats/__init__.py +++ b/pyrogram/client/methods/chats/__init__.py @@ -31,6 +31,7 @@ from .kick_chat_member import KickChatMember from .leave_chat import LeaveChat from .pin_chat_message import PinChatMessage from .promote_chat_member import PromoteChatMember +from .restrict_chat import RestrictChat from .restrict_chat_member import RestrictChatMember from .set_chat_description import SetChatDescription from .set_chat_photo import SetChatPhoto @@ -62,6 +63,7 @@ class Chats( GetChatPreview, IterDialogs, IterChatMembers, - UpdateChatUsername + UpdateChatUsername, + RestrictChat ): pass diff --git a/pyrogram/client/methods/chats/restrict_chat.py b/pyrogram/client/methods/chats/restrict_chat.py new file mode 100644 index 00000000..502d9566 --- /dev/null +++ b/pyrogram/client/methods/chats/restrict_chat.py @@ -0,0 +1,143 @@ +# 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 typing import Union + +from pyrogram.api import functions, types +from ...ext import BaseClient +from ...types.user_and_chats import Chat + + +class RestrictChat(BaseClient): + def restrict_chat( + self, + chat_id: Union[int, str], + can_send_messages: bool = False, + can_send_media_messages: bool = False, + can_send_other_messages: bool = False, + can_add_web_page_previews: bool = False, + can_send_polls: bool = False, + can_change_info: bool = False, + can_invite_users: bool = False, + can_pin_messages: bool = False + ) -> Chat: + """Use this method to restrict a chat. + Pass True for all boolean parameters to lift restrictions from a chat. + + Args: + chat_id (``int`` | ``str``): + Unique identifier (int) or username (str) of the target chat. + + can_send_messages (``bool``, *optional*): + Pass True, if the user can send text messages, contacts, locations and venues. + + can_send_media_messages (``bool``, *optional*): + Pass True, if the user can send audios, documents, photos, videos, video notes and voice notes, + implies can_send_messages. + + can_send_other_messages (``bool``, *optional*): + Pass True, if the user can send animations, games, stickers and use inline bots, + implies can_send_media_messages. + + can_add_web_page_previews (``bool``, *optional*): + Pass True, if the user may add web page previews to their messages, implies can_send_media_messages. + + can_send_polls (``bool``, *optional*): + Pass True, if the user can send polls, implies can_send_media_messages. + + can_change_info (``bool``, *optional*): + Pass True, if the user can change the chat title, photo and other settings. + + can_invite_users (``bool``, *optional*): + Pass True, if the user can invite new users to the chat. + + can_pin_messages (``bool``, *optional*): + Pass True, if the user can pin messages. + + Returns: + On success, a :obj:`Chat ` object is returned. + + Raises: + :class:`Error ` in case of a Telegram RPC error. + """ + send_messages = True + send_media = True + send_stickers = True + send_gifs = True + send_games = True + send_inline = True + embed_links = True + send_polls = True + change_info = True + invite_users = True + pin_messages = True + + if can_send_messages: + send_messages = None + + if can_send_media_messages: + send_messages = None + send_media = None + + if can_send_other_messages: + send_messages = None + send_media = None + send_stickers = None + send_gifs = None + send_games = None + send_inline = None + + if can_add_web_page_previews: + send_messages = None + send_media = None + embed_links = None + + if can_send_polls: + send_messages = None + send_polls = None + + if can_change_info: + change_info = None + + if can_invite_users: + invite_users = None + + if can_pin_messages: + pin_messages = None + + r = self.send( + functions.messages.EditChatDefaultBannedRights( + peer=self.resolve_peer(chat_id), + banned_rights=types.ChatBannedRights( + until_date=0, + send_messages=send_messages, + send_media=send_media, + send_stickers=send_stickers, + send_gifs=send_gifs, + send_games=send_games, + send_inline=send_inline, + embed_links=embed_links, + send_polls=send_polls, + change_info=change_info, + invite_users=invite_users, + pin_messages=pin_messages + ) + ) + ) + + return Chat._parse_chat(self, r.chats[0]) From f7b864f320d66d03f70579986c28c488fe2ef49d Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:51:23 +0100 Subject: [PATCH 06/15] Update README.rst --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 50e848db..2bb0725b 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 91 on top of `MTProto 2.0`_. +- **Updated**, to the latest Telegram API version, currently Layer 95 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%2091-eda738.svg?longCache=true&colorA=262b30 +.. |schema| image:: https://img.shields.io/badge/schema-layer%2095-eda738.svg?longCache=true&colorA=262b30 :target: compiler/api/source/main_api.tl :alt: Schema Layer From 3a1c02738da76171da34cc14b19db3c11f7242e3 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:54:40 +0100 Subject: [PATCH 07/15] Update doc sources --- docs/source/index.rst | 4 ++-- docs/source/start/Installation.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 4d913d23..6a333d6d 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 91 on top of `MTProto 2.0`_. +- **Updated**, to the latest Telegram API version, currently Layer 95 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/Installation.rst b/docs/source/start/Installation.rst index c5c6cb31..6a6ceef8 100644 --- a/docs/source/start/Installation.rst +++ b/docs/source/start/Installation.rst @@ -82,7 +82,7 @@ If no error shows up you are good to go. >>> import pyrogram >>> pyrogram.__version__ - '0.11.0' + '0.12.0' .. _TgCrypto: https://docs.pyrogram.ml/resources/TgCrypto .. _develop: http://github.com/pyrogram/pyrogram From 36635625f344629523bcec29fc1bb87b3e6a04bc Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 13 Mar 2019 14:55:02 +0100 Subject: [PATCH 08/15] Update develop version --- pyrogram/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index bad806d5..9ec7fc9f 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -29,7 +29,7 @@ __copyright__ = "Copyright (C) 2017-2019 Dan Tès Date: Sat, 16 Mar 2019 15:30:55 +0100 Subject: [PATCH 09/15] Add __slots__ to Telegram TL types --- compiler/api/compiler.py | 4 ++- compiler/api/template/mtproto.txt | 3 ++ pyrogram/api/core/object.py | 47 +++++++++++++------------------ 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index 9e671e80..c9ea5f34 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -456,7 +456,9 @@ def start(): fields=fields, read_types=read_types, write_types=write_types, - return_arguments=", ".join([i[0] for i in sorted_args if i != ("flags", "#")]) + return_arguments=", ".join([i[0] for i in sorted_args if i != ("flags", "#")]), + slots=", ".join(['"{}"'.format(i[0]) for i in sorted_args if i != ("flags", "#")]), + qualname="{}{}".format("{}.".format(c.namespace) if c.namespace else "", c.name) ) ) diff --git a/compiler/api/template/mtproto.txt b/compiler/api/template/mtproto.txt index 9a65b52d..c63525d6 100644 --- a/compiler/api/template/mtproto.txt +++ b/compiler/api/template/mtproto.txt @@ -9,7 +9,10 @@ class {class_name}(Object): """{docstring_args} """ + __slots__ = [{slots}] + ID = {object_id} + QUALNAME = "{qualname}" def __init__(self{arguments}): {fields} diff --git a/pyrogram/api/core/object.py b/pyrogram/api/core/object.py index 1a3cb388..8f8015fb 100644 --- a/pyrogram/api/core/object.py +++ b/pyrogram/api/core/object.py @@ -19,14 +19,16 @@ from collections import OrderedDict from datetime import datetime from io import BytesIO -from json import JSONEncoder, dumps - -from ..all import objects +from json import dumps class Object: all = {} + __slots__ = [] + + QUALNAME = "Base" + @staticmethod def read(b: BytesIO, *args): return Object.all[int.from_bytes(b.read(4), "little")].read(b, *args) @@ -35,7 +37,7 @@ class Object: pass def __str__(self) -> str: - return dumps(self, cls=Encoder, indent=4) + return dumps(self, indent=4, default=default) def __bool__(self) -> bool: return True @@ -62,29 +64,18 @@ def remove_none(obj): return obj -class Encoder(JSONEncoder): - def default(self, o: Object): - try: - content = o.__dict__ - except AttributeError: - if isinstance(o, datetime): - return o.strftime("%d-%b-%Y %H:%M:%S") - else: - return repr(o) +def default(o: "Object"): + try: + content = {i: getattr(o, i) for i in o.__slots__} - name = o.__class__.__name__ - o = objects.get(getattr(o, "ID", None), None) - - if o is not None: - if o.startswith("pyrogram.client"): - r = remove_none(OrderedDict([("_", "pyrogram:" + name)] + [i for i in content.items()])) - r.pop("_client", None) - - return r - else: - return OrderedDict( - [("_", o.replace("pyrogram.api.types.", "telegram:"))] - + [i for i in content.items()] - ) + return remove_none( + OrderedDict( + [("_", o.QUALNAME)] + + [i for i in content.items()] + ) + ) + except AttributeError: + if isinstance(o, datetime): + return o.strftime("%d-%b-%Y %H:%M:%S") else: - return None + return repr(o) From c611944d458599fbc383b28778cad3bc46a08685 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 15:39:35 +0100 Subject: [PATCH 10/15] Don't ensure ascii when printing objects This will break in case of non-utf8 terminals --- pyrogram/api/core/object.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/api/core/object.py b/pyrogram/api/core/object.py index 8f8015fb..d4715d3c 100644 --- a/pyrogram/api/core/object.py +++ b/pyrogram/api/core/object.py @@ -37,7 +37,7 @@ class Object: pass def __str__(self) -> str: - return dumps(self, indent=4, default=default) + return dumps(self, indent=4, default=default, ensure_ascii=False) def __bool__(self) -> bool: return True From ef9ed315896965d5095c768a80dc0c25f15c1950 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 15:45:35 +0100 Subject: [PATCH 11/15] Add __slots__ to PyrogramType and Update types --- pyrogram/client/types/pyrogram_type.py | 20 +++++++++----------- pyrogram/client/types/update.py | 2 ++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyrogram/client/types/pyrogram_type.py b/pyrogram/client/types/pyrogram_type.py index 3708cdc5..d746e6a7 100644 --- a/pyrogram/client/types/pyrogram_type.py +++ b/pyrogram/client/types/pyrogram_type.py @@ -17,15 +17,17 @@ # along with Pyrogram. If not, see . from collections import OrderedDict -from json import dumps, JSONEncoder +from json import dumps class PyrogramType: + __slots__ = ["_client"] + def __init__(self, client): self._client = client def __str__(self): - return dumps(self, cls=Encoder, indent=4) + return dumps(self, indent=4, default=default, ensure_ascii=False) def __getitem__(self, item): return getattr(self, item) @@ -40,15 +42,9 @@ def remove_none(obj): return obj -class Encoder(JSONEncoder): - def default(self, o: PyrogramType): - try: - content = { - i: getattr(o, i) - for i in filter(lambda x: not x.startswith("_"), o.__dict__) - } - except AttributeError: - return repr(o) +def default(o: PyrogramType): + try: + content = {i: getattr(o, i) for i in o.__slots__} return remove_none( OrderedDict( @@ -56,3 +52,5 @@ class Encoder(JSONEncoder): + [i for i in content.items()] ) ) + except AttributeError: + return repr(o) diff --git a/pyrogram/client/types/update.py b/pyrogram/client/types/update.py index 2ec22f5a..48179ac0 100644 --- a/pyrogram/client/types/update.py +++ b/pyrogram/client/types/update.py @@ -26,6 +26,8 @@ class ContinuePropagation(StopIteration): class Update: + __slots__ = [] + def stop_propagation(self): raise StopPropagation From e0f1f6aaeb6ffb795cf54657d020ca683d9386af Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 16:15:27 +0100 Subject: [PATCH 12/15] Add __slots__ to every single Pyrogram types --- pyrogram/client/types/bots/callback_game.py | 2 + pyrogram/client/types/bots/callback_query.py | 24 ++-- pyrogram/client/types/bots/force_reply.py | 8 +- pyrogram/client/types/bots/game_high_score.py | 16 ++- .../client/types/bots/game_high_scores.py | 14 +- .../types/bots/inline_keyboard_button.py | 20 ++- .../types/bots/inline_keyboard_markup.py | 8 +- pyrogram/client/types/bots/keyboard_button.py | 12 +- .../types/bots/reply_keyboard_markup.py | 14 +- .../types/bots/reply_keyboard_remove.py | 8 +- .../client/types/input_media/input_media.py | 12 +- .../input_media/input_media_animation.py | 20 +-- .../types/input_media/input_media_audio.py | 20 +-- .../types/input_media/input_media_document.py | 14 +- .../types/input_media/input_media_photo.py | 12 +- .../types/input_media/input_media_video.py | 22 +-- .../types/input_media/input_phone_contact.py | 12 +- .../types/messages_and_media/animation.py | 28 ++-- .../client/types/messages_and_media/audio.py | 28 ++-- .../types/messages_and_media/contact.py | 20 +-- .../types/messages_and_media/document.py | 22 +-- .../client/types/messages_and_media/game.py | 22 +-- .../types/messages_and_media/location.py | 14 +- .../types/messages_and_media/message.py | 133 ++++++++++-------- .../messages_and_media/message_entity.py | 20 +-- .../types/messages_and_media/messages.py | 14 +- .../client/types/messages_and_media/photo.py | 16 ++- .../types/messages_and_media/photo_size.py | 18 ++- .../client/types/messages_and_media/poll.py | 22 +-- .../types/messages_and_media/poll_option.py | 16 ++- .../types/messages_and_media/sticker.py | 32 +++-- .../messages_and_media/user_profile_photos.py | 14 +- .../client/types/messages_and_media/venue.py | 20 +-- .../client/types/messages_and_media/video.py | 28 ++-- .../types/messages_and_media/video_note.py | 24 ++-- .../client/types/messages_and_media/voice.py | 22 +-- pyrogram/client/types/user_and_chats/chat.py | 44 +++--- .../types/user_and_chats/chat_member.py | 24 ++-- .../types/user_and_chats/chat_members.py | 15 +- .../types/user_and_chats/chat_permissions.py | 7 + .../client/types/user_and_chats/chat_photo.py | 14 +- .../types/user_and_chats/chat_preview.py | 20 +-- .../client/types/user_and_chats/dialog.py | 22 +-- .../client/types/user_and_chats/dialogs.py | 14 +- pyrogram/client/types/user_and_chats/user.py | 41 +++--- .../types/user_and_chats/user_status.py | 26 ++-- 46 files changed, 592 insertions(+), 386 deletions(-) diff --git a/pyrogram/client/types/bots/callback_game.py b/pyrogram/client/types/bots/callback_game.py index be026360..fc2d9884 100644 --- a/pyrogram/client/types/bots/callback_game.py +++ b/pyrogram/client/types/bots/callback_game.py @@ -25,5 +25,7 @@ class CallbackGame(PyrogramType): Use BotFather to set up your game. """ + __slots__ = [] + def __init__(self): super().__init__(None) diff --git a/pyrogram/client/types/bots/callback_query.py b/pyrogram/client/types/bots/callback_query.py index c2558844..a7a9ad53 100644 --- a/pyrogram/client/types/bots/callback_query.py +++ b/pyrogram/client/types/bots/callback_query.py @@ -58,16 +58,20 @@ class CallbackQuery(PyrogramType, Update): """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - id: str, - from_user: User, - chat_instance: str, - message: "pyrogram.Message" = None, - inline_message_id: str = None, - data: bytes = None, - game_short_name: str = None): + __slots__ = ["id", "from_user", "chat_instance", "message", "inline_message_id", "data", "game_short_name"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: str, + from_user: User, + chat_instance: str, + message: "pyrogram.Message" = None, + inline_message_id: str = None, + data: bytes = None, + game_short_name: str = None + ): super().__init__(client) self.id = id diff --git a/pyrogram/client/types/bots/force_reply.py b/pyrogram/client/types/bots/force_reply.py index 2e5c2f42..7838ee88 100644 --- a/pyrogram/client/types/bots/force_reply.py +++ b/pyrogram/client/types/bots/force_reply.py @@ -33,8 +33,12 @@ class ForceReply(PyrogramType): 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. """ - def __init__(self, - selective: bool = None): + __slots__ = ["selective"] + + def __init__( + self, + selective: bool = None + ): super().__init__(None) self.selective = selective diff --git a/pyrogram/client/types/bots/game_high_score.py b/pyrogram/client/types/bots/game_high_score.py index 0541c18c..4fc3c6f8 100644 --- a/pyrogram/client/types/bots/game_high_score.py +++ b/pyrogram/client/types/bots/game_high_score.py @@ -37,12 +37,16 @@ class GameHighScore(PyrogramType): Position in high score table for the game. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - user: User, - score: int, - position: int = None): + __slots__ = ["user", "score", "position"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + user: User, + score: int, + position: int = None + ): super().__init__(client) self.user = user diff --git a/pyrogram/client/types/bots/game_high_scores.py b/pyrogram/client/types/bots/game_high_scores.py index 1717effa..25e4af5d 100644 --- a/pyrogram/client/types/bots/game_high_scores.py +++ b/pyrogram/client/types/bots/game_high_scores.py @@ -35,11 +35,15 @@ class GameHighScores(PyrogramType): Game scores. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - game_high_scores: List[GameHighScore]): + __slots__ = ["total_count", "game_high_scores"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + game_high_scores: List[GameHighScore] + ): super().__init__(client) self.total_count = total_count diff --git a/pyrogram/client/types/bots/inline_keyboard_button.py b/pyrogram/client/types/bots/inline_keyboard_button.py index cc829cb1..505b7c87 100644 --- a/pyrogram/client/types/bots/inline_keyboard_button.py +++ b/pyrogram/client/types/bots/inline_keyboard_button.py @@ -54,13 +54,19 @@ class InlineKeyboardButton(PyrogramType): # TODO: Add callback_game and pay fields - def __init__(self, - text: str, - callback_data: bytes = None, - url: str = None, - switch_inline_query: str = None, - switch_inline_query_current_chat: str = None, - callback_game: CallbackGame = None): + __slots__ = [ + "text", "url", "callback_data", "switch_inline_query", "switch_inline_query_current_chat", "callback_game" + ] + + def __init__( + self, + text: str, + callback_data: bytes = None, + url: str = None, + switch_inline_query: str = None, + switch_inline_query_current_chat: str = None, + callback_game: CallbackGame = None + ): super().__init__(None) self.text = str(text) diff --git a/pyrogram/client/types/bots/inline_keyboard_markup.py b/pyrogram/client/types/bots/inline_keyboard_markup.py index f18bd605..cb5327b1 100644 --- a/pyrogram/client/types/bots/inline_keyboard_markup.py +++ b/pyrogram/client/types/bots/inline_keyboard_markup.py @@ -31,8 +31,12 @@ class InlineKeyboardMarkup(PyrogramType): List of button rows, each represented by a List of InlineKeyboardButton objects. """ - def __init__(self, - inline_keyboard: List[List[InlineKeyboardButton]]): + __slots__ = ["inline_keyboard"] + + def __init__( + self, + inline_keyboard: List[List[InlineKeyboardButton]] + ): super().__init__(None) self.inline_keyboard = inline_keyboard diff --git a/pyrogram/client/types/bots/keyboard_button.py b/pyrogram/client/types/bots/keyboard_button.py index 3c7c2bd6..dc4ed1e7 100644 --- a/pyrogram/client/types/bots/keyboard_button.py +++ b/pyrogram/client/types/bots/keyboard_button.py @@ -40,10 +40,14 @@ class KeyboardButton(PyrogramType): Available in private chats only. """ - def __init__(self, - text: str, - request_contact: bool = None, - request_location: bool = None): + __slots__ = ["text", "request_contact", "request_location"] + + def __init__( + self, + text: str, + request_contact: bool = None, + request_location: bool = None + ): super().__init__(None) self.text = str(text) diff --git a/pyrogram/client/types/bots/reply_keyboard_markup.py b/pyrogram/client/types/bots/reply_keyboard_markup.py index afae236d..229899d0 100644 --- a/pyrogram/client/types/bots/reply_keyboard_markup.py +++ b/pyrogram/client/types/bots/reply_keyboard_markup.py @@ -49,11 +49,15 @@ class ReplyKeyboardMarkup(PyrogramType): select the new language. Other users in the group don't see the keyboard. """ - def __init__(self, - keyboard: List[List[Union[KeyboardButton, str]]], - resize_keyboard: bool = None, - one_time_keyboard: bool = None, - selective: bool = None): + __slots__ = ["keyboard", "resize_keyboard", "one_time_keyboard", "selective"] + + def __init__( + self, + keyboard: List[List[Union[KeyboardButton, str]]], + resize_keyboard: bool = None, + one_time_keyboard: bool = None, + selective: bool = None + ): super().__init__(None) self.keyboard = keyboard diff --git a/pyrogram/client/types/bots/reply_keyboard_remove.py b/pyrogram/client/types/bots/reply_keyboard_remove.py index 5b67fbb4..2fb5fe19 100644 --- a/pyrogram/client/types/bots/reply_keyboard_remove.py +++ b/pyrogram/client/types/bots/reply_keyboard_remove.py @@ -35,8 +35,12 @@ class ReplyKeyboardRemove(PyrogramType): keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet. """ - def __init__(self, - selective: bool = None): + __slots__ = ["selective"] + + def __init__( + self, + selective: bool = None + ): super().__init__(None) self.selective = selective diff --git a/pyrogram/client/types/input_media/input_media.py b/pyrogram/client/types/input_media/input_media.py index f55d8aa0..677d4918 100644 --- a/pyrogram/client/types/input_media/input_media.py +++ b/pyrogram/client/types/input_media/input_media.py @@ -18,10 +18,14 @@ class InputMedia: - def __init__(self, - media: str, - caption: str, - parse_mode: str): + __slots__ = ["media", "caption", "parse_mode"] + + def __init__( + self, + media: str, + caption: str, + parse_mode: str + ): self.media = media self.caption = caption self.parse_mode = parse_mode diff --git a/pyrogram/client/types/input_media/input_media_animation.py b/pyrogram/client/types/input_media/input_media_animation.py index af0c2b2a..20debb19 100644 --- a/pyrogram/client/types/input_media/input_media_animation.py +++ b/pyrogram/client/types/input_media/input_media_animation.py @@ -52,14 +52,18 @@ class InputMediaAnimation(InputMedia): Animation duration. """ - def __init__(self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - width: int = 0, - height: int = 0, - duration: int = 0): + __slots__ = ["thumb", "width", "height", "duration"] + + def __init__( + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + width: int = 0, + height: int = 0, + duration: int = 0 + ): super().__init__(media, caption, parse_mode) self.thumb = thumb diff --git a/pyrogram/client/types/input_media/input_media_audio.py b/pyrogram/client/types/input_media/input_media_audio.py index a2dc18db..2709a409 100644 --- a/pyrogram/client/types/input_media/input_media_audio.py +++ b/pyrogram/client/types/input_media/input_media_audio.py @@ -53,14 +53,18 @@ class InputMediaAudio(InputMedia): Title of the audio """ - def __init__(self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - duration: int = 0, - performer: int = "", - title: str = ""): + __slots__ = ["thumb", "duration", "performer", "title"] + + def __init__( + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + duration: int = 0, + performer: int = "", + title: str = "" + ): super().__init__(media, caption, parse_mode) self.thumb = thumb diff --git a/pyrogram/client/types/input_media/input_media_document.py b/pyrogram/client/types/input_media/input_media_document.py index 25e17d0f..2c0c628d 100644 --- a/pyrogram/client/types/input_media/input_media_document.py +++ b/pyrogram/client/types/input_media/input_media_document.py @@ -43,11 +43,15 @@ class InputMediaDocument(InputMedia): Defaults to Markdown. """ - def __init__(self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = ""): + __slots__ = ["thumb"] + + def __init__( + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "" + ): super().__init__(media, caption, parse_mode) self.thumb = thumb diff --git a/pyrogram/client/types/input_media/input_media_photo.py b/pyrogram/client/types/input_media/input_media_photo.py index 5917fbf0..5618b843 100644 --- a/pyrogram/client/types/input_media/input_media_photo.py +++ b/pyrogram/client/types/input_media/input_media_photo.py @@ -39,8 +39,12 @@ class InputMediaPhoto(InputMedia): Defaults to Markdown. """ - def __init__(self, - media: str, - caption: str = "", - parse_mode: str = ""): + __slots__ = [] + + def __init__( + self, + media: str, + caption: str = "", + parse_mode: str = "" + ): super().__init__(media, caption, parse_mode) diff --git a/pyrogram/client/types/input_media/input_media_video.py b/pyrogram/client/types/input_media/input_media_video.py index 6fa7936e..b55a9438 100644 --- a/pyrogram/client/types/input_media/input_media_video.py +++ b/pyrogram/client/types/input_media/input_media_video.py @@ -57,15 +57,19 @@ class InputMediaVideo(InputMedia): Pass True, if the uploaded video is suitable for streaming. """ - def __init__(self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - width: int = 0, - height: int = 0, - duration: int = 0, - supports_streaming: bool = True): + __slots__ = ["thumb", "width", "height", "duration", "supports_streaming"] + + def __init__( + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + width: int = 0, + height: int = 0, + duration: int = 0, + supports_streaming: bool = True + ): super().__init__(media, caption, parse_mode) self.thumb = thumb diff --git a/pyrogram/client/types/input_media/input_phone_contact.py b/pyrogram/client/types/input_media/input_phone_contact.py index 1a89759a..340b335f 100644 --- a/pyrogram/client/types/input_media/input_phone_contact.py +++ b/pyrogram/client/types/input_media/input_phone_contact.py @@ -35,10 +35,14 @@ class InputPhoneContact: Contact's last name """ - def __init__(self, - phone: str, - first_name: str, - last_name: str = ""): + __slots__ = [] + + def __init__( + self, + phone: str, + first_name: str, + last_name: str = "" + ): pass def __new__(cls, diff --git a/pyrogram/client/types/messages_and_media/animation.py b/pyrogram/client/types/messages_and_media/animation.py index 9f3ba886..978c88c9 100644 --- a/pyrogram/client/types/messages_and_media/animation.py +++ b/pyrogram/client/types/messages_and_media/animation.py @@ -57,18 +57,22 @@ class Animation(PyrogramType): Date the animation was sent in Unix time. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - duration: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None): + __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "duration"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + duration: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/audio.py b/pyrogram/client/types/messages_and_media/audio.py index 9c5698f1..334e022e 100644 --- a/pyrogram/client/types/messages_and_media/audio.py +++ b/pyrogram/client/types/messages_and_media/audio.py @@ -57,18 +57,22 @@ class Audio(PyrogramType): Title of the audio as defined by sender or by audio tags. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - duration: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None, - performer: str = None, - title: str = None): + __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "duration", "performer", "title"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + duration: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None, + performer: str = None, + title: str = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/contact.py b/pyrogram/client/types/messages_and_media/contact.py index 51acb59f..0a897c05 100644 --- a/pyrogram/client/types/messages_and_media/contact.py +++ b/pyrogram/client/types/messages_and_media/contact.py @@ -42,14 +42,18 @@ class Contact(PyrogramType): Additional data about the contact in the form of a vCard. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - phone_number: str, - first_name: str, - last_name: str = None, - user_id: int = None, - vcard: str = None): + __slots__ = ["phone_number", "first_name", "last_name", "user_id", "vcard"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + phone_number: str, + first_name: str, + last_name: str = None, + user_id: int = None, + vcard: str = None + ): super().__init__(client) self.phone_number = phone_number diff --git a/pyrogram/client/types/messages_and_media/document.py b/pyrogram/client/types/messages_and_media/document.py index 5cd01a92..b3f5b586 100644 --- a/pyrogram/client/types/messages_and_media/document.py +++ b/pyrogram/client/types/messages_and_media/document.py @@ -48,15 +48,19 @@ class Document(PyrogramType): Date the document was sent in Unix time. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None): + __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/game.py b/pyrogram/client/types/messages_and_media/game.py index 01af7226..ddfa84af 100644 --- a/pyrogram/client/types/messages_and_media/game.py +++ b/pyrogram/client/types/messages_and_media/game.py @@ -48,15 +48,19 @@ class Game(PyrogramType): Upload via BotFather. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - title: str, - short_name: str, - description: str, - photo: Photo, - animation: Animation = None): + __slots__ = ["id", "title", "short_name", "description", "photo", "animation"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + title: str, + short_name: str, + description: str, + photo: Photo, + animation: Animation = None + ): super().__init__(client) self.id = id diff --git a/pyrogram/client/types/messages_and_media/location.py b/pyrogram/client/types/messages_and_media/location.py index 64acdbf5..0d2e6c43 100644 --- a/pyrogram/client/types/messages_and_media/location.py +++ b/pyrogram/client/types/messages_and_media/location.py @@ -33,11 +33,15 @@ class Location(PyrogramType): Latitude as defined by sender. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - longitude: float, - latitude: float): + __slots__ = ["longitude", "latitude"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + longitude: float, + latitude: float + ): super().__init__(client) self.longitude = longitude diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index badd3689..405c26d9 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -234,65 +234,80 @@ class Message(PyrogramType, Update): # TODO: Add game missing field. Also invoice, successful_payment, connected_website - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - message_id: int, - date: int = None, - chat: Chat = None, - from_user: User = None, - forward_from: User = None, - forward_from_chat: Chat = None, - forward_from_message_id: int = None, - forward_signature: str = None, - forward_date: int = None, - reply_to_message: "Message" = None, - mentioned: bool = None, - empty: bool = None, - service: bool = None, - media: bool = None, - edit_date: int = None, - media_group_id: str = None, - author_signature: str = None, - text: str = None, - entities: List["pyrogram.MessageEntity"] = None, - caption_entities: List["pyrogram.MessageEntity"] = None, - audio: "pyrogram.Audio" = None, - document: "pyrogram.Document" = None, - photo: "pyrogram.Photo" = None, - sticker: "pyrogram.Sticker" = None, - animation: "pyrogram.Animation" = None, - game: "pyrogram.Game" = None, - video: "pyrogram.Video" = None, - voice: "pyrogram.Voice" = None, - video_note: "pyrogram.VideoNote" = None, - caption: str = None, - contact: "pyrogram.Contact" = None, - location: "pyrogram.Location" = None, - venue: "pyrogram.Venue" = None, - web_page: bool = None, - poll: "pyrogram.Poll" = None, - new_chat_members: List[User] = None, - left_chat_member: User = None, - new_chat_title: str = None, - new_chat_photo: "pyrogram.Photo" = None, - delete_chat_photo: bool = None, - group_chat_created: bool = None, - supergroup_chat_created: bool = None, - channel_chat_created: bool = None, - migrate_to_chat_id: int = None, - migrate_from_chat_id: int = None, - pinned_message: "Message" = None, - game_high_score: int = None, - views: int = None, - via_bot: User = None, - outgoing: bool = None, - matches: List[Match] = None, - command: List[str] = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None): + __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", + "migrate_to_chat_id", "migrate_from_chat_id", "pinned_message", "game_high_score", "views", "via_bot", + "outgoing", "matches", "command", "reply_markup" + ] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + message_id: int, + date: int = None, + chat: Chat = None, + from_user: User = None, + forward_from: User = None, + forward_from_chat: Chat = None, + forward_from_message_id: int = None, + forward_signature: str = None, + forward_date: int = None, + reply_to_message: "Message" = None, + mentioned: bool = None, + empty: bool = None, + service: bool = None, + media: bool = None, + edit_date: int = None, + media_group_id: str = None, + author_signature: str = None, + text: str = None, + entities: List["pyrogram.MessageEntity"] = None, + caption_entities: List["pyrogram.MessageEntity"] = None, + audio: "pyrogram.Audio" = None, + document: "pyrogram.Document" = None, + photo: "pyrogram.Photo" = None, + sticker: "pyrogram.Sticker" = None, + animation: "pyrogram.Animation" = None, + game: "pyrogram.Game" = None, + video: "pyrogram.Video" = None, + voice: "pyrogram.Voice" = None, + video_note: "pyrogram.VideoNote" = None, + caption: str = None, + contact: "pyrogram.Contact" = None, + location: "pyrogram.Location" = None, + venue: "pyrogram.Venue" = None, + web_page: bool = None, + poll: "pyrogram.Poll" = None, + new_chat_members: List[User] = None, + left_chat_member: User = None, + new_chat_title: str = None, + new_chat_photo: "pyrogram.Photo" = None, + delete_chat_photo: bool = None, + group_chat_created: bool = None, + supergroup_chat_created: bool = None, + channel_chat_created: bool = None, + migrate_to_chat_id: int = None, + migrate_from_chat_id: int = None, + pinned_message: "Message" = None, + game_high_score: int = None, + views: int = None, + via_bot: User = None, + outgoing: bool = None, + matches: List[Match] = None, + command: List[str] = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ): super().__init__(client) self.message_id = message_id diff --git a/pyrogram/client/types/messages_and_media/message_entity.py b/pyrogram/client/types/messages_and_media/message_entity.py index 88beeb2f..fa59a5bc 100644 --- a/pyrogram/client/types/messages_and_media/message_entity.py +++ b/pyrogram/client/types/messages_and_media/message_entity.py @@ -47,6 +47,8 @@ class MessageEntity(PyrogramType): For "text_mention" only, the mentioned user. """ + __slots__ = ["type", "offset", "length", "url", "user"] + ENTITIES = { types.MessageEntityMention.ID: "mention", types.MessageEntityHashtag.ID: "hashtag", @@ -63,14 +65,16 @@ class MessageEntity(PyrogramType): types.MessageEntityPhone.ID: "phone_number" } - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - type: str, - offset: int, - length: int, - url: str = None, - user: User = None): + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + type: str, + offset: int, + length: int, + url: str = None, + user: User = None + ): super().__init__(client) self.type = type diff --git a/pyrogram/client/types/messages_and_media/messages.py b/pyrogram/client/types/messages_and_media/messages.py index d89f0bad..4a203a4e 100644 --- a/pyrogram/client/types/messages_and_media/messages.py +++ b/pyrogram/client/types/messages_and_media/messages.py @@ -37,11 +37,15 @@ class Messages(PyrogramType, Update): Requested messages. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - messages: List[Message]): + __slots__ = ["total_count", "messages"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + messages: List[Message] + ): super().__init__(client) self.total_count = total_count diff --git a/pyrogram/client/types/messages_and_media/photo.py b/pyrogram/client/types/messages_and_media/photo.py index aa2b3a26..12be919c 100644 --- a/pyrogram/client/types/messages_and_media/photo.py +++ b/pyrogram/client/types/messages_and_media/photo.py @@ -41,12 +41,16 @@ class Photo(PyrogramType): Available sizes of this photo. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - id: str, - date: int, - sizes: List[PhotoSize]): + __slots__ = ["id", "date", "sizes"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: str, + date: int, + sizes: List[PhotoSize] + ): super().__init__(client) self.id = id diff --git a/pyrogram/client/types/messages_and_media/photo_size.py b/pyrogram/client/types/messages_and_media/photo_size.py index 116b564c..03569062 100644 --- a/pyrogram/client/types/messages_and_media/photo_size.py +++ b/pyrogram/client/types/messages_and_media/photo_size.py @@ -42,13 +42,17 @@ class PhotoSize(PyrogramType): File size. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - file_size: int): + __slots__ = ["file_id", "width", "height", "file_size"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + file_size: int + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py index 72735c28..fa6372d9 100644 --- a/pyrogram/client/types/messages_and_media/poll.py +++ b/pyrogram/client/types/messages_and_media/poll.py @@ -47,15 +47,19 @@ class Poll(PyrogramType): The index of your chosen option (in case you voted already), None otherwise. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - closed: bool, - question: str, - options: List[PollOption], - total_voters: int, - option_chosen: int = None): + __slots__ = ["id", "closed", "question", "options", "total_voters", "option_chosen"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + closed: bool, + question: str, + options: List[PollOption], + total_voters: int, + option_chosen: int = None + ): super().__init__(client) self.id = id diff --git a/pyrogram/client/types/messages_and_media/poll_option.py b/pyrogram/client/types/messages_and_media/poll_option.py index 227fe74f..1c2d6f1b 100644 --- a/pyrogram/client/types/messages_and_media/poll_option.py +++ b/pyrogram/client/types/messages_and_media/poll_option.py @@ -34,12 +34,16 @@ class PollOption(PyrogramType): Unique data that identifies this option among all the other options in a poll. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - text: str, - voters: int, - data: bytes): + __slots__ = ["text", "voters", "data"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + text: str, + voters: int, + data: bytes + ): super().__init__(client) self.text = text diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py index a1ebbe32..70322577 100644 --- a/pyrogram/client/types/messages_and_media/sticker.py +++ b/pyrogram/client/types/messages_and_media/sticker.py @@ -64,19 +64,25 @@ class Sticker(PyrogramType): # TODO: Add mask position - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None, - emoji: str = None, - set_name: str = None): + __slots__ = [ + "file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "emoji", "set_name" + ] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None, + emoji: str = None, + set_name: str = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/user_profile_photos.py b/pyrogram/client/types/messages_and_media/user_profile_photos.py index 8f8525cc..770b0ec8 100644 --- a/pyrogram/client/types/messages_and_media/user_profile_photos.py +++ b/pyrogram/client/types/messages_and_media/user_profile_photos.py @@ -34,11 +34,15 @@ class UserProfilePhotos(PyrogramType): Requested profile pictures. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - photos: List[Photo]): + __slots__ = ["total_count", "photos"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + photos: List[Photo] + ): super().__init__(client) self.total_count = total_count diff --git a/pyrogram/client/types/messages_and_media/venue.py b/pyrogram/client/types/messages_and_media/venue.py index 91b3455a..5dd81093 100644 --- a/pyrogram/client/types/messages_and_media/venue.py +++ b/pyrogram/client/types/messages_and_media/venue.py @@ -44,14 +44,18 @@ class Venue(PyrogramType): """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - location: Location, - title: str, - address: str, - foursquare_id: str = None, - foursquare_type: str = None): + __slots__ = ["location", "title", "address", "foursquare_id", "foursquare_type"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + location: Location, + title: str, + address: str, + foursquare_id: str = None, + foursquare_type: str = None + ): super().__init__(client) self.location = location diff --git a/pyrogram/client/types/messages_and_media/video.py b/pyrogram/client/types/messages_and_media/video.py index 2ec9a947..39ec1455 100644 --- a/pyrogram/client/types/messages_and_media/video.py +++ b/pyrogram/client/types/messages_and_media/video.py @@ -57,18 +57,22 @@ class Video(PyrogramType): Date the video was sent in Unix time. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - duration: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None): + __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "duration"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + duration: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/video_note.py b/pyrogram/client/types/messages_and_media/video_note.py index 73bb85dc..afa4ad46 100644 --- a/pyrogram/client/types/messages_and_media/video_note.py +++ b/pyrogram/client/types/messages_and_media/video_note.py @@ -51,16 +51,20 @@ class VideoNote(PyrogramType): Date the video note was sent in Unix time. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - length: int, - duration: int, - thumb: PhotoSize = None, - mime_type: str = None, - file_size: int = None, - date: int = None): + __slots__ = ["file_id", "thumb", "mime_type", "file_size", "date", "length", "duration"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + length: int, + duration: int, + thumb: PhotoSize = None, + mime_type: str = None, + file_size: int = None, + date: int = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/messages_and_media/voice.py b/pyrogram/client/types/messages_and_media/voice.py index e6bba45b..d5028cd3 100644 --- a/pyrogram/client/types/messages_and_media/voice.py +++ b/pyrogram/client/types/messages_and_media/voice.py @@ -47,15 +47,19 @@ class Voice(PyrogramType): Date the voice was sent in Unix time. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - duration: int, - waveform: bytes = None, - mime_type: str = None, - file_size: int = None, - date: int = None): + __slots__ = ["file_id", "duration", "waveform", "mime_type", "file_size", "date"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + duration: int, + waveform: bytes = None, + mime_type: str = None, + file_size: int = None, + date: int = None + ): super().__init__(client) self.file_id = file_id diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index db15db58..81067821 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -80,24 +80,32 @@ class Chat(PyrogramType): Information about the chat default permissions. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - type: str, - title: str = None, - username: str = None, - first_name: str = None, - last_name: str = None, - photo: ChatPhoto = None, - description: str = None, - invite_link: str = None, - pinned_message=None, - sticker_set_name: str = None, - can_set_sticker_set: bool = None, - members_count: int = None, - restriction_reason: str = None, - permissions: "pyrogram.ChatPermissions" = None): + __slots__ = [ + "id", "type", "title", "username", "first_name", "last_name", "photo", "description", "invite_link", + "pinned_message", "sticker_set_name", "can_set_sticker_set", "members_count", "restriction_reason", + "permissions" + ] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + type: str, + title: str = None, + username: str = None, + first_name: str = None, + last_name: str = None, + photo: ChatPhoto = None, + description: str = None, + invite_link: str = None, + pinned_message=None, + sticker_set_name: str = None, + can_set_sticker_set: bool = None, + members_count: int = None, + restriction_reason: str = None, + permissions: "pyrogram.ChatPermissions" = None + ): super().__init__(client) self.id = id diff --git a/pyrogram/client/types/user_and_chats/chat_member.py b/pyrogram/client/types/user_and_chats/chat_member.py index 5769b3f8..07a3d190 100644 --- a/pyrogram/client/types/user_and_chats/chat_member.py +++ b/pyrogram/client/types/user_and_chats/chat_member.py @@ -51,16 +51,20 @@ class ChatMember(PyrogramType): Information about the member permissions. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - user: "pyrogram.User", - status: str, - date: int = None, - invited_by: "pyrogram.User" = None, - promoted_by: "pyrogram.User" = None, - restricted_by: "pyrogram.User" = None, - permissions: "pyrogram.ChatPermissions" = None): + __slots__ = ["user", "status", "date", "invited_by", "promoted_by", "restricted_by", "permissions"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + user: "pyrogram.User", + status: str, + date: int = None, + invited_by: "pyrogram.User" = None, + promoted_by: "pyrogram.User" = None, + restricted_by: "pyrogram.User" = None, + permissions: "pyrogram.ChatPermissions" = None + ): super().__init__(client) self.user = user diff --git a/pyrogram/client/types/user_and_chats/chat_members.py b/pyrogram/client/types/user_and_chats/chat_members.py index 39d69089..0578e04e 100644 --- a/pyrogram/client/types/user_and_chats/chat_members.py +++ b/pyrogram/client/types/user_and_chats/chat_members.py @@ -21,7 +21,6 @@ from typing import List import pyrogram from pyrogram.api import types from .chat_member import ChatMember -from .user import User from ..pyrogram_type import PyrogramType @@ -36,11 +35,15 @@ class ChatMembers(PyrogramType): Requested chat members. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - chat_members: List[ChatMember]): + __slots__ = ["total_count", "chat_members"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + chat_members: List[ChatMember] + ): super().__init__(client) self.total_count = total_count diff --git a/pyrogram/client/types/user_and_chats/chat_permissions.py b/pyrogram/client/types/user_and_chats/chat_permissions.py index a931cd7a..4a4785b5 100644 --- a/pyrogram/client/types/user_and_chats/chat_permissions.py +++ b/pyrogram/client/types/user_and_chats/chat_permissions.py @@ -94,6 +94,13 @@ class ChatPermissions(PyrogramType): True, if polls can be sent, implies can_send_media_messages. """ + __slots__ = [ + "until_date", "can_be_edited", "can_change_info", "can_post_messages", "can_edit_messages", + "can_delete_messages", "can_restrict_members", "can_invite_users", "can_pin_messages", "can_promote_members", + "can_send_messages", "can_send_media_messages", "can_send_other_messages", "can_add_web_page_previews", + "can_send_polls" + ] + def __init__( self, *, diff --git a/pyrogram/client/types/user_and_chats/chat_photo.py b/pyrogram/client/types/user_and_chats/chat_photo.py index 848f7250..deec5770 100644 --- a/pyrogram/client/types/user_and_chats/chat_photo.py +++ b/pyrogram/client/types/user_and_chats/chat_photo.py @@ -35,11 +35,15 @@ class ChatPhoto(PyrogramType): Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - small_file_id: str, - big_file_id: str): + __slots__ = ["small_file_id", "big_file_id"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + small_file_id: str, + big_file_id: str + ): super().__init__(client) self.small_file_id = small_file_id diff --git a/pyrogram/client/types/user_and_chats/chat_preview.py b/pyrogram/client/types/user_and_chats/chat_preview.py index 45048637..9c9c71ec 100644 --- a/pyrogram/client/types/user_and_chats/chat_preview.py +++ b/pyrogram/client/types/user_and_chats/chat_preview.py @@ -45,14 +45,18 @@ class ChatPreview(PyrogramType): Preview of some of the chat members. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - title: str, - photo: ChatPhoto, - type: str, - members_count: int, - members: List[User] = None): + __slots__ = ["title", "photo", "type", "members_count", "members"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + title: str, + photo: ChatPhoto, + type: str, + members_count: int, + members: List[User] = None + ): super().__init__(client) self.title = title diff --git a/pyrogram/client/types/user_and_chats/dialog.py b/pyrogram/client/types/user_and_chats/dialog.py index b71caba7..11a1ae19 100644 --- a/pyrogram/client/types/user_and_chats/dialog.py +++ b/pyrogram/client/types/user_and_chats/dialog.py @@ -46,15 +46,19 @@ class Dialog(PyrogramType): True, if the dialog is pinned. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - chat: Chat, - top_message: "pyrogram.Message", - unread_messages_count: int, - unread_mentions_count: int, - unread_mark: bool, - is_pinned: bool): + __slots__ = ["chat", "top_message", "unread_messages_count", "unread_mentions_count", "unread_mark", "is_pinned"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + chat: Chat, + top_message: "pyrogram.Message", + unread_messages_count: int, + unread_mentions_count: int, + unread_mark: bool, + is_pinned: bool + ): super().__init__(client) self.chat = chat diff --git a/pyrogram/client/types/user_and_chats/dialogs.py b/pyrogram/client/types/user_and_chats/dialogs.py index 394ddd28..27222a91 100644 --- a/pyrogram/client/types/user_and_chats/dialogs.py +++ b/pyrogram/client/types/user_and_chats/dialogs.py @@ -36,11 +36,15 @@ class Dialogs(PyrogramType): Requested dialogs. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - dialogs: List[Dialog]): + __slots__ = ["total_count", "dialogs"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + dialogs: List[Dialog] + ): super().__init__(client) self.total_count = total_count diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index c6ee03e8..f5c00ac0 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -70,23 +70,30 @@ class User(PyrogramType): The reason why this bot might be unavailable to some users. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - is_self: bool, - is_contact: bool, - is_mutual_contact: bool, - is_deleted: bool, - is_bot: bool, - first_name: str, - last_name: str = None, - status: UserStatus = None, - username: str = None, - language_code: str = None, - phone_number: str = None, - photo: ChatPhoto = None, - restriction_reason: str = None): + __slots__ = [ + "id", "is_self", "is_contact", "is_mutual_contact", "is_deleted", "is_bot", "first_name", "last_name", "status", + "username", "language_code", "phone_number", "photo", "restriction_reason" + ] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + is_self: bool, + is_contact: bool, + is_mutual_contact: bool, + is_deleted: bool, + is_bot: bool, + first_name: str, + last_name: str = None, + status: UserStatus = None, + username: str = None, + language_code: str = None, + phone_number: str = None, + photo: ChatPhoto = None, + restriction_reason: str = None + ): super().__init__(client) self.id = id diff --git a/pyrogram/client/types/user_and_chats/user_status.py b/pyrogram/client/types/user_and_chats/user_status.py index 8c936f8e..871978d0 100644 --- a/pyrogram/client/types/user_and_chats/user_status.py +++ b/pyrogram/client/types/user_and_chats/user_status.py @@ -65,17 +65,21 @@ class UserStatus(PyrogramType, Update): always shown to blocked users), None otherwise. """ - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - user_id: int, - online: bool = None, - offline: bool = None, - date: int = None, - recently: bool = None, - within_week: bool = None, - within_month: bool = None, - long_time_ago: bool = None): + __slots__ = ["user_id", "online", "offline", "date", "recently", "within_week", "within_month", "long_time_ago"] + + def __init__( + self, + *, + client: "pyrogram.client.ext.BaseClient", + user_id: int, + online: bool = None, + offline: bool = None, + date: int = None, + recently: bool = None, + within_week: bool = None, + within_month: bool = None, + long_time_ago: bool = None + ): super().__init__(client) self.user_id = user_id From 34b51b6481de6166d43aa4c3f37bbe50ef8e6c40 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 16:50:40 +0100 Subject: [PATCH 13/15] Force keyword arguments for all TL types --- compiler/api/compiler.py | 12 ++-- pyrogram/client/client.py | 34 ++++++----- pyrogram/client/ext/utils.py | 6 +- .../methods/chats/export_chat_invite_link.py | 2 +- pyrogram/client/methods/chats/get_chat.py | 6 +- .../client/methods/chats/get_chat_members.py | 2 +- .../client/methods/contacts/get_contacts.py | 2 +- .../methods/messages/edit_message_media.py | 16 ++++-- .../client/methods/messages/get_messages.py | 2 +- .../client/methods/messages/send_animation.py | 2 +- .../client/methods/messages/send_audio.py | 2 +- .../client/methods/messages/send_document.py | 2 +- .../client/methods/messages/send_location.py | 6 +- .../methods/messages/send_media_group.py | 2 +- .../client/methods/messages/send_sticker.py | 2 +- .../client/methods/messages/send_video.py | 2 +- pyrogram/client/methods/password/utils.py | 2 +- pyrogram/client/methods/users/get_me.py | 2 +- .../methods/users/set_user_profile_photo.py | 2 +- pyrogram/client/style/html.py | 14 ++--- pyrogram/client/style/markdown.py | 14 ++--- .../types/bots/inline_keyboard_button.py | 14 +++-- .../types/bots/inline_keyboard_markup.py | 4 +- pyrogram/client/types/bots/keyboard_button.py | 6 +- .../types/bots/reply_keyboard_markup.py | 8 ++- .../types/messages_and_media/sticker.py | 5 +- pyrogram/session/auth.py | 56 +++++++++---------- pyrogram/session/session.py | 14 ++--- 28 files changed, 133 insertions(+), 108 deletions(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index c9ea5f34..fe204a98 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -287,9 +287,11 @@ def start(): sorted_args = sort_args(c.args) - arguments = ", " + ", ".join( - [get_argument_type(i) for i in sorted_args if i != ("flags", "#")] - ) if c.args else "" + arguments = ( + ", " + + ("*, " if c.args else "") + + (", ".join([get_argument_type(i) for i in sorted_args if i != ("flags", "#")]) if c.args else "") + ) fields = "\n ".join( ["self.{0} = {0} # {1}".format(i[0], i[1]) for i in c.args if i != ("flags", "#")] @@ -456,7 +458,9 @@ def start(): fields=fields, read_types=read_types, write_types=write_types, - return_arguments=", ".join([i[0] for i in sorted_args if i != ("flags", "#")]), + return_arguments=", ".join( + ["{0}={0}".format(i[0]) for i in sorted_args if i != ("flags", "#")] + ), slots=", ".join(['"{}"'.format(i[0]) for i in sorted_args if i != ("flags", "#")]), qualname="{}{}".format("{}.".format(c.namespace) if c.namespace else "", c.name) ) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index df1ff1c5..253cc754 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -627,9 +627,9 @@ class Client(Methods, BaseClient): try: r = self.send( functions.auth.SignIn( - self.phone_number, - phone_code_hash, - self.phone_code + phone_number=self.phone_number, + phone_code_hash=phone_code_hash, + phone_code=self.phone_code ) ) except PhoneNumberUnoccupied: @@ -640,11 +640,11 @@ class Client(Methods, BaseClient): try: r = self.send( functions.auth.SignUp( - self.phone_number, - phone_code_hash, - self.phone_code, - self.first_name, - self.last_name + phone_number=self.phone_number, + phone_code_hash=phone_code_hash, + phone_code=self.phone_code, + first_name=self.first_name, + last_name=self.last_name ) ) except PhoneNumberOccupied: @@ -738,7 +738,11 @@ class Client(Methods, BaseClient): break if terms_of_service: - assert self.send(functions.help.AcceptTermsOfService(terms_of_service.id)) + assert self.send( + functions.help.AcceptTermsOfService( + id=terms_of_service.id + ) + ) self.password = None self.user_id = r.user.id @@ -1036,10 +1040,10 @@ class Client(Methods, BaseClient): raise ConnectionError("Client has not been started") if self.no_updates: - data = functions.InvokeWithoutUpdates(data) + data = functions.InvokeWithoutUpdates(query=data) if self.takeout_id: - data = functions.InvokeWithTakeout(self.takeout_id, data) + data = functions.InvokeWithTakeout(takeout_id=self.takeout_id, query=data) r = self.session.send(data, retries, timeout) @@ -1353,7 +1357,7 @@ class Client(Methods, BaseClient): self.fetch_peers( self.send( functions.users.GetUsers( - id=[types.InputUser(peer_id, 0)] + id=[types.InputUser(user_id=peer_id, access_hash=0)] ) ) ) @@ -1361,7 +1365,7 @@ class Client(Methods, BaseClient): if str(peer_id).startswith("-100"): self.send( functions.channels.GetChannels( - id=[types.InputChannel(int(str(peer_id)[4:]), 0)] + id=[types.InputChannel(channel_id=int(str(peer_id)[4:]), access_hash=0)] ) ) else: @@ -1668,8 +1672,8 @@ class Client(Methods, BaseClient): hashes = session.send( functions.upload.GetCdnFileHashes( - r.file_token, - offset + file_token=r.file_token, + offset=offset ) ) diff --git a/pyrogram/client/ext/utils.py b/pyrogram/client/ext/utils.py index 087773f4..981752fa 100644 --- a/pyrogram/client/ext/utils.py +++ b/pyrogram/client/ext/utils.py @@ -67,10 +67,10 @@ def get_peer_id(input_peer) -> int: def get_input_peer(peer_id: int, access_hash: int): return ( - types.InputPeerUser(peer_id, access_hash) if peer_id > 0 - else types.InputPeerChannel(int(str(peer_id)[4:]), access_hash) + types.InputPeerUser(user_id=peer_id, access_hash=access_hash) if peer_id > 0 + else types.InputPeerChannel(channel_id=int(str(peer_id)[4:]), access_hash=access_hash) if (str(peer_id).startswith("-100") and access_hash) - else types.InputPeerChat(-peer_id) + else types.InputPeerChat(chat_id=-peer_id) ) diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py index 9ff8c9c0..39f1a2fe 100644 --- a/pyrogram/client/methods/chats/export_chat_invite_link.py +++ b/pyrogram/client/methods/chats/export_chat_invite_link.py @@ -45,7 +45,7 @@ class ExportChatInviteLink(BaseClient): if isinstance(peer, types.InputPeerChat): return self.send( functions.messages.ExportChatInvite( - chat_id=peer.chat_id + peer=peer.chat_id ) ).link elif isinstance(peer, types.InputPeerChannel): diff --git a/pyrogram/client/methods/chats/get_chat.py b/pyrogram/client/methods/chats/get_chat.py index d30fd9bb..9db34669 100644 --- a/pyrogram/client/methods/chats/get_chat.py +++ b/pyrogram/client/methods/chats/get_chat.py @@ -67,10 +67,10 @@ class GetChat(BaseClient): peer = self.resolve_peer(chat_id) if isinstance(peer, types.InputPeerChannel): - r = self.send(functions.channels.GetFullChannel(peer)) + r = self.send(functions.channels.GetFullChannel(channel=peer)) elif isinstance(peer, (types.InputPeerUser, types.InputPeerSelf)): - r = self.send(functions.users.GetFullUser(peer)) + r = self.send(functions.users.GetFullUser(id=peer)) else: - r = self.send(functions.messages.GetFullChat(peer.chat_id)) + r = self.send(functions.messages.GetFullChat(chat_id=peer.chat_id)) return pyrogram.Chat._parse_full(self, r) diff --git a/pyrogram/client/methods/chats/get_chat_members.py b/pyrogram/client/methods/chats/get_chat_members.py index 382d7f0f..6c56b532 100644 --- a/pyrogram/client/methods/chats/get_chat_members.py +++ b/pyrogram/client/methods/chats/get_chat_members.py @@ -92,7 +92,7 @@ class GetChatMembers(BaseClient): self, self.send( functions.messages.GetFullChat( - peer.chat_id + chat_id=peer.chat_id ) ) ) diff --git a/pyrogram/client/methods/contacts/get_contacts.py b/pyrogram/client/methods/contacts/get_contacts.py index 29b7e176..30310913 100644 --- a/pyrogram/client/methods/contacts/get_contacts.py +++ b/pyrogram/client/methods/contacts/get_contacts.py @@ -39,7 +39,7 @@ class GetContacts(BaseClient): """ while True: try: - contacts = self.send(functions.contacts.GetContacts(0)) + contacts = self.send(functions.contacts.GetContacts(hash=0)) except FloodWait as e: log.warning("get_contacts flood: waiting {} seconds".format(e.x)) time.sleep(e.x) diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index 9ad2f199..2f82e2ea 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -131,7 +131,9 @@ class EditMessageMedia(BaseClient): w=media.width, h=media.height ), - types.DocumentAttributeFilename(os.path.basename(media.media)) + types.DocumentAttributeFilename( + file_name=os.path.basename(media.media) + ) ] ) ) @@ -187,7 +189,9 @@ class EditMessageMedia(BaseClient): performer=media.performer, title=media.title ), - types.DocumentAttributeFilename(os.path.basename(media.media)) + types.DocumentAttributeFilename( + file_name=os.path.basename(media.media) + ) ] ) ) @@ -244,7 +248,9 @@ class EditMessageMedia(BaseClient): w=media.width, h=media.height ), - types.DocumentAttributeFilename(os.path.basename(media.media)), + types.DocumentAttributeFilename( + file_name=os.path.basename(media.media) + ), types.DocumentAttributeAnimated() ] ) @@ -296,7 +302,9 @@ class EditMessageMedia(BaseClient): thumb=None if media.thumb is None else self.save_file(media.thumb), file=self.save_file(media.media), attributes=[ - types.DocumentAttributeFilename(os.path.basename(media.media)) + types.DocumentAttributeFilename( + file_name=os.path.basename(media.media) + ) ] ) ) diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py index b1c90d10..40b1b0ee 100644 --- a/pyrogram/client/methods/messages/get_messages.py +++ b/pyrogram/client/methods/messages/get_messages.py @@ -76,7 +76,7 @@ class GetMessages(BaseClient): is_iterable = not isinstance(ids, int) ids = list(ids) if is_iterable else [ids] - ids = [ids_type(i) for i in ids] + ids = [ids_type(id=i) for i in ids] if isinstance(peer, types.InputPeerChannel): rpc = functions.channels.GetMessages(channel=peer, id=ids) diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index 8fc31e08..5ac902ed 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -141,7 +141,7 @@ class SendAnimation(BaseClient): w=width, h=height ), - types.DocumentAttributeFilename(os.path.basename(animation)), + types.DocumentAttributeFilename(file_name=os.path.basename(animation)), types.DocumentAttributeAnimated() ] ) diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index a956ba85..a4f5512b 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -142,7 +142,7 @@ class SendAudio(BaseClient): performer=performer, title=title ), - types.DocumentAttributeFilename(os.path.basename(audio)) + types.DocumentAttributeFilename(file_name=os.path.basename(audio)) ] ) elif audio.startswith("http"): diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 35fe8c0e..6dc496e4 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -123,7 +123,7 @@ class SendDocument(BaseClient): file=file, thumb=thumb, attributes=[ - types.DocumentAttributeFilename(os.path.basename(document)) + types.DocumentAttributeFilename(file_name=os.path.basename(document)) ] ) elif document.startswith("http"): diff --git a/pyrogram/client/methods/messages/send_location.py b/pyrogram/client/methods/messages/send_location.py index b899a938..5fe57904 100644 --- a/pyrogram/client/methods/messages/send_location.py +++ b/pyrogram/client/methods/messages/send_location.py @@ -69,9 +69,9 @@ class SendLocation(BaseClient): functions.messages.SendMedia( peer=self.resolve_peer(chat_id), media=types.InputMediaGeoPoint( - types.InputGeoPoint( - latitude, - longitude + geo_point=types.InputGeoPoint( + lat=latitude, + long=longitude ) ), message="", diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py index 0df273bc..42e4ddde 100644 --- a/pyrogram/client/methods/messages/send_media_group.py +++ b/pyrogram/client/methods/messages/send_media_group.py @@ -137,7 +137,7 @@ class SendMediaGroup(BaseClient): w=i.width, h=i.height ), - types.DocumentAttributeFilename(os.path.basename(i.media)) + types.DocumentAttributeFilename(file_name=os.path.basename(i.media)) ] ) ) diff --git a/pyrogram/client/methods/messages/send_sticker.py b/pyrogram/client/methods/messages/send_sticker.py index e41c074e..ba16a2e7 100644 --- a/pyrogram/client/methods/messages/send_sticker.py +++ b/pyrogram/client/methods/messages/send_sticker.py @@ -103,7 +103,7 @@ class SendSticker(BaseClient): mime_type="image/webp", file=file, attributes=[ - types.DocumentAttributeFilename(os.path.basename(sticker)) + types.DocumentAttributeFilename(file_name=os.path.basename(sticker)) ] ) elif sticker.startswith("http"): diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index b69b2185..0224eaf6 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -145,7 +145,7 @@ class SendVideo(BaseClient): w=width, h=height ), - types.DocumentAttributeFilename(os.path.basename(video)) + types.DocumentAttributeFilename(file_name=os.path.basename(video)) ] ) elif video.startswith("http"): diff --git a/pyrogram/client/methods/password/utils.py b/pyrogram/client/methods/password/utils.py index 24c4dd28..3a29976a 100644 --- a/pyrogram/client/methods/password/utils.py +++ b/pyrogram/client/methods/password/utils.py @@ -101,4 +101,4 @@ def compute_check(r: types.account.Password, password: str) -> types.InputCheckP + K_bytes ) - return types.InputCheckPasswordSRP(srp_id, A_bytes, M1_bytes) + return types.InputCheckPasswordSRP(srp_id=srp_id, A=A_bytes, M1=M1_bytes) diff --git a/pyrogram/client/methods/users/get_me.py b/pyrogram/client/methods/users/get_me.py index beea1243..fdceeaba 100644 --- a/pyrogram/client/methods/users/get_me.py +++ b/pyrogram/client/methods/users/get_me.py @@ -35,7 +35,7 @@ class GetMe(BaseClient): self, self.send( functions.users.GetFullUser( - types.InputPeerSelf() + id=types.InputPeerSelf() ) ).user ) diff --git a/pyrogram/client/methods/users/set_user_profile_photo.py b/pyrogram/client/methods/users/set_user_profile_photo.py index 0863c695..359a0cd0 100644 --- a/pyrogram/client/methods/users/set_user_profile_photo.py +++ b/pyrogram/client/methods/users/set_user_profile_photo.py @@ -43,7 +43,7 @@ class SetUserProfilePhoto(BaseClient): return bool( self.send( functions.photos.UploadProfilePhoto( - self.save_file(photo) + file=self.save_file(photo) ) ) ) diff --git a/pyrogram/client/style/html.py b/pyrogram/client/style/html.py index 9a72a565..040e770b 100644 --- a/pyrogram/client/style/html.py +++ b/pyrogram/client/style/html.py @@ -55,20 +55,20 @@ class HTML: input_user = self.peers_by_id.get(user_id, None) entity = ( - Mention(start, len(body), input_user) - if input_user else MentionInvalid(start, len(body), user_id) + Mention(offset=start, length=len(body), user_id=input_user) + if input_user else MentionInvalid(offset=start, length=len(body), user_id=user_id) ) else: - entity = Url(start, len(body), url) + entity = Url(offset=start, length=len(body), url=url) else: if style == "b" or style == "strong": - entity = Bold(start, len(body)) + entity = Bold(offset=start, length=len(body)) elif style == "i" or style == "em": - entity = Italic(start, len(body)) + entity = Italic(offset=start, length=len(body)) elif style == "code": - entity = Code(start, len(body)) + entity = Code(offset=start, length=len(body)) elif style == "pre": - entity = Pre(start, len(body), "") + entity = Pre(offset=start, length=len(body), language="") else: continue diff --git a/pyrogram/client/style/markdown.py b/pyrogram/client/style/markdown.py index 05a11a25..04ce95c8 100644 --- a/pyrogram/client/style/markdown.py +++ b/pyrogram/client/style/markdown.py @@ -72,24 +72,24 @@ class Markdown: input_user = self.peers_by_id.get(user_id, None) entity = ( - Mention(start, len(text), input_user) + Mention(offset=start, length=len(text), user_id=input_user) if input_user - else MentionInvalid(start, len(text), user_id) + else MentionInvalid(offset=start, length=len(text), user_id=user_id) ) else: - entity = Url(start, len(text), url) + entity = Url(offset=start, length=len(text), url=url) body = text offset += len(url) + 4 else: if style == self.BOLD_DELIMITER: - entity = Bold(start, len(body)) + entity = Bold(offset=start, length=len(body)) elif style == self.ITALIC_DELIMITER: - entity = Italic(start, len(body)) + entity = Italic(offset=start, length=len(body)) elif style == self.CODE_DELIMITER: - entity = Code(start, len(body)) + entity = Code(offset=start, length=len(body)) elif style == self.PRE_DELIMITER: - entity = Pre(start, len(body), "") + entity = Pre(offset=start, length=len(body), language="") else: continue diff --git a/pyrogram/client/types/bots/inline_keyboard_button.py b/pyrogram/client/types/bots/inline_keyboard_button.py index 505b7c87..cca42b33 100644 --- a/pyrogram/client/types/bots/inline_keyboard_button.py +++ b/pyrogram/client/types/bots/inline_keyboard_button.py @@ -111,16 +111,20 @@ class InlineKeyboardButton(PyrogramType): def write(self): if self.callback_data: - return KeyboardButtonCallback(self.text, self.callback_data) + return KeyboardButtonCallback(text=self.text, data=self.callback_data) if self.url: - return KeyboardButtonUrl(self.text, self.url) + return KeyboardButtonUrl(text=self.text, url=self.url) if self.switch_inline_query: - return KeyboardButtonSwitchInline(self.text, self.switch_inline_query) + return KeyboardButtonSwitchInline(text=self.text, query=self.switch_inline_query) if self.switch_inline_query_current_chat: - return KeyboardButtonSwitchInline(self.text, self.switch_inline_query_current_chat, same_peer=True) + return KeyboardButtonSwitchInline( + text=self.text, + query=self.switch_inline_query_current_chat, + same_peer=True + ) if self.callback_game: - return KeyboardButtonGame(self.text) + return KeyboardButtonGame(text=self.text) diff --git a/pyrogram/client/types/bots/inline_keyboard_markup.py b/pyrogram/client/types/bots/inline_keyboard_markup.py index cb5327b1..77e9cfeb 100644 --- a/pyrogram/client/types/bots/inline_keyboard_markup.py +++ b/pyrogram/client/types/bots/inline_keyboard_markup.py @@ -59,7 +59,7 @@ class InlineKeyboardMarkup(PyrogramType): def write(self): return ReplyInlineMarkup( - [KeyboardButtonRow( - [j.write() for j in i] + rows=[KeyboardButtonRow( + buttons=[j.write() for j in i] ) for i in self.inline_keyboard] ) diff --git a/pyrogram/client/types/bots/keyboard_button.py b/pyrogram/client/types/bots/keyboard_button.py index dc4ed1e7..b8786cee 100644 --- a/pyrogram/client/types/bots/keyboard_button.py +++ b/pyrogram/client/types/bots/keyboard_button.py @@ -75,8 +75,8 @@ class KeyboardButton(PyrogramType): # TODO: Enforce optional args mutual exclusiveness if self.request_contact: - return KeyboardButtonRequestPhone(self.text) + return KeyboardButtonRequestPhone(text=self.text) elif self.request_location: - return KeyboardButtonRequestGeoLocation(self.text) + return KeyboardButtonRequestGeoLocation(text=self.text) else: - return RawKeyboardButton(self.text) + return RawKeyboardButton(text=self.text) diff --git a/pyrogram/client/types/bots/reply_keyboard_markup.py b/pyrogram/client/types/bots/reply_keyboard_markup.py index 229899d0..431a55eb 100644 --- a/pyrogram/client/types/bots/reply_keyboard_markup.py +++ b/pyrogram/client/types/bots/reply_keyboard_markup.py @@ -87,9 +87,11 @@ class ReplyKeyboardMarkup(PyrogramType): def write(self): return RawReplyKeyboardMarkup( rows=[KeyboardButtonRow( - [KeyboardButton(j).write() - if isinstance(j, str) else j.write() - for j in i] + buttons=[ + KeyboardButton(j).write() + if isinstance(j, str) else j.write() + for j in i + ] ) for i in self.keyboard], resize=self.resize_keyboard or None, single_use=self.one_time_keyboard or None, diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py index 70322577..ce390b1d 100644 --- a/pyrogram/client/types/messages_and_media/sticker.py +++ b/pyrogram/client/types/messages_and_media/sticker.py @@ -103,7 +103,10 @@ class Sticker(PyrogramType): try: return send( functions.messages.GetStickerSet( - types.InputStickerSetID(*input_sticker_set_id) + stickerset=types.InputStickerSetID( + id=input_sticker_set_id[0], + access_hash=input_sticker_set_id[1] + ) ) ).set.short_name except StickersetInvalid: diff --git a/pyrogram/session/auth.py b/pyrogram/session/auth.py index 05b20eec..9d8e4b16 100644 --- a/pyrogram/session/auth.py +++ b/pyrogram/session/auth.py @@ -45,10 +45,10 @@ class Auth: @staticmethod def pack(data: Object) -> bytes: return ( - bytes(8) - + Long(MsgId()) - + Int(len(data.write())) - + data.write() + bytes(8) + + Long(MsgId()) + + Int(len(data.write())) + + data.write() ) @staticmethod @@ -83,7 +83,7 @@ class Auth: # Step 1; Step 2 nonce = int.from_bytes(urandom(16), "little", signed=True) log.debug("Send req_pq: {}".format(nonce)) - res_pq = self.send(functions.ReqPqMulti(nonce)) + res_pq = self.send(functions.ReqPqMulti(nonce=nonce)) log.debug("Got ResPq: {}".format(res_pq.server_nonce)) log.debug("Server public key fingerprints: {}".format(res_pq.server_public_key_fingerprints)) @@ -110,12 +110,12 @@ class Auth: new_nonce = int.from_bytes(urandom(32), "little", signed=True) data = types.PQInnerData( - res_pq.pq, - p.to_bytes(4, "big"), - q.to_bytes(4, "big"), - nonce, - server_nonce, - new_nonce, + pq=res_pq.pq, + p=p.to_bytes(4, "big"), + q=q.to_bytes(4, "big"), + nonce=nonce, + server_nonce=server_nonce, + new_nonce=new_nonce, ).write() sha = sha1(data).digest() @@ -129,12 +129,12 @@ class Auth: log.debug("Send req_DH_params") server_dh_params = self.send( functions.ReqDHParams( - nonce, - server_nonce, - p.to_bytes(4, "big"), - q.to_bytes(4, "big"), - public_key_fingerprint, - encrypted_data + nonce=nonce, + server_nonce=server_nonce, + p=p.to_bytes(4, "big"), + q=q.to_bytes(4, "big"), + public_key_fingerprint=public_key_fingerprint, + encrypted_data=encrypted_data ) ) @@ -144,13 +144,13 @@ class Auth: new_nonce = new_nonce.to_bytes(32, "little", signed=True) tmp_aes_key = ( - sha1(new_nonce + server_nonce).digest() - + sha1(server_nonce + new_nonce).digest()[:12] + sha1(new_nonce + server_nonce).digest() + + sha1(server_nonce + new_nonce).digest()[:12] ) tmp_aes_iv = ( - sha1(server_nonce + new_nonce).digest()[12:] - + sha1(new_nonce + new_nonce).digest() + new_nonce[:4] + sha1(server_nonce + new_nonce).digest()[12:] + + sha1(new_nonce + new_nonce).digest() + new_nonce[:4] ) server_nonce = int.from_bytes(server_nonce, "little", signed=True) @@ -175,10 +175,10 @@ class Auth: retry_id = 0 data = types.ClientDHInnerData( - nonce, - server_nonce, - retry_id, - g_b + nonce=nonce, + server_nonce=server_nonce, + retry_id=retry_id, + g_b=g_b ).write() sha = sha1(data).digest() @@ -189,9 +189,9 @@ class Auth: log.debug("Send set_client_DH_params") set_client_dh_params_answer = self.send( functions.SetClientDHParams( - nonce, - server_nonce, - encrypted_data + nonce=nonce, + server_nonce=server_nonce, + encrypted_data=encrypted_data ) ) diff --git a/pyrogram/session/session.py b/pyrogram/session/session.py index 5392728f..4ebdf4fc 100644 --- a/pyrogram/session/session.py +++ b/pyrogram/session/session.py @@ -134,11 +134,11 @@ class Session: self.current_salt = FutureSalt( 0, 0, self._send( - functions.Ping(0), + functions.Ping(ping_id=0), timeout=self.START_TIMEOUT ).new_server_salt ) - self.current_salt = self._send(functions.GetFutureSalts(1), timeout=self.START_TIMEOUT).salts[0] + self.current_salt = self._send(functions.GetFutureSalts(num=1), timeout=self.START_TIMEOUT).salts[0] self.next_salt_thread = Thread(target=self.next_salt, name="NextSaltThread") self.next_salt_thread.start() @@ -146,8 +146,8 @@ class Session: if not self.is_cdn: self._send( functions.InvokeWithLayer( - layer, - functions.InitConnection( + layer=layer, + query=functions.InitConnection( api_id=self.client.api_id, app_version=self.client.app_version, device_model=self.client.device_model, @@ -314,7 +314,7 @@ class Session: log.info("Send {} acks".format(len(self.pending_acks))) try: - self._send(types.MsgsAck(list(self.pending_acks)), False) + self._send(types.MsgsAck(msg_ids=list(self.pending_acks)), False) except (OSError, TimeoutError): pass else: @@ -335,7 +335,7 @@ class Session: try: self._send(functions.PingDelayDisconnect( - 0, self.WAIT_TIMEOUT + 10 + ping_id=0, disconnect_delay=self.WAIT_TIMEOUT + 10 ), False) except (OSError, TimeoutError, Error): pass @@ -365,7 +365,7 @@ class Session: break try: - self.current_salt = self._send(functions.GetFutureSalts(1)).salts[0] + self.current_salt = self._send(functions.GetFutureSalts(num=1)).salts[0] except (OSError, TimeoutError, Error): self.connection.close() break From def3bdaa63b00e3bceca5ee33bb831fcd61fd153 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 17:51:37 +0100 Subject: [PATCH 14/15] Reformat code --- compiler/api/compiler.py | 4 +- compiler/error/compiler.py | 2 +- .../client/methods/chats/restrict_chat.py | 20 ++--- .../methods/chats/restrict_chat_member.py | 24 +++--- .../methods/chats/update_chat_username.py | 2 +- .../client/methods/messages/download_media.py | 18 ++-- .../methods/messages/send_cached_media.py | 26 +++--- .../types/user_and_chats/chat_members.py | 1 - .../types/user_and_chats/chat_permissions.py | 52 ++++++------ .../transport/tcp/tcp_abridged_o.py | 4 +- .../transport/tcp/tcp_intermediate_o.py | 4 +- pyrogram/vendor/typing/typing.py | 83 +++++++++---------- 12 files changed, 114 insertions(+), 126 deletions(-) diff --git a/compiler/api/compiler.py b/compiler/api/compiler.py index 9e671e80..4589074b 100644 --- a/compiler/api/compiler.py +++ b/compiler/api/compiler.py @@ -171,8 +171,8 @@ def start(): shutil.rmtree("{}/functions".format(DESTINATION), ignore_errors=True) with open("{}/source/auth_key.tl".format(HOME), encoding="utf-8") as auth, \ - open("{}/source/sys_msgs.tl".format(HOME), encoding="utf-8") as system, \ - open("{}/source/main_api.tl".format(HOME), encoding="utf-8") as api: + open("{}/source/sys_msgs.tl".format(HOME), encoding="utf-8") as system, \ + open("{}/source/main_api.tl".format(HOME), encoding="utf-8") as api: schema = (auth.read() + system.read() + api.read()).splitlines() with open("{}/template/mtproto.txt".format(HOME), encoding="utf-8") as f: diff --git a/compiler/error/compiler.py b/compiler/error/compiler.py index b86222e7..751db1bc 100644 --- a/compiler/error/compiler.py +++ b/compiler/error/compiler.py @@ -73,7 +73,7 @@ def start(): f_init.write("from .{}_{} import *\n".format(name.lower(), code)) with open("{}/source/{}".format(HOME, i), encoding="utf-8") as f_csv, \ - open("{}/{}_{}.py".format(DEST, name.lower(), code), "w", encoding="utf-8") as f_class: + open("{}/{}_{}.py".format(DEST, name.lower(), code), "w", encoding="utf-8") as f_class: reader = csv.reader(f_csv, delimiter="\t") super_class = caml(name) diff --git a/pyrogram/client/methods/chats/restrict_chat.py b/pyrogram/client/methods/chats/restrict_chat.py index 502d9566..ca3e8055 100644 --- a/pyrogram/client/methods/chats/restrict_chat.py +++ b/pyrogram/client/methods/chats/restrict_chat.py @@ -25,16 +25,16 @@ from ...types.user_and_chats import Chat class RestrictChat(BaseClient): def restrict_chat( - self, - chat_id: Union[int, str], - can_send_messages: bool = False, - can_send_media_messages: bool = False, - can_send_other_messages: bool = False, - can_add_web_page_previews: bool = False, - can_send_polls: bool = False, - can_change_info: bool = False, - can_invite_users: bool = False, - can_pin_messages: bool = False + self, + chat_id: Union[int, str], + can_send_messages: bool = False, + can_send_media_messages: bool = False, + can_send_other_messages: bool = False, + can_add_web_page_previews: bool = False, + can_send_polls: bool = False, + can_change_info: bool = False, + can_invite_users: bool = False, + can_pin_messages: bool = False ) -> Chat: """Use this method to restrict a chat. Pass True for all boolean parameters to lift restrictions from a chat. diff --git a/pyrogram/client/methods/chats/restrict_chat_member.py b/pyrogram/client/methods/chats/restrict_chat_member.py index f4545cb1..d75d1fa4 100644 --- a/pyrogram/client/methods/chats/restrict_chat_member.py +++ b/pyrogram/client/methods/chats/restrict_chat_member.py @@ -25,18 +25,18 @@ from ...types.user_and_chats import Chat class RestrictChatMember(BaseClient): def restrict_chat_member( - self, - chat_id: Union[int, str], - user_id: Union[int, str], - until_date: int = 0, - can_send_messages: bool = False, - can_send_media_messages: bool = False, - can_send_other_messages: bool = False, - can_add_web_page_previews: bool = False, - can_send_polls: bool = False, - can_change_info: bool = False, - can_invite_users: bool = False, - can_pin_messages: bool = False + self, + chat_id: Union[int, str], + user_id: Union[int, str], + until_date: int = 0, + can_send_messages: bool = False, + can_send_media_messages: bool = False, + can_send_other_messages: bool = False, + can_add_web_page_previews: bool = False, + can_send_polls: bool = False, + can_change_info: bool = False, + can_invite_users: bool = False, + can_pin_messages: bool = False ) -> Chat: """Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift diff --git a/pyrogram/client/methods/chats/update_chat_username.py b/pyrogram/client/methods/chats/update_chat_username.py index 156ee6f8..353c338e 100644 --- a/pyrogram/client/methods/chats/update_chat_username.py +++ b/pyrogram/client/methods/chats/update_chat_username.py @@ -45,7 +45,7 @@ class UpdateChatUsername(BaseClient): """ peer = self.resolve_peer(chat_id) - + if isinstance(peer, types.InputPeerChannel): return bool( self.send( diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py index 181daa14..1c80f63a 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -106,15 +106,15 @@ class DownloadMedia(BaseClient): else: raise ValueError(error_message) elif isinstance(message, ( - pyrogram.Photo, - pyrogram.PhotoSize, - pyrogram.Audio, - pyrogram.Document, - pyrogram.Video, - pyrogram.Voice, - pyrogram.VideoNote, - pyrogram.Sticker, - pyrogram.Animation + pyrogram.Photo, + pyrogram.PhotoSize, + pyrogram.Audio, + pyrogram.Document, + pyrogram.Video, + pyrogram.Voice, + pyrogram.VideoNote, + pyrogram.Sticker, + pyrogram.Animation )): if isinstance(message, pyrogram.Photo): media = pyrogram.Document( diff --git a/pyrogram/client/methods/messages/send_cached_media.py b/pyrogram/client/methods/messages/send_cached_media.py index 843b7197..90c9b09f 100644 --- a/pyrogram/client/methods/messages/send_cached_media.py +++ b/pyrogram/client/methods/messages/send_cached_media.py @@ -28,19 +28,19 @@ from pyrogram.client.ext import BaseClient, utils class SendCachedMedia(BaseClient): def send_cached_media( - self, - chat_id: Union[int, str], - file_id: str, - caption: str = "", - parse_mode: str = "", - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union[ - "pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply" - ] = None + self, + chat_id: Union[int, str], + file_id: str, + caption: str = "", + parse_mode: str = "", + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None ) -> Union["pyrogram.Message", None]: """Use this method to send any media stored on the Telegram servers using a file_id. diff --git a/pyrogram/client/types/user_and_chats/chat_members.py b/pyrogram/client/types/user_and_chats/chat_members.py index 39d69089..81d63231 100644 --- a/pyrogram/client/types/user_and_chats/chat_members.py +++ b/pyrogram/client/types/user_and_chats/chat_members.py @@ -21,7 +21,6 @@ from typing import List import pyrogram from pyrogram.api import types from .chat_member import ChatMember -from .user import User from ..pyrogram_type import PyrogramType diff --git a/pyrogram/client/types/user_and_chats/chat_permissions.py b/pyrogram/client/types/user_and_chats/chat_permissions.py index a931cd7a..419f3cd2 100644 --- a/pyrogram/client/types/user_and_chats/chat_permissions.py +++ b/pyrogram/client/types/user_and_chats/chat_permissions.py @@ -95,27 +95,27 @@ class ChatPermissions(PyrogramType): """ def __init__( - self, - *, - until_date: int = None, + self, + *, + until_date: int = None, - # Admin permissions - can_be_edited: bool = None, - can_change_info: bool = None, - can_post_messages: bool = None, # Channels only - can_edit_messages: bool = None, # Channels only - can_delete_messages: bool = None, - can_restrict_members: bool = None, - can_invite_users: bool = None, - can_pin_messages: bool = None, # Supergroups only - can_promote_members: bool = None, + # Admin permissions + can_be_edited: bool = None, + can_change_info: bool = None, + can_post_messages: bool = None, # Channels only + can_edit_messages: bool = None, # Channels only + can_delete_messages: bool = None, + can_restrict_members: bool = None, + can_invite_users: bool = None, + can_pin_messages: bool = None, # Supergroups only + can_promote_members: bool = None, - # Restricted user permissions - can_send_messages: bool = None, # Text, contacts, locations and venues - can_send_media_messages: bool = None, # Audios, documents, photos, videos, video notes and voice notes - can_send_other_messages: bool = None, # Animations (GIFs), games, stickers, inline bot results - can_add_web_page_previews: bool = None, - can_send_polls: bool = None + # Restricted user permissions + can_send_messages: bool = None, # Text, contacts, locations and venues + can_send_media_messages: bool = None, # Audios, documents, photos, videos, video notes and voice notes + can_send_other_messages: bool = None, # Animations (GIFs), games, stickers, inline bot results + can_add_web_page_previews: bool = None, + can_send_polls: bool = None ): super().__init__(None) @@ -139,11 +139,11 @@ class ChatPermissions(PyrogramType): @staticmethod def _parse( - entity: Union[ - types.ChannelParticipantAdmin, - types.ChannelParticipantBanned, - types.ChatBannedRights - ] + entity: Union[ + types.ChannelParticipantAdmin, + types.ChannelParticipantBanned, + types.ChatBannedRights + ] ) -> "ChatPermissions": if isinstance(entity, types.ChannelParticipantAdmin): permissions = entity.admin_rights @@ -171,8 +171,8 @@ class ChatPermissions(PyrogramType): can_send_messages=not denied_permissions.send_messages, can_send_media_messages=not denied_permissions.send_media, can_send_other_messages=( - not denied_permissions.send_stickers or not denied_permissions.send_gifs or - not denied_permissions.send_games or not denied_permissions.send_inline + not denied_permissions.send_stickers or not denied_permissions.send_gifs or + not denied_permissions.send_games or not denied_permissions.send_inline ), can_add_web_page_previews=not denied_permissions.embed_links, can_send_polls=not denied_permissions.send_polls, diff --git a/pyrogram/connection/transport/tcp/tcp_abridged_o.py b/pyrogram/connection/transport/tcp/tcp_abridged_o.py index d15d0389..136d22ef 100644 --- a/pyrogram/connection/transport/tcp/tcp_abridged_o.py +++ b/pyrogram/connection/transport/tcp/tcp_abridged_o.py @@ -40,9 +40,7 @@ class TCPAbridgedO(TCP): while True: nonce = bytearray(os.urandom(64)) - if (nonce[0] != b"\xef" - and nonce[:4] not in self.RESERVED - and nonce[4:4] != b"\x00" * 4): + if nonce[0] != b"\xef" and nonce[:4] not in self.RESERVED and nonce[4:4] != b"\x00" * 4: nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xef break diff --git a/pyrogram/connection/transport/tcp/tcp_intermediate_o.py b/pyrogram/connection/transport/tcp/tcp_intermediate_o.py index c59deed7..a92acb7f 100644 --- a/pyrogram/connection/transport/tcp/tcp_intermediate_o.py +++ b/pyrogram/connection/transport/tcp/tcp_intermediate_o.py @@ -41,9 +41,7 @@ class TCPIntermediateO(TCP): while True: nonce = bytearray(os.urandom(64)) - if (nonce[0] != b"\xef" - and nonce[:4] not in self.RESERVED - and nonce[4:4] != b"\x00" * 4): + if nonce[0] != b"\xef" and nonce[:4] not in self.RESERVED and nonce[4:4] != b"\x00" * 4: nonce[56] = nonce[57] = nonce[58] = nonce[59] = 0xee break diff --git a/pyrogram/vendor/typing/typing.py b/pyrogram/vendor/typing/typing.py index 2189cd48..16888d3f 100644 --- a/pyrogram/vendor/typing/typing.py +++ b/pyrogram/vendor/typing/typing.py @@ -1,17 +1,18 @@ import abc -from abc import abstractmethod, abstractproperty import collections import contextlib import functools import re as stdlib_re # Avoid confusion with the re we export. import sys import types +from abc import abstractmethod, abstractproperty + try: import collections.abc as collections_abc except ImportError: import collections as collections_abc # Fallback for PY3.2. if sys.version_info[:2] >= (3, 6): - import _collections_abc # Needed for private function _check_methods # noqa + pass try: from types import WrapperDescriptorType, MethodWrapperType, MethodDescriptorType except ImportError: @@ -19,7 +20,6 @@ except ImportError: MethodWrapperType = type(object().__str__) MethodDescriptorType = type(str.join) - # Please keep __all__ alphabetized within each category. __all__ = [ # Super-special typing primitives. @@ -36,7 +36,7 @@ __all__ = [ # ABCs (from collections.abc). 'AbstractSet', # collections.abc.Set. 'GenericMeta', # subclass of abc.ABCMeta and a metaclass - # for 'Generic' and ABCs below. + # for 'Generic' and ABCs below. 'ByteString', 'Container', 'ContextManager', @@ -96,6 +96,7 @@ __all__ = [ 'TYPE_CHECKING', ] + # The pseudo-submodules 're' and 'io' are part of the public # namespace, but excluded from __all__ because they might stomp on # legitimate imports of those modules. @@ -173,8 +174,8 @@ class _TypingBase(metaclass=TypingMeta, _root=True): someone tries to subclass a special typing object (not a good idea). """ if (len(args) == 3 and - isinstance(args[0], str) and - isinstance(args[1], tuple)): + isinstance(args[0], str) and + isinstance(args[1], tuple)): # Close enough. raise TypeError("Cannot subclass %r" % cls) return super().__new__(cls) @@ -396,7 +397,7 @@ def _type_repr(obj): return _qualname(obj) return '%s.%s' % (obj.__module__, _qualname(obj)) if obj is ...: - return('...') + return ('...') if isinstance(obj, types.FunctionType): return obj.__name__ return repr(obj) @@ -681,6 +682,7 @@ def _tp_cache(func): except TypeError: pass # All real errors (not unhashable args) are raised below. return func(*args, **kwds) + return inner @@ -948,7 +950,7 @@ class GenericMeta(TypingMeta, abc.ABCMeta): if base is Generic: raise TypeError("Cannot inherit from plain Generic") if (isinstance(base, GenericMeta) and - base.__origin__ is Generic): + base.__origin__ is Generic): if gvars is not None: raise TypeError( "Cannot inherit from Generic[...] multiple types.") @@ -1183,14 +1185,14 @@ def _generic_new(base_cls, cls, *args, **kwds): # but attempt to store it in __orig_class__ if cls.__origin__ is None: if (base_cls.__new__ is object.__new__ and - cls.__init__ is not object.__init__): + cls.__init__ is not object.__init__): return base_cls.__new__(cls) else: return base_cls.__new__(cls, *args, **kwds) else: origin = cls._gorg if (base_cls.__new__ is object.__new__ and - cls.__init__ is not object.__init__): + cls.__init__ is not object.__init__): obj = base_cls.__new__(origin) else: obj = base_cls.__new__(origin, *args, **kwds) @@ -1399,7 +1401,7 @@ class _ClassVar(_FinalTypingBase, _root=True): cls = type(self) if self.__type__ is None: return cls(_type_check(item, - '{} accepts only single type.'.format(cls.__name__[1:])), + '{} accepts only single type.'.format(cls.__name__[1:])), _root=True) raise TypeError('{} cannot be further subscripted' .format(cls.__name__[1:])) @@ -1671,26 +1673,26 @@ class _ProtocolMeta(GenericMeta): # Include attributes not defined in any non-protocol bases. for c in self.__mro__: if (c is not base and attr in c.__dict__ and - not getattr(c, '_is_protocol', False)): + not getattr(c, '_is_protocol', False)): break else: if (not attr.startswith('_abc_') and - attr != '__abstractmethods__' and - attr != '__annotations__' and - attr != '__weakref__' and - attr != '_is_protocol' and - attr != '_gorg' and - attr != '__dict__' and - attr != '__args__' and - attr != '__slots__' and - attr != '_get_protocol_attrs' and - attr != '__next_in_mro__' and - attr != '__parameters__' and - attr != '__origin__' and - attr != '__orig_bases__' and - attr != '__extra__' and - attr != '__tree_hash__' and - attr != '__module__'): + attr != '__abstractmethods__' and + attr != '__annotations__' and + attr != '__weakref__' and + attr != '_is_protocol' and + attr != '_gorg' and + attr != '__dict__' and + attr != '__args__' and + attr != '__slots__' and + attr != '_get_protocol_attrs' and + attr != '__next_in_mro__' and + attr != '__parameters__' and + attr != '__origin__' and + attr != '__orig_bases__' and + attr != '__extra__' and + attr != '__tree_hash__' and + attr != '__module__'): attrs.add(attr) return attrs @@ -1714,31 +1716,31 @@ class _Protocol(metaclass=_ProtocolMeta): Hashable = collections_abc.Hashable # Not generic. - if hasattr(collections_abc, 'Awaitable'): class Awaitable(Generic[T_co], extra=collections_abc.Awaitable): __slots__ = () - __all__.append('Awaitable') + __all__.append('Awaitable') if hasattr(collections_abc, 'Coroutine'): class Coroutine(Awaitable[V_co], Generic[T_co, T_contra, V_co], extra=collections_abc.Coroutine): __slots__ = () + __all__.append('Coroutine') - if hasattr(collections_abc, 'AsyncIterable'): - class AsyncIterable(Generic[T_co], extra=collections_abc.AsyncIterable): __slots__ = () + class AsyncIterator(AsyncIterable[T_co], extra=collections_abc.AsyncIterator): __slots__ = () + __all__.append('AsyncIterable') __all__.append('AsyncIterator') @@ -1810,7 +1812,6 @@ else: def __reversed__(self) -> 'Iterator[T_co]': pass - Sized = collections_abc.Sized # Not generic. @@ -1823,8 +1824,8 @@ if hasattr(collections_abc, 'Collection'): extra=collections_abc.Collection): __slots__ = () - __all__.append('Collection') + __all__.append('Collection') # Callable was defined earlier. @@ -1881,7 +1882,6 @@ class ByteString(Sequence[int], extra=collections_abc.ByteString): class List(list, MutableSequence[T], extra=list): - __slots__ = () def __new__(cls, *args, **kwds): @@ -1892,7 +1892,6 @@ class List(list, MutableSequence[T], extra=list): class Deque(collections.deque, MutableSequence[T], extra=collections.deque): - __slots__ = () def __new__(cls, *args, **kwds): @@ -1902,7 +1901,6 @@ class Deque(collections.deque, MutableSequence[T], extra=collections.deque): class Set(set, MutableSet[T], extra=set): - __slots__ = () def __new__(cls, *args, **kwds): @@ -1969,12 +1967,12 @@ else: return True return NotImplemented - if hasattr(contextlib, 'AbstractAsyncContextManager'): class AsyncContextManager(Generic[T_co], extra=contextlib.AbstractAsyncContextManager): __slots__ = () + __all__.append('AsyncContextManager') elif sys.version_info[:2] >= (3, 5): exec(""" @@ -2003,7 +2001,6 @@ __all__.append('AsyncContextManager') class Dict(dict, MutableMapping[KT, VT], extra=dict): - __slots__ = () def __new__(cls, *args, **kwds): @@ -2015,7 +2012,6 @@ class Dict(dict, MutableMapping[KT, VT], extra=dict): class DefaultDict(collections.defaultdict, MutableMapping[KT, VT], extra=collections.defaultdict): - __slots__ = () def __new__(cls, *args, **kwds): @@ -2025,7 +2021,6 @@ class DefaultDict(collections.defaultdict, MutableMapping[KT, VT], class Counter(collections.Counter, Dict[T, int], extra=collections.Counter): - __slots__ = () def __new__(cls, *args, **kwds): @@ -2038,6 +2033,7 @@ if hasattr(collections, 'ChainMap'): # ChainMap only exists in 3.3+ __all__.append('ChainMap') + class ChainMap(collections.ChainMap, MutableMapping[KT, VT], extra=collections.ChainMap): @@ -2048,7 +2044,6 @@ if hasattr(collections, 'ChainMap'): return collections.ChainMap(*args, **kwds) return _generic_new(collections.ChainMap, cls, *args, **kwds) - # Determine what base class to use for Generator. if hasattr(collections_abc, 'Generator'): # Sufficiently recent versions of 3.5 have a Generator ABC. @@ -2074,8 +2069,8 @@ if hasattr(collections_abc, 'AsyncGenerator'): extra=collections_abc.AsyncGenerator): __slots__ = () - __all__.append('AsyncGenerator') + __all__.append('AsyncGenerator') # Internal type variable used for Type[]. CT_co = TypeVar('CT_co', covariant=True, bound=type) @@ -2237,7 +2232,6 @@ def NewType(name, tp): # Python-version-specific alias (Python 2: unicode; Python 3: str) Text = str - # Constant that's True when type checking, but False here. TYPE_CHECKING = False @@ -2394,7 +2388,6 @@ class io: io.__name__ = __name__ + '.io' sys.modules[io.__name__] = io - Pattern = _TypeAlias('Pattern', AnyStr, type(stdlib_re.compile('')), lambda p: p.pattern) Match = _TypeAlias('Match', AnyStr, type(stdlib_re.match('', '')), From 3e18945f3ccbbce3eb7a4b506c531a616a981583 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 16 Mar 2019 19:23:23 +0100 Subject: [PATCH 15/15] Reformat code --- pyrogram/api/errors/__init__.py | 2 +- .../methods/bots/answer_callback_query.py | 14 +- .../methods/bots/get_game_high_scores.py | 10 +- .../methods/bots/get_inline_bot_results.py | 14 +- .../methods/bots/request_callback_answer.py | 10 +- pyrogram/client/methods/bots/send_game.py | 22 ++-- .../methods/bots/send_inline_bot_result.py | 16 ++- .../client/methods/bots/set_game_score.py | 16 ++- .../client/methods/chats/delete_chat_photo.py | 6 +- .../methods/chats/export_chat_invite_link.py | 6 +- pyrogram/client/methods/chats/get_chat.py | 6 +- .../client/methods/chats/get_chat_member.py | 8 +- .../client/methods/chats/get_chat_members.py | 14 +- .../methods/chats/get_chat_members_count.py | 6 +- .../client/methods/chats/get_chat_preview.py | 6 +- pyrogram/client/methods/chats/get_dialogs.py | 10 +- .../client/methods/chats/iter_chat_members.py | 12 +- pyrogram/client/methods/chats/iter_dialogs.py | 8 +- pyrogram/client/methods/chats/join_chat.py | 6 +- .../client/methods/chats/kick_chat_member.py | 10 +- pyrogram/client/methods/chats/leave_chat.py | 8 +- .../client/methods/chats/pin_chat_message.py | 12 +- .../methods/chats/promote_chat_member.py | 24 ++-- .../methods/chats/set_chat_description.py | 8 +- .../client/methods/chats/set_chat_photo.py | 8 +- .../client/methods/chats/set_chat_title.py | 8 +- .../client/methods/chats/unban_chat_member.py | 8 +- .../methods/chats/unpin_chat_message.py | 6 +- .../methods/chats/update_chat_username.py | 8 +- .../client/methods/contacts/add_contacts.py | 6 +- .../methods/contacts/delete_contacts.py | 6 +- .../methods/decorators/on_callback_query.py | 8 +- .../methods/decorators/on_deleted_messages.py | 8 +- .../client/methods/decorators/on_message.py | 8 +- .../methods/decorators/on_raw_update.py | 6 +- .../methods/decorators/on_user_status.py | 8 +- .../client/methods/messages/close_poll.py | 8 +- .../methods/messages/delete_messages.py | 10 +- .../client/methods/messages/download_media.py | 14 +- .../methods/messages/edit_message_caption.py | 14 +- .../methods/messages/edit_message_media.py | 12 +- .../messages/edit_message_reply_markup.py | 10 +- .../methods/messages/edit_message_text.py | 16 ++- .../methods/messages/forward_messages.py | 12 +- .../client/methods/messages/get_history.py | 16 ++- .../client/methods/messages/get_messages.py | 12 +- .../client/methods/messages/iter_history.py | 16 ++- .../client/methods/messages/retract_vote.py | 8 +- .../client/methods/messages/send_animation.py | 38 +++--- .../client/methods/messages/send_audio.py | 38 +++--- .../methods/messages/send_chat_action.py | 10 +- .../client/methods/messages/send_contact.py | 28 ++-- .../client/methods/messages/send_document.py | 32 +++-- .../client/methods/messages/send_location.py | 24 ++-- .../methods/messages/send_media_group.py | 12 +- .../client/methods/messages/send_message.py | 26 ++-- .../client/methods/messages/send_photo.py | 32 +++-- pyrogram/client/methods/messages/send_poll.py | 24 ++-- .../client/methods/messages/send_sticker.py | 26 ++-- .../client/methods/messages/send_venue.py | 32 +++-- .../client/methods/messages/send_video.py | 40 +++--- .../methods/messages/send_video_note.py | 32 +++-- .../client/methods/messages/send_voice.py | 32 +++-- pyrogram/client/methods/messages/vote_poll.py | 10 +- .../methods/password/change_cloud_password.py | 10 +- .../methods/password/enable_cloud_password.py | 10 +- .../methods/password/remove_cloud_password.py | 6 +- .../users/delete_user_profile_photos.py | 6 +- .../methods/users/get_user_profile_photos.py | 10 +- pyrogram/client/methods/users/get_users.py | 6 +- .../methods/users/set_user_profile_photo.py | 6 +- .../client/methods/users/update_username.py | 6 +- pyrogram/client/types/bots/callback_query.py | 20 +-- pyrogram/client/types/bots/force_reply.py | 4 +- pyrogram/client/types/bots/game_high_score.py | 12 +- .../client/types/bots/game_high_scores.py | 10 +- .../types/bots/inline_keyboard_button.py | 14 +- .../types/bots/inline_keyboard_markup.py | 4 +- pyrogram/client/types/bots/keyboard_button.py | 8 +- .../types/bots/reply_keyboard_markup.py | 10 +- .../types/bots/reply_keyboard_remove.py | 4 +- .../client/types/input_media/input_media.py | 8 +- .../input_media/input_media_animation.py | 16 +-- .../types/input_media/input_media_audio.py | 16 +-- .../types/input_media/input_media_document.py | 10 +- .../types/input_media/input_media_photo.py | 8 +- .../types/input_media/input_media_video.py | 18 +-- .../types/input_media/input_phone_contact.py | 8 +- .../types/messages_and_media/animation.py | 24 ++-- .../client/types/messages_and_media/audio.py | 24 ++-- .../types/messages_and_media/contact.py | 16 +-- .../types/messages_and_media/document.py | 18 +-- .../client/types/messages_and_media/game.py | 18 +-- .../types/messages_and_media/location.py | 10 +- .../types/messages_and_media/message.py | 122 +++++++++--------- .../messages_and_media/message_entity.py | 16 +-- .../types/messages_and_media/messages.py | 10 +- .../client/types/messages_and_media/photo.py | 12 +- .../types/messages_and_media/photo_size.py | 14 +- .../client/types/messages_and_media/poll.py | 18 +-- .../types/messages_and_media/poll_option.py | 12 +- .../types/messages_and_media/sticker.py | 26 ++-- .../messages_and_media/user_profile_photos.py | 10 +- .../client/types/messages_and_media/venue.py | 16 +-- .../client/types/messages_and_media/video.py | 24 ++-- .../types/messages_and_media/video_note.py | 20 +-- .../client/types/messages_and_media/voice.py | 18 +-- pyrogram/client/types/user_and_chats/chat.py | 36 +++--- .../types/user_and_chats/chat_member.py | 20 +-- .../types/user_and_chats/chat_members.py | 10 +- .../client/types/user_and_chats/chat_photo.py | 10 +- .../types/user_and_chats/chat_preview.py | 16 +-- .../client/types/user_and_chats/dialog.py | 18 +-- .../client/types/user_and_chats/dialogs.py | 10 +- pyrogram/client/types/user_and_chats/user.py | 34 ++--- .../types/user_and_chats/user_status.py | 22 ++-- pyrogram/session/auth.py | 16 +-- 117 files changed, 974 insertions(+), 802 deletions(-) diff --git a/pyrogram/api/errors/__init__.py b/pyrogram/api/errors/__init__.py index ca65619c..8a1dc699 100644 --- a/pyrogram/api/errors/__init__.py +++ b/pyrogram/api/errors/__init__.py @@ -16,5 +16,5 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from .exceptions import * from .error import UnknownError +from .exceptions import * diff --git a/pyrogram/client/methods/bots/answer_callback_query.py b/pyrogram/client/methods/bots/answer_callback_query.py index 5e8468e5..87fc458a 100644 --- a/pyrogram/client/methods/bots/answer_callback_query.py +++ b/pyrogram/client/methods/bots/answer_callback_query.py @@ -21,12 +21,14 @@ from pyrogram.client.ext import BaseClient class AnswerCallbackQuery(BaseClient): - def answer_callback_query(self, - callback_query_id: str, - text: str = None, - show_alert: bool = None, - url: str = None, - cache_time: int = 0): + def answer_callback_query( + self, + callback_query_id: str, + text: str = None, + show_alert: bool = None, + url: str = None, + cache_time: int = 0 + ): """Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. diff --git a/pyrogram/client/methods/bots/get_game_high_scores.py b/pyrogram/client/methods/bots/get_game_high_scores.py index ad4f8b4a..e782dadc 100644 --- a/pyrogram/client/methods/bots/get_game_high_scores.py +++ b/pyrogram/client/methods/bots/get_game_high_scores.py @@ -24,10 +24,12 @@ from pyrogram.client.ext import BaseClient class GetGameHighScores(BaseClient): - def get_game_high_scores(self, - user_id: Union[int, str], - chat_id: Union[int, str], - message_id: int = None): + def get_game_high_scores( + self, + user_id: Union[int, str], + chat_id: Union[int, str], + message_id: int = None + ): """Use this method to get data for high score tables. Args: diff --git a/pyrogram/client/methods/bots/get_inline_bot_results.py b/pyrogram/client/methods/bots/get_inline_bot_results.py index e76a0d1d..7c94bcf3 100644 --- a/pyrogram/client/methods/bots/get_inline_bot_results.py +++ b/pyrogram/client/methods/bots/get_inline_bot_results.py @@ -24,12 +24,14 @@ from pyrogram.client.ext import BaseClient class GetInlineBotResults(BaseClient): - def get_inline_bot_results(self, - bot: Union[int, str], - query: str, - offset: str = "", - latitude: float = None, - longitude: float = None): + def get_inline_bot_results( + self, + bot: Union[int, str], + query: str, + offset: str = "", + latitude: float = None, + longitude: float = None + ): """Use this method to get bot results via inline queries. You can then send a result using :obj:`send_inline_bot_result ` diff --git a/pyrogram/client/methods/bots/request_callback_answer.py b/pyrogram/client/methods/bots/request_callback_answer.py index 74e2d26d..0d440fd9 100644 --- a/pyrogram/client/methods/bots/request_callback_answer.py +++ b/pyrogram/client/methods/bots/request_callback_answer.py @@ -23,10 +23,12 @@ from pyrogram.client.ext import BaseClient class RequestCallbackAnswer(BaseClient): - def request_callback_answer(self, - chat_id: Union[int, str], - message_id: int, - callback_data: bytes): + def request_callback_answer( + self, + chat_id: Union[int, str], + message_id: int, + callback_data: bytes + ): """Use this method to request a callback answer from bots. This is the equivalent of clicking an inline button containing callback data. diff --git a/pyrogram/client/methods/bots/send_game.py b/pyrogram/client/methods/bots/send_game.py index 401a5aa6..c396ee85 100644 --- a/pyrogram/client/methods/bots/send_game.py +++ b/pyrogram/client/methods/bots/send_game.py @@ -24,15 +24,19 @@ from pyrogram.client.ext import BaseClient class SendGame(BaseClient): - def send_game(self, - chat_id: Union[int, str], - game_short_name: str, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + def send_game( + self, + chat_id: Union[int, str], + game_short_name: str, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ) -> "pyrogram.Message": """Use this method to send a game. Args: diff --git a/pyrogram/client/methods/bots/send_inline_bot_result.py b/pyrogram/client/methods/bots/send_inline_bot_result.py index 66caab16..6cfc6295 100644 --- a/pyrogram/client/methods/bots/send_inline_bot_result.py +++ b/pyrogram/client/methods/bots/send_inline_bot_result.py @@ -23,13 +23,15 @@ from pyrogram.client.ext import BaseClient class SendInlineBotResult(BaseClient): - def send_inline_bot_result(self, - chat_id: Union[int, str], - query_id: int, - result_id: str, - disable_notification: bool = None, - reply_to_message_id: int = None, - hide_via: bool = None): + def send_inline_bot_result( + self, + chat_id: Union[int, str], + query_id: int, + result_id: str, + disable_notification: bool = None, + reply_to_message_id: int = None, + hide_via: bool = None + ): """Use this method to send an inline bot result. Bot results can be retrieved using :obj:`get_inline_bot_results ` diff --git a/pyrogram/client/methods/bots/set_game_score.py b/pyrogram/client/methods/bots/set_game_score.py index e9d20844..337576a9 100644 --- a/pyrogram/client/methods/bots/set_game_score.py +++ b/pyrogram/client/methods/bots/set_game_score.py @@ -24,13 +24,15 @@ from pyrogram.client.ext import BaseClient class SetGameScore(BaseClient): - def set_game_score(self, - user_id: Union[int, str], - score: int, - force: bool = None, - disable_edit_message: bool = None, - chat_id: Union[int, str] = None, - message_id: int = None): + def set_game_score( + self, + user_id: Union[int, str], + score: int, + force: bool = None, + disable_edit_message: bool = None, + chat_id: Union[int, str] = None, + message_id: int = None + ): # inline_message_id: str = None): TODO Add inline_message_id """Use this method to set the score of the specified user in a game. diff --git a/pyrogram/client/methods/chats/delete_chat_photo.py b/pyrogram/client/methods/chats/delete_chat_photo.py index 0164ff43..2473e123 100644 --- a/pyrogram/client/methods/chats/delete_chat_photo.py +++ b/pyrogram/client/methods/chats/delete_chat_photo.py @@ -23,8 +23,10 @@ from ...ext import BaseClient class DeleteChatPhoto(BaseClient): - def delete_chat_photo(self, - chat_id: Union[int, str]) -> bool: + def delete_chat_photo( + self, + chat_id: Union[int, str] + ) -> bool: """Use this method to delete a chat photo. Photos can't be changed for private chats. You must be an administrator in the chat for this to work and must have the appropriate admin rights. diff --git a/pyrogram/client/methods/chats/export_chat_invite_link.py b/pyrogram/client/methods/chats/export_chat_invite_link.py index 39f1a2fe..88056344 100644 --- a/pyrogram/client/methods/chats/export_chat_invite_link.py +++ b/pyrogram/client/methods/chats/export_chat_invite_link.py @@ -23,8 +23,10 @@ from ...ext import BaseClient class ExportChatInviteLink(BaseClient): - def export_chat_invite_link(self, - chat_id: Union[int, str]) -> str: + def export_chat_invite_link( + self, + chat_id: Union[int, str] + ) -> str: """Use this method to generate a new invite link for a chat; any previously generated link is revoked. You must be an administrator in the chat for this to work and have the appropriate admin rights. diff --git a/pyrogram/client/methods/chats/get_chat.py b/pyrogram/client/methods/chats/get_chat.py index 9db34669..89a72722 100644 --- a/pyrogram/client/methods/chats/get_chat.py +++ b/pyrogram/client/methods/chats/get_chat.py @@ -24,8 +24,10 @@ from ...ext import BaseClient class GetChat(BaseClient): - def get_chat(self, - chat_id: Union[int, str]) -> "pyrogram.Chat": + def get_chat( + self, + chat_id: Union[int, str] + ) -> "pyrogram.Chat": """Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.) diff --git a/pyrogram/client/methods/chats/get_chat_member.py b/pyrogram/client/methods/chats/get_chat_member.py index 7ed4104b..d8315010 100644 --- a/pyrogram/client/methods/chats/get_chat_member.py +++ b/pyrogram/client/methods/chats/get_chat_member.py @@ -24,9 +24,11 @@ from ...ext import BaseClient class GetChatMember(BaseClient): - def get_chat_member(self, - chat_id: Union[int, str], - user_id: Union[int, str]) -> "pyrogram.ChatMember": + def get_chat_member( + self, + chat_id: Union[int, str], + user_id: Union[int, str] + ) -> "pyrogram.ChatMember": """Use this method to get information about one member of a chat. Args: diff --git a/pyrogram/client/methods/chats/get_chat_members.py b/pyrogram/client/methods/chats/get_chat_members.py index 6c56b532..0b07f674 100644 --- a/pyrogram/client/methods/chats/get_chat_members.py +++ b/pyrogram/client/methods/chats/get_chat_members.py @@ -33,12 +33,14 @@ class Filters: class GetChatMembers(BaseClient): - def get_chat_members(self, - chat_id: Union[int, str], - offset: int = 0, - limit: int = 200, - query: str = "", - filter: str = Filters.ALL) -> "pyrogram.ChatMembers": + def get_chat_members( + self, + chat_id: Union[int, str], + offset: int = 0, + limit: int = 200, + query: str = "", + filter: str = Filters.ALL + ) -> "pyrogram.ChatMembers": """Use this method to get a chunk of the members list of a chat. You can get up to 200 chat members at once. diff --git a/pyrogram/client/methods/chats/get_chat_members_count.py b/pyrogram/client/methods/chats/get_chat_members_count.py index 9360b64f..9e79d5fa 100644 --- a/pyrogram/client/methods/chats/get_chat_members_count.py +++ b/pyrogram/client/methods/chats/get_chat_members_count.py @@ -23,8 +23,10 @@ from ...ext import BaseClient class GetChatMembersCount(BaseClient): - def get_chat_members_count(self, - chat_id: Union[int, str]) -> int: + def get_chat_members_count( + self, + chat_id: Union[int, str] + ) -> int: """Use this method to get the number of members in a chat. Args: diff --git a/pyrogram/client/methods/chats/get_chat_preview.py b/pyrogram/client/methods/chats/get_chat_preview.py index 434c385b..28e84c79 100644 --- a/pyrogram/client/methods/chats/get_chat_preview.py +++ b/pyrogram/client/methods/chats/get_chat_preview.py @@ -22,8 +22,10 @@ from ...ext import BaseClient class GetChatPreview(BaseClient): - def get_chat_preview(self, - invite_link: str): + def get_chat_preview( + self, + invite_link: str + ): """Use this method to get the preview of a chat using the invite link. This method only returns a chat preview, if you want to join a chat use :meth:`join_chat` diff --git a/pyrogram/client/methods/chats/get_dialogs.py b/pyrogram/client/methods/chats/get_dialogs.py index c5fe6cfb..b73d0efa 100644 --- a/pyrogram/client/methods/chats/get_dialogs.py +++ b/pyrogram/client/methods/chats/get_dialogs.py @@ -28,10 +28,12 @@ log = logging.getLogger(__name__) class GetDialogs(BaseClient): - def get_dialogs(self, - offset_date: int = 0, - limit: int = 100, - pinned_only: bool = False) -> "pyrogram.Dialogs": + def get_dialogs( + self, + offset_date: int = 0, + limit: int = 100, + pinned_only: bool = False + ) -> "pyrogram.Dialogs": """Use this method to get a chunk of the user's dialogs You can get up to 100 dialogs at once. diff --git a/pyrogram/client/methods/chats/iter_chat_members.py b/pyrogram/client/methods/chats/iter_chat_members.py index b0aeb51b..0886d6c6 100644 --- a/pyrogram/client/methods/chats/iter_chat_members.py +++ b/pyrogram/client/methods/chats/iter_chat_members.py @@ -38,11 +38,13 @@ QUERYABLE_FILTERS = (Filters.ALL, Filters.KICKED, Filters.RESTRICTED) class IterChatMembers(BaseClient): - def iter_chat_members(self, - chat_id: Union[int, str], - limit: int = 0, - query: str = "", - filter: str = Filters.ALL) -> Generator["pyrogram.ChatMember", None, None]: + def iter_chat_members( + self, + chat_id: Union[int, str], + limit: int = 0, + query: str = "", + filter: str = Filters.ALL + ) -> Generator["pyrogram.ChatMember", None, None]: """Use this method to iterate through the members of a chat sequentially. This convenience method does the same as repeatedly calling :meth:`get_chat_members` in a loop, thus saving you diff --git a/pyrogram/client/methods/chats/iter_dialogs.py b/pyrogram/client/methods/chats/iter_dialogs.py index 6058cd17..a5fdb35e 100644 --- a/pyrogram/client/methods/chats/iter_dialogs.py +++ b/pyrogram/client/methods/chats/iter_dialogs.py @@ -23,9 +23,11 @@ from ...ext import BaseClient class IterDialogs(BaseClient): - def iter_dialogs(self, - offset_date: int = 0, - limit: int = 0) -> Generator["pyrogram.Dialog", None, None]: + def iter_dialogs( + self, + offset_date: int = 0, + limit: int = 0 + ) -> Generator["pyrogram.Dialog", None, None]: """Use this method to iterate through a user's dialogs sequentially. This convenience method does the same as repeatedly calling :meth:`get_dialogs` in a loop, thus saving you from diff --git a/pyrogram/client/methods/chats/join_chat.py b/pyrogram/client/methods/chats/join_chat.py index b50e50c6..1ee680bf 100644 --- a/pyrogram/client/methods/chats/join_chat.py +++ b/pyrogram/client/methods/chats/join_chat.py @@ -22,8 +22,10 @@ from ...ext import BaseClient class JoinChat(BaseClient): - def join_chat(self, - chat_id: str): + def join_chat( + self, + chat_id: str + ): """Use this method to join a group chat or channel. Args: diff --git a/pyrogram/client/methods/chats/kick_chat_member.py b/pyrogram/client/methods/chats/kick_chat_member.py index 49b3dcfd..ef0d7d55 100644 --- a/pyrogram/client/methods/chats/kick_chat_member.py +++ b/pyrogram/client/methods/chats/kick_chat_member.py @@ -24,10 +24,12 @@ from ...ext import BaseClient class KickChatMember(BaseClient): - def kick_chat_member(self, - chat_id: Union[int, str], - user_id: Union[int, str], - until_date: int = 0) -> Union["pyrogram.Message", bool]: + def kick_chat_member( + self, + chat_id: Union[int, str], + user_id: Union[int, str], + until_date: int = 0 + ) -> Union["pyrogram.Message", bool]: """Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. You must be an administrator in the chat for this to work and must diff --git a/pyrogram/client/methods/chats/leave_chat.py b/pyrogram/client/methods/chats/leave_chat.py index 5b765ac0..9f41a0cc 100644 --- a/pyrogram/client/methods/chats/leave_chat.py +++ b/pyrogram/client/methods/chats/leave_chat.py @@ -23,9 +23,11 @@ from ...ext import BaseClient class LeaveChat(BaseClient): - def leave_chat(self, - chat_id: Union[int, str], - delete: bool = False): + def leave_chat( + self, + chat_id: Union[int, str], + delete: bool = False + ): """Use this method to leave a group chat or channel. Args: diff --git a/pyrogram/client/methods/chats/pin_chat_message.py b/pyrogram/client/methods/chats/pin_chat_message.py index bb70f9e8..682f595d 100644 --- a/pyrogram/client/methods/chats/pin_chat_message.py +++ b/pyrogram/client/methods/chats/pin_chat_message.py @@ -23,10 +23,12 @@ from ...ext import BaseClient class PinChatMessage(BaseClient): - def pin_chat_message(self, - chat_id: Union[int, str], - message_id: int, - disable_notification: bool = None) -> bool: + def pin_chat_message( + self, + chat_id: Union[int, str], + message_id: int, + disable_notification: bool = None + ) -> bool: """Use this method to pin a message in a group, channel or your own chat. You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in the supergroup or "can_edit_messages" admin right in the channel. @@ -55,3 +57,5 @@ class PinChatMessage(BaseClient): silent=disable_notification or None ) ) + + return True diff --git a/pyrogram/client/methods/chats/promote_chat_member.py b/pyrogram/client/methods/chats/promote_chat_member.py index d1f942c2..f3359c5f 100644 --- a/pyrogram/client/methods/chats/promote_chat_member.py +++ b/pyrogram/client/methods/chats/promote_chat_member.py @@ -23,17 +23,19 @@ from ...ext import BaseClient class PromoteChatMember(BaseClient): - def promote_chat_member(self, - chat_id: Union[int, str], - user_id: Union[int, str], - can_change_info: bool = True, - can_post_messages: bool = False, - can_edit_messages: bool = False, - can_delete_messages: bool = True, - can_restrict_members: bool = True, - can_invite_users: bool = True, - can_pin_messages: bool = False, - can_promote_members: bool = False) -> bool: + def promote_chat_member( + self, + chat_id: Union[int, str], + user_id: Union[int, str], + can_change_info: bool = True, + can_post_messages: bool = False, + can_edit_messages: bool = False, + can_delete_messages: bool = True, + can_restrict_members: bool = True, + can_invite_users: bool = True, + can_pin_messages: bool = False, + can_promote_members: bool = False + ) -> bool: """Use this method to promote or demote a user in a supergroup or a channel. You must be an administrator in the chat for this to work and must have the appropriate admin rights. diff --git a/pyrogram/client/methods/chats/set_chat_description.py b/pyrogram/client/methods/chats/set_chat_description.py index e6c5bba1..795c0504 100644 --- a/pyrogram/client/methods/chats/set_chat_description.py +++ b/pyrogram/client/methods/chats/set_chat_description.py @@ -23,9 +23,11 @@ from ...ext import BaseClient class SetChatDescription(BaseClient): - def set_chat_description(self, - chat_id: Union[int, str], - description: str) -> bool: + def set_chat_description( + self, + chat_id: Union[int, str], + description: str + ) -> bool: """Use this method to change the description of a supergroup or a channel. You must be an administrator in the chat for this to work and must have the appropriate admin rights. diff --git a/pyrogram/client/methods/chats/set_chat_photo.py b/pyrogram/client/methods/chats/set_chat_photo.py index cc5c776a..e2fdaab2 100644 --- a/pyrogram/client/methods/chats/set_chat_photo.py +++ b/pyrogram/client/methods/chats/set_chat_photo.py @@ -26,9 +26,11 @@ from ...ext import BaseClient class SetChatPhoto(BaseClient): - def set_chat_photo(self, - chat_id: Union[int, str], - photo: str) -> bool: + def set_chat_photo( + self, + chat_id: Union[int, str], + photo: str + ) -> bool: """Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. You must be an administrator in the chat for this to work and must have the appropriate admin rights. diff --git a/pyrogram/client/methods/chats/set_chat_title.py b/pyrogram/client/methods/chats/set_chat_title.py index fff330ee..1c953ee1 100644 --- a/pyrogram/client/methods/chats/set_chat_title.py +++ b/pyrogram/client/methods/chats/set_chat_title.py @@ -23,9 +23,11 @@ from ...ext import BaseClient class SetChatTitle(BaseClient): - def set_chat_title(self, - chat_id: Union[int, str], - title: str) -> bool: + def set_chat_title( + self, + chat_id: Union[int, str], + title: str + ) -> bool: """Use this method to change the title of a chat. Titles can't be changed for private chats. You must be an administrator in the chat for this to work and must have the appropriate admin rights. diff --git a/pyrogram/client/methods/chats/unban_chat_member.py b/pyrogram/client/methods/chats/unban_chat_member.py index 4c68b14f..3000648f 100644 --- a/pyrogram/client/methods/chats/unban_chat_member.py +++ b/pyrogram/client/methods/chats/unban_chat_member.py @@ -23,9 +23,11 @@ from ...ext import BaseClient class UnbanChatMember(BaseClient): - def unban_chat_member(self, - chat_id: Union[int, str], - user_id: Union[int, str]) -> bool: + def unban_chat_member( + self, + chat_id: Union[int, str], + user_id: Union[int, str] + ) -> bool: """Use this method to unban a previously kicked user in a supergroup or channel. The user will **not** return to the group or channel automatically, but will be able to join via link, etc. You must be an administrator for this to work. diff --git a/pyrogram/client/methods/chats/unpin_chat_message.py b/pyrogram/client/methods/chats/unpin_chat_message.py index 4355010d..8030d966 100644 --- a/pyrogram/client/methods/chats/unpin_chat_message.py +++ b/pyrogram/client/methods/chats/unpin_chat_message.py @@ -23,8 +23,10 @@ from ...ext import BaseClient class UnpinChatMessage(BaseClient): - def unpin_chat_message(self, - chat_id: Union[int, str]) -> bool: + def unpin_chat_message( + self, + chat_id: Union[int, str] + ) -> bool: """Use this method to unpin a message in a group, channel or your own chat. You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in the supergroup or "can_edit_messages" admin right in the channel. diff --git a/pyrogram/client/methods/chats/update_chat_username.py b/pyrogram/client/methods/chats/update_chat_username.py index 353c338e..cc6416a9 100644 --- a/pyrogram/client/methods/chats/update_chat_username.py +++ b/pyrogram/client/methods/chats/update_chat_username.py @@ -23,9 +23,11 @@ from ...ext import BaseClient class UpdateChatUsername(BaseClient): - def update_chat_username(self, - chat_id: Union[int, str], - username: Union[str, None]) -> bool: + def update_chat_username( + self, + chat_id: Union[int, str], + username: Union[str, None] + ) -> bool: """Use this method to update a channel or a supergroup username. To update your own username (for users only, not bots) you can use :meth:`update_username`. diff --git a/pyrogram/client/methods/contacts/add_contacts.py b/pyrogram/client/methods/contacts/add_contacts.py index 48575a78..aa98fef2 100644 --- a/pyrogram/client/methods/contacts/add_contacts.py +++ b/pyrogram/client/methods/contacts/add_contacts.py @@ -24,8 +24,10 @@ from ...ext import BaseClient class AddContacts(BaseClient): - def add_contacts(self, - contacts: List["pyrogram.InputPhoneContact"]): + def add_contacts( + self, + contacts: List["pyrogram.InputPhoneContact"] + ): """Use this method to add contacts to your Telegram address book. Args: diff --git a/pyrogram/client/methods/contacts/delete_contacts.py b/pyrogram/client/methods/contacts/delete_contacts.py index dba2581d..c7e7c0e6 100644 --- a/pyrogram/client/methods/contacts/delete_contacts.py +++ b/pyrogram/client/methods/contacts/delete_contacts.py @@ -24,8 +24,10 @@ from ...ext import BaseClient class DeleteContacts(BaseClient): - def delete_contacts(self, - ids: List[int]): + def delete_contacts( + self, + ids: List[int] + ): """Use this method to delete contacts from your Telegram address book Args: diff --git a/pyrogram/client/methods/decorators/on_callback_query.py b/pyrogram/client/methods/decorators/on_callback_query.py index bf0a823a..f030f929 100644 --- a/pyrogram/client/methods/decorators/on_callback_query.py +++ b/pyrogram/client/methods/decorators/on_callback_query.py @@ -25,9 +25,11 @@ from ...ext import BaseClient class OnCallbackQuery(BaseClient): - def on_callback_query(self=None, - filters=None, - group: int = 0) -> callable: + def on_callback_query( + self=None, + filters=None, + group: int = 0 + ) -> callable: """Use this decorator to automatically register a function for handling callback queries. This does the same thing as :meth:`add_handler` using the :class:`CallbackQueryHandler`. diff --git a/pyrogram/client/methods/decorators/on_deleted_messages.py b/pyrogram/client/methods/decorators/on_deleted_messages.py index 1b1a602b..b5a95381 100644 --- a/pyrogram/client/methods/decorators/on_deleted_messages.py +++ b/pyrogram/client/methods/decorators/on_deleted_messages.py @@ -25,9 +25,11 @@ from ...ext import BaseClient class OnDeletedMessages(BaseClient): - def on_deleted_messages(self=None, - filters=None, - group: int = 0) -> callable: + def on_deleted_messages( + self=None, + filters=None, + group: int = 0 + ) -> callable: """Use this decorator to automatically register a function for handling deleted messages. This does the same thing as :meth:`add_handler` using the :class:`DeletedMessagesHandler`. diff --git a/pyrogram/client/methods/decorators/on_message.py b/pyrogram/client/methods/decorators/on_message.py index c2f35a19..41eb73e5 100644 --- a/pyrogram/client/methods/decorators/on_message.py +++ b/pyrogram/client/methods/decorators/on_message.py @@ -25,9 +25,11 @@ from ...ext import BaseClient class OnMessage(BaseClient): - def on_message(self=None, - filters=None, - group: int = 0) -> callable: + def on_message( + self=None, + filters=None, + group: int = 0 + ) -> callable: """Use this decorator to automatically register a function for handling messages. This does the same thing as :meth:`add_handler` using the :class:`MessageHandler`. diff --git a/pyrogram/client/methods/decorators/on_raw_update.py b/pyrogram/client/methods/decorators/on_raw_update.py index 2deedb00..a176ab50 100644 --- a/pyrogram/client/methods/decorators/on_raw_update.py +++ b/pyrogram/client/methods/decorators/on_raw_update.py @@ -24,8 +24,10 @@ from ...ext import BaseClient class OnRawUpdate(BaseClient): - def on_raw_update(self=None, - group: int = 0) -> callable: + def on_raw_update( + self=None, + group: int = 0 + ) -> callable: """Use this decorator to automatically register a function for handling raw updates. This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`. diff --git a/pyrogram/client/methods/decorators/on_user_status.py b/pyrogram/client/methods/decorators/on_user_status.py index 6198c9cd..580dc498 100644 --- a/pyrogram/client/methods/decorators/on_user_status.py +++ b/pyrogram/client/methods/decorators/on_user_status.py @@ -25,9 +25,11 @@ from ...ext import BaseClient class OnUserStatus(BaseClient): - def on_user_status(self=None, - filters=None, - group: int = 0) -> callable: + def on_user_status( + self=None, + filters=None, + group: int = 0 + ) -> callable: """Use this decorator to automatically register a function for handling user status updates. This does the same thing as :meth:`add_handler` using the :class:`UserStatusHandler`. diff --git a/pyrogram/client/methods/messages/close_poll.py b/pyrogram/client/methods/messages/close_poll.py index c2d2706b..ac4fc197 100644 --- a/pyrogram/client/methods/messages/close_poll.py +++ b/pyrogram/client/methods/messages/close_poll.py @@ -23,9 +23,11 @@ from pyrogram.client.ext import BaseClient class ClosePoll(BaseClient): - def close_poll(self, - chat_id: Union[int, str], - message_id: id) -> bool: + def close_poll( + self, + chat_id: Union[int, str], + message_id: id + ) -> bool: """Use this method to close (stop) a poll. Closed polls can't be reopened and nobody will be able to vote in it anymore. diff --git a/pyrogram/client/methods/messages/delete_messages.py b/pyrogram/client/methods/messages/delete_messages.py index 06acbb1f..8ea729ff 100644 --- a/pyrogram/client/methods/messages/delete_messages.py +++ b/pyrogram/client/methods/messages/delete_messages.py @@ -23,10 +23,12 @@ from pyrogram.client.ext import BaseClient class DeleteMessages(BaseClient): - def delete_messages(self, - chat_id: Union[int, str], - message_ids: Iterable[int], - revoke: bool = True) -> bool: + def delete_messages( + self, + chat_id: Union[int, str], + message_ids: Iterable[int], + revoke: bool = True + ) -> bool: """Use this method to delete messages, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. diff --git a/pyrogram/client/methods/messages/download_media.py b/pyrogram/client/methods/messages/download_media.py index 1c80f63a..29ba7af5 100644 --- a/pyrogram/client/methods/messages/download_media.py +++ b/pyrogram/client/methods/messages/download_media.py @@ -24,12 +24,14 @@ from pyrogram.client.ext import BaseClient class DownloadMedia(BaseClient): - def download_media(self, - message: Union["pyrogram.Message", str], - file_name: str = "", - block: bool = True, - progress: callable = None, - progress_args: tuple = ()) -> Union[str, None]: + def download_media( + self, + message: Union["pyrogram.Message", str], + file_name: str = "", + block: bool = True, + progress: callable = None, + progress_args: tuple = () + ) -> Union[str, None]: """Use this method to download the media from a Message. Args: diff --git a/pyrogram/client/methods/messages/edit_message_caption.py b/pyrogram/client/methods/messages/edit_message_caption.py index fe704e41..ce393319 100644 --- a/pyrogram/client/methods/messages/edit_message_caption.py +++ b/pyrogram/client/methods/messages/edit_message_caption.py @@ -24,12 +24,14 @@ from pyrogram.client.ext import BaseClient class EditMessageCaption(BaseClient): - def edit_message_caption(self, - chat_id: Union[int, str], - message_id: int, - caption: str, - parse_mode: str = "", - reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message": + def edit_message_caption( + self, + chat_id: Union[int, str], + message_id: int, + caption: str, + parse_mode: str = "", + reply_markup: "pyrogram.InlineKeyboardMarkup" = None + ) -> "pyrogram.Message": """Use this method to edit captions of messages. Args: diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index 2f82e2ea..cbb00aa3 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -33,11 +33,13 @@ from pyrogram.client.types.input_media import InputMedia class EditMessageMedia(BaseClient): - def edit_message_media(self, - chat_id: Union[int, str], - message_id: int, - media: InputMedia, - reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message": + def edit_message_media( + self, + chat_id: Union[int, str], + message_id: int, + media: InputMedia, + reply_markup: "pyrogram.InlineKeyboardMarkup" = None + ) -> "pyrogram.Message": """Use this method to edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, diff --git a/pyrogram/client/methods/messages/edit_message_reply_markup.py b/pyrogram/client/methods/messages/edit_message_reply_markup.py index f8b5c0a5..68455131 100644 --- a/pyrogram/client/methods/messages/edit_message_reply_markup.py +++ b/pyrogram/client/methods/messages/edit_message_reply_markup.py @@ -24,10 +24,12 @@ from pyrogram.client.ext import BaseClient class EditMessageReplyMarkup(BaseClient): - def edit_message_reply_markup(self, - chat_id: Union[int, str], - message_id: int, - reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message": + def edit_message_reply_markup( + self, + chat_id: Union[int, str], + message_id: int, + reply_markup: "pyrogram.InlineKeyboardMarkup" = None + ) -> "pyrogram.Message": """Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). Args: diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py index 1d2a065b..f4c5f6cf 100644 --- a/pyrogram/client/methods/messages/edit_message_text.py +++ b/pyrogram/client/methods/messages/edit_message_text.py @@ -24,13 +24,15 @@ from pyrogram.client.ext import BaseClient class EditMessageText(BaseClient): - def edit_message_text(self, - chat_id: Union[int, str], - message_id: int, - text: str, - parse_mode: str = "", - disable_web_page_preview: bool = None, - reply_markup: "pyrogram.InlineKeyboardMarkup" = None) -> "pyrogram.Message": + def edit_message_text( + self, + chat_id: Union[int, str], + message_id: int, + text: str, + parse_mode: str = "", + disable_web_page_preview: bool = None, + reply_markup: "pyrogram.InlineKeyboardMarkup" = None + ) -> "pyrogram.Message": """Use this method to edit text messages. Args: diff --git a/pyrogram/client/methods/messages/forward_messages.py b/pyrogram/client/methods/messages/forward_messages.py index 72e43e08..35d406ae 100644 --- a/pyrogram/client/methods/messages/forward_messages.py +++ b/pyrogram/client/methods/messages/forward_messages.py @@ -24,11 +24,13 @@ from ...ext import BaseClient class ForwardMessages(BaseClient): - def forward_messages(self, - chat_id: Union[int, str], - from_chat_id: Union[int, str], - message_ids: Iterable[int], - disable_notification: bool = None) -> "pyrogram.Messages": + def forward_messages( + self, + chat_id: Union[int, str], + from_chat_id: Union[int, str], + message_ids: Iterable[int], + disable_notification: bool = None + ) -> "pyrogram.Messages": """Use this method to forward messages of any kind. Args: diff --git a/pyrogram/client/methods/messages/get_history.py b/pyrogram/client/methods/messages/get_history.py index 73923b44..ca357204 100644 --- a/pyrogram/client/methods/messages/get_history.py +++ b/pyrogram/client/methods/messages/get_history.py @@ -29,13 +29,15 @@ log = logging.getLogger(__name__) class GetHistory(BaseClient): - def get_history(self, - chat_id: Union[int, str], - limit: int = 100, - offset: int = 0, - offset_id: int = 0, - offset_date: int = 0, - reverse: bool = False): + def get_history( + self, + chat_id: Union[int, str], + limit: int = 100, + offset: int = 0, + offset_id: int = 0, + offset_date: int = 0, + reverse: bool = False + ): """Use this method to retrieve a chunk of the history of a chat. You can get up to 100 messages at once. diff --git a/pyrogram/client/methods/messages/get_messages.py b/pyrogram/client/methods/messages/get_messages.py index 40b1b0ee..63fee163 100644 --- a/pyrogram/client/methods/messages/get_messages.py +++ b/pyrogram/client/methods/messages/get_messages.py @@ -29,11 +29,13 @@ log = logging.getLogger(__name__) class GetMessages(BaseClient): - def get_messages(self, - chat_id: Union[int, str], - message_ids: Union[int, Iterable[int]] = None, - reply_to_message_ids: Union[int, Iterable[int]] = None, - replies: int = 1) -> Union["pyrogram.Message", "pyrogram.Messages"]: + def get_messages( + self, + chat_id: Union[int, str], + message_ids: Union[int, Iterable[int]] = None, + reply_to_message_ids: Union[int, Iterable[int]] = None, + replies: int = 1 + ) -> Union["pyrogram.Message", "pyrogram.Messages"]: """Use this method to get one or more messages that belong to a specific chat. You can retrieve up to 200 messages at once. diff --git a/pyrogram/client/methods/messages/iter_history.py b/pyrogram/client/methods/messages/iter_history.py index ab587988..92dc7584 100644 --- a/pyrogram/client/methods/messages/iter_history.py +++ b/pyrogram/client/methods/messages/iter_history.py @@ -23,13 +23,15 @@ from ...ext import BaseClient class IterHistory(BaseClient): - def iter_history(self, - chat_id: Union[int, str], - limit: int = 0, - offset: int = 0, - offset_id: int = 0, - offset_date: int = 0, - reverse: bool = False) -> Generator["pyrogram.Message", None, None]: + def iter_history( + self, + chat_id: Union[int, str], + limit: int = 0, + offset: int = 0, + offset_id: int = 0, + offset_date: int = 0, + reverse: bool = False + ) -> Generator["pyrogram.Message", None, None]: """Use this method to iterate through a chat history sequentially. This convenience method does the same as repeatedly calling :meth:`get_history` in a loop, thus saving you from diff --git a/pyrogram/client/methods/messages/retract_vote.py b/pyrogram/client/methods/messages/retract_vote.py index 7893f768..e7ffe19b 100644 --- a/pyrogram/client/methods/messages/retract_vote.py +++ b/pyrogram/client/methods/messages/retract_vote.py @@ -23,9 +23,11 @@ from pyrogram.client.ext import BaseClient class RetractVote(BaseClient): - def retract_vote(self, - chat_id: Union[int, str], - message_id: id) -> bool: + def retract_vote( + self, + chat_id: Union[int, str], + message_id: id + ) -> bool: """Use this method to retract your vote in a poll. Args: diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index 5ac902ed..454d25ff 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -28,23 +28,27 @@ from pyrogram.client.ext import BaseClient, utils class SendAnimation(BaseClient): - def send_animation(self, - chat_id: Union[int, str], - animation: str, - caption: str = "", - parse_mode: str = "", - duration: int = 0, - width: int = 0, - height: int = 0, - thumb: str = None, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_animation( + self, + chat_id: Union[int, str], + animation: str, + caption: str = "", + parse_mode: str = "", + duration: int = 0, + width: int = 0, + height: int = 0, + thumb: str = None, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound). Args: diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index a4f5512b..d99cf744 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -28,23 +28,27 @@ from pyrogram.client.ext import BaseClient, utils class SendAudio(BaseClient): - def send_audio(self, - chat_id: Union[int, str], - audio: str, - caption: str = "", - parse_mode: str = "", - duration: int = 0, - performer: str = None, - title: str = None, - thumb: str = None, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_audio( + self, + chat_id: Union[int, str], + audio: str, + caption: str = "", + parse_mode: str = "", + duration: int = 0, + performer: str = None, + title: str = None, + thumb: str = None, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send audio files. For sending voice messages, use the :obj:`send_voice()` method instead. diff --git a/pyrogram/client/methods/messages/send_chat_action.py b/pyrogram/client/methods/messages/send_chat_action.py index 479e7abb..bfddf90b 100644 --- a/pyrogram/client/methods/messages/send_chat_action.py +++ b/pyrogram/client/methods/messages/send_chat_action.py @@ -23,10 +23,12 @@ from pyrogram.client.ext import BaseClient, ChatAction class SendChatAction(BaseClient): - def send_chat_action(self, - chat_id: Union[int, str], - action: Union[ChatAction, str], - progress: int = 0): + def send_chat_action( + self, + chat_id: Union[int, str], + action: Union[ChatAction, str], + progress: int = 0 + ): """Use this method when you need to tell the other party that something is happening on your side. Args: diff --git a/pyrogram/client/methods/messages/send_contact.py b/pyrogram/client/methods/messages/send_contact.py index 96b23a9b..bed9a37e 100644 --- a/pyrogram/client/methods/messages/send_contact.py +++ b/pyrogram/client/methods/messages/send_contact.py @@ -24,18 +24,22 @@ from pyrogram.client.ext import BaseClient class SendContact(BaseClient): - def send_contact(self, - chat_id: Union[int, str], - phone_number: str, - first_name: str, - last_name: str = "", - vcard: str = "", - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + def send_contact( + self, + chat_id: Union[int, str], + phone_number: str, + first_name: str, + last_name: str = "", + vcard: str = "", + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ) -> "pyrogram.Message": """Use this method to send phone contacts. Args: diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 6dc496e4..2693697a 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -28,20 +28,24 @@ from pyrogram.client.ext import BaseClient, utils class SendDocument(BaseClient): - def send_document(self, - chat_id: Union[int, str], - document: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_document( + self, + chat_id: Union[int, str], + document: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send general files. Args: diff --git a/pyrogram/client/methods/messages/send_location.py b/pyrogram/client/methods/messages/send_location.py index 5fe57904..c59ea380 100644 --- a/pyrogram/client/methods/messages/send_location.py +++ b/pyrogram/client/methods/messages/send_location.py @@ -24,16 +24,20 @@ from pyrogram.client.ext import BaseClient class SendLocation(BaseClient): - def send_location(self, - chat_id: Union[int, str], - latitude: float, - longitude: float, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + def send_location( + self, + chat_id: Union[int, str], + latitude: float, + longitude: float, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ) -> "pyrogram.Message": """Use this method to send points on the map. Args: diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py index 42e4ddde..aff0a29f 100644 --- a/pyrogram/client/methods/messages/send_media_group.py +++ b/pyrogram/client/methods/messages/send_media_group.py @@ -34,11 +34,13 @@ log = logging.getLogger(__name__) class SendMediaGroup(BaseClient): # TODO: Add progress parameter # TODO: Figure out how to send albums using URLs - def send_media_group(self, - chat_id: Union[int, str], - media: List[Union["pyrogram.InputMediaPhoto", "pyrogram.InputMediaVideo"]], - disable_notification: bool = None, - reply_to_message_id: int = None): + def send_media_group( + self, + chat_id: Union[int, str], + media: List[Union["pyrogram.InputMediaPhoto", "pyrogram.InputMediaVideo"]], + disable_notification: bool = None, + reply_to_message_id: int = None + ): """Use this method to send a group of photos or videos as an album. Args: diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py index 6589fcd6..3913e97d 100644 --- a/pyrogram/client/methods/messages/send_message.py +++ b/pyrogram/client/methods/messages/send_message.py @@ -24,17 +24,21 @@ from ...ext import BaseClient class SendMessage(BaseClient): - def send_message(self, - chat_id: Union[int, str], - text: str, - parse_mode: str = "", - disable_web_page_preview: bool = None, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + def send_message( + self, + chat_id: Union[int, str], + text: str, + parse_mode: str = "", + disable_web_page_preview: bool = None, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ) -> "pyrogram.Message": """Use this method to send text messages. Args: diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py index 84647245..6892f92d 100644 --- a/pyrogram/client/methods/messages/send_photo.py +++ b/pyrogram/client/methods/messages/send_photo.py @@ -28,20 +28,24 @@ from pyrogram.client.ext import BaseClient, utils class SendPhoto(BaseClient): - def send_photo(self, - chat_id: Union[int, str], - photo: str, - caption: str = "", - parse_mode: str = "", - ttl_seconds: int = None, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_photo( + self, + chat_id: Union[int, str], + photo: str, + caption: str = "", + parse_mode: str = "", + ttl_seconds: int = None, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send photos. Args: diff --git a/pyrogram/client/methods/messages/send_poll.py b/pyrogram/client/methods/messages/send_poll.py index 8e938a1a..423f962d 100644 --- a/pyrogram/client/methods/messages/send_poll.py +++ b/pyrogram/client/methods/messages/send_poll.py @@ -24,16 +24,20 @@ from pyrogram.client.ext import BaseClient class SendPoll(BaseClient): - def send_poll(self, - chat_id: Union[int, str], - question: str, - options: List[str], - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + def send_poll \ + (self, + chat_id: Union[int, str], + question: str, + options: List[str], + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ) -> "pyrogram.Message": """Use this method to send a new poll. Args: diff --git a/pyrogram/client/methods/messages/send_sticker.py b/pyrogram/client/methods/messages/send_sticker.py index ba16a2e7..b4441cb1 100644 --- a/pyrogram/client/methods/messages/send_sticker.py +++ b/pyrogram/client/methods/messages/send_sticker.py @@ -28,17 +28,21 @@ from pyrogram.client.ext import BaseClient, utils class SendSticker(BaseClient): - def send_sticker(self, - chat_id: Union[int, str], - sticker: str, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_sticker( + self, + chat_id: Union[int, str], + sticker: str, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send .webp stickers. Args: diff --git a/pyrogram/client/methods/messages/send_venue.py b/pyrogram/client/methods/messages/send_venue.py index 163be38e..cc98eb28 100644 --- a/pyrogram/client/methods/messages/send_venue.py +++ b/pyrogram/client/methods/messages/send_venue.py @@ -24,20 +24,24 @@ from pyrogram.client.ext import BaseClient class SendVenue(BaseClient): - def send_venue(self, - chat_id: Union[int, str], - latitude: float, - longitude: float, - title: str, - address: str, - foursquare_id: str = "", - foursquare_type: str = "", - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None) -> "pyrogram.Message": + def send_venue( + self, + chat_id: Union[int, str], + latitude: float, + longitude: float, + title: str, + address: str, + foursquare_id: str = "", + foursquare_type: str = "", + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None + ) -> "pyrogram.Message": """Use this method to send information about a venue. Args: diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index 0224eaf6..bb90bdf6 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -28,24 +28,28 @@ from pyrogram.client.ext import BaseClient, utils class SendVideo(BaseClient): - def send_video(self, - chat_id: Union[int, str], - video: str, - caption: str = "", - parse_mode: str = "", - duration: int = 0, - width: int = 0, - height: int = 0, - thumb: str = None, - supports_streaming: bool = True, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_video( + self, + chat_id: Union[int, str], + video: str, + caption: str = "", + parse_mode: str = "", + duration: int = 0, + width: int = 0, + height: int = 0, + thumb: str = None, + supports_streaming: bool = True, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send video files. Args: diff --git a/pyrogram/client/methods/messages/send_video_note.py b/pyrogram/client/methods/messages/send_video_note.py index b35dbea6..349b76a6 100644 --- a/pyrogram/client/methods/messages/send_video_note.py +++ b/pyrogram/client/methods/messages/send_video_note.py @@ -28,20 +28,24 @@ from pyrogram.client.ext import BaseClient, utils class SendVideoNote(BaseClient): - def send_video_note(self, - chat_id: Union[int, str], - video_note: str, - duration: int = 0, - length: int = 1, - thumb: str = None, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_video_note( + self, + chat_id: Union[int, str], + video_note: str, + duration: int = 0, + length: int = 1, + thumb: str = None, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send video messages. Args: diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py index 33261db6..10b3c906 100644 --- a/pyrogram/client/methods/messages/send_voice.py +++ b/pyrogram/client/methods/messages/send_voice.py @@ -28,20 +28,24 @@ from pyrogram.client.ext import BaseClient, utils class SendVoice(BaseClient): - def send_voice(self, - chat_id: Union[int, str], - voice: str, - caption: str = "", - parse_mode: str = "", - duration: int = 0, - disable_notification: bool = None, - reply_to_message_id: int = None, - reply_markup: Union["pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply"] = None, - progress: callable = None, - progress_args: tuple = ()) -> Union["pyrogram.Message", None]: + def send_voice( + self, + chat_id: Union[int, str], + voice: str, + caption: str = "", + parse_mode: str = "", + duration: int = 0, + disable_notification: bool = None, + reply_to_message_id: int = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None, + progress: callable = None, + progress_args: tuple = () + ) -> Union["pyrogram.Message", None]: """Use this method to send audio files. Args: diff --git a/pyrogram/client/methods/messages/vote_poll.py b/pyrogram/client/methods/messages/vote_poll.py index 9e400e62..bf44c831 100644 --- a/pyrogram/client/methods/messages/vote_poll.py +++ b/pyrogram/client/methods/messages/vote_poll.py @@ -23,10 +23,12 @@ from pyrogram.client.ext import BaseClient class VotePoll(BaseClient): - def vote_poll(self, - chat_id: Union[int, str], - message_id: id, - option: int) -> bool: + def vote_poll( + self, + chat_id: Union[int, str], + message_id: id, + option: int + ) -> bool: """Use this method to vote a poll. Args: diff --git a/pyrogram/client/methods/password/change_cloud_password.py b/pyrogram/client/methods/password/change_cloud_password.py index 3504dab1..163144bf 100644 --- a/pyrogram/client/methods/password/change_cloud_password.py +++ b/pyrogram/client/methods/password/change_cloud_password.py @@ -24,10 +24,12 @@ from ...ext import BaseClient class ChangeCloudPassword(BaseClient): - def change_cloud_password(self, - current_password: str, - new_password: str, - new_hint: str = "") -> bool: + def change_cloud_password( + self, + current_password: str, + new_password: str, + new_hint: str = "" + ) -> bool: """Use this method to change your Two-Step Verification password (Cloud Password) with a new one. Args: diff --git a/pyrogram/client/methods/password/enable_cloud_password.py b/pyrogram/client/methods/password/enable_cloud_password.py index 980f50fd..6e7a0bc9 100644 --- a/pyrogram/client/methods/password/enable_cloud_password.py +++ b/pyrogram/client/methods/password/enable_cloud_password.py @@ -24,10 +24,12 @@ from ...ext import BaseClient class EnableCloudPassword(BaseClient): - def enable_cloud_password(self, - password: str, - hint: str = "", - email: str = None) -> bool: + def enable_cloud_password( + self, + password: str, + hint: str = "", + email: str = None + ) -> bool: """Use this method to enable the Two-Step Verification security feature (Cloud Password) on your account. This password will be asked when you log-in on a new device in addition to the SMS code. diff --git a/pyrogram/client/methods/password/remove_cloud_password.py b/pyrogram/client/methods/password/remove_cloud_password.py index 6817ab12..e7c7ed2d 100644 --- a/pyrogram/client/methods/password/remove_cloud_password.py +++ b/pyrogram/client/methods/password/remove_cloud_password.py @@ -22,8 +22,10 @@ from ...ext import BaseClient class RemoveCloudPassword(BaseClient): - def remove_cloud_password(self, - password: str) -> bool: + def remove_cloud_password( + self, + password: str + ) -> bool: """Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account. Args: diff --git a/pyrogram/client/methods/users/delete_user_profile_photos.py b/pyrogram/client/methods/users/delete_user_profile_photos.py index 025a5e95..84c68dd4 100644 --- a/pyrogram/client/methods/users/delete_user_profile_photos.py +++ b/pyrogram/client/methods/users/delete_user_profile_photos.py @@ -25,8 +25,10 @@ from ...ext import BaseClient class DeleteUserProfilePhotos(BaseClient): - def delete_user_profile_photos(self, - id: Union[str, List[str]]) -> bool: + def delete_user_profile_photos( + self, + id: Union[str, List[str]] + ) -> bool: """Use this method to delete your own profile photos Args: diff --git a/pyrogram/client/methods/users/get_user_profile_photos.py b/pyrogram/client/methods/users/get_user_profile_photos.py index 2129dba3..d23ec48d 100644 --- a/pyrogram/client/methods/users/get_user_profile_photos.py +++ b/pyrogram/client/methods/users/get_user_profile_photos.py @@ -24,10 +24,12 @@ from ...ext import BaseClient class GetUserProfilePhotos(BaseClient): - def get_user_profile_photos(self, - user_id: Union[int, str], - offset: int = 0, - limit: int = 100) -> "pyrogram.UserProfilePhotos": + def get_user_profile_photos( + self, + user_id: Union[int, str], + offset: int = 0, + limit: int = 100 + ) -> "pyrogram.UserProfilePhotos": """Use this method to get a list of profile pictures for a user. Args: diff --git a/pyrogram/client/methods/users/get_users.py b/pyrogram/client/methods/users/get_users.py index 6c340ffa..d3822dc9 100644 --- a/pyrogram/client/methods/users/get_users.py +++ b/pyrogram/client/methods/users/get_users.py @@ -24,8 +24,10 @@ from ...ext import BaseClient class GetUsers(BaseClient): - def get_users(self, - user_ids: Iterable[Union[int, str]]) -> Union["pyrogram.User", List["pyrogram.User"]]: + def get_users( + self, + user_ids: Iterable[Union[int, str]] + ) -> Union["pyrogram.User", List["pyrogram.User"]]: """Use this method to get information about a user. You can retrieve up to 200 users at once. diff --git a/pyrogram/client/methods/users/set_user_profile_photo.py b/pyrogram/client/methods/users/set_user_profile_photo.py index 359a0cd0..705631fd 100644 --- a/pyrogram/client/methods/users/set_user_profile_photo.py +++ b/pyrogram/client/methods/users/set_user_profile_photo.py @@ -21,8 +21,10 @@ from ...ext import BaseClient class SetUserProfilePhoto(BaseClient): - def set_user_profile_photo(self, - photo: str) -> bool: + def set_user_profile_photo( + self, + photo: str + ) -> bool: """Use this method to set a new profile photo. This method only works for Users. diff --git a/pyrogram/client/methods/users/update_username.py b/pyrogram/client/methods/users/update_username.py index 9a4feb23..5fd1a711 100644 --- a/pyrogram/client/methods/users/update_username.py +++ b/pyrogram/client/methods/users/update_username.py @@ -23,8 +23,10 @@ from ...ext import BaseClient class UpdateUsername(BaseClient): - def update_username(self, - username: Union[str, None]) -> bool: + def update_username( + self, + username: Union[str, None] + ) -> bool: """Use this method to update your own username. This method only works for users, not bots. Bot usernames must be changed via Bot Support or by recreating diff --git a/pyrogram/client/types/bots/callback_query.py b/pyrogram/client/types/bots/callback_query.py index a7a9ad53..4497747e 100644 --- a/pyrogram/client/types/bots/callback_query.py +++ b/pyrogram/client/types/bots/callback_query.py @@ -61,16 +61,16 @@ class CallbackQuery(PyrogramType, Update): __slots__ = ["id", "from_user", "chat_instance", "message", "inline_message_id", "data", "game_short_name"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - id: str, - from_user: User, - chat_instance: str, - message: "pyrogram.Message" = None, - inline_message_id: str = None, - data: bytes = None, - game_short_name: str = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: str, + from_user: User, + chat_instance: str, + message: "pyrogram.Message" = None, + inline_message_id: str = None, + data: bytes = None, + game_short_name: str = None ): super().__init__(client) diff --git a/pyrogram/client/types/bots/force_reply.py b/pyrogram/client/types/bots/force_reply.py index 7838ee88..fca2c061 100644 --- a/pyrogram/client/types/bots/force_reply.py +++ b/pyrogram/client/types/bots/force_reply.py @@ -36,8 +36,8 @@ class ForceReply(PyrogramType): __slots__ = ["selective"] def __init__( - self, - selective: bool = None + self, + selective: bool = None ): super().__init__(None) diff --git a/pyrogram/client/types/bots/game_high_score.py b/pyrogram/client/types/bots/game_high_score.py index 4fc3c6f8..da6b2881 100644 --- a/pyrogram/client/types/bots/game_high_score.py +++ b/pyrogram/client/types/bots/game_high_score.py @@ -40,12 +40,12 @@ class GameHighScore(PyrogramType): __slots__ = ["user", "score", "position"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - user: User, - score: int, - position: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + user: User, + score: int, + position: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/bots/game_high_scores.py b/pyrogram/client/types/bots/game_high_scores.py index 25e4af5d..3c197969 100644 --- a/pyrogram/client/types/bots/game_high_scores.py +++ b/pyrogram/client/types/bots/game_high_scores.py @@ -38,11 +38,11 @@ class GameHighScores(PyrogramType): __slots__ = ["total_count", "game_high_scores"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - game_high_scores: List[GameHighScore] + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + game_high_scores: List[GameHighScore] ): super().__init__(client) diff --git a/pyrogram/client/types/bots/inline_keyboard_button.py b/pyrogram/client/types/bots/inline_keyboard_button.py index cca42b33..ff6f3cdb 100644 --- a/pyrogram/client/types/bots/inline_keyboard_button.py +++ b/pyrogram/client/types/bots/inline_keyboard_button.py @@ -59,13 +59,13 @@ class InlineKeyboardButton(PyrogramType): ] def __init__( - self, - text: str, - callback_data: bytes = None, - url: str = None, - switch_inline_query: str = None, - switch_inline_query_current_chat: str = None, - callback_game: CallbackGame = None + self, + text: str, + callback_data: bytes = None, + url: str = None, + switch_inline_query: str = None, + switch_inline_query_current_chat: str = None, + callback_game: CallbackGame = None ): super().__init__(None) diff --git a/pyrogram/client/types/bots/inline_keyboard_markup.py b/pyrogram/client/types/bots/inline_keyboard_markup.py index 77e9cfeb..54476c5e 100644 --- a/pyrogram/client/types/bots/inline_keyboard_markup.py +++ b/pyrogram/client/types/bots/inline_keyboard_markup.py @@ -34,8 +34,8 @@ class InlineKeyboardMarkup(PyrogramType): __slots__ = ["inline_keyboard"] def __init__( - self, - inline_keyboard: List[List[InlineKeyboardButton]] + self, + inline_keyboard: List[List[InlineKeyboardButton]] ): super().__init__(None) diff --git a/pyrogram/client/types/bots/keyboard_button.py b/pyrogram/client/types/bots/keyboard_button.py index b8786cee..477442cc 100644 --- a/pyrogram/client/types/bots/keyboard_button.py +++ b/pyrogram/client/types/bots/keyboard_button.py @@ -43,10 +43,10 @@ class KeyboardButton(PyrogramType): __slots__ = ["text", "request_contact", "request_location"] def __init__( - self, - text: str, - request_contact: bool = None, - request_location: bool = None + self, + text: str, + request_contact: bool = None, + request_location: bool = None ): super().__init__(None) diff --git a/pyrogram/client/types/bots/reply_keyboard_markup.py b/pyrogram/client/types/bots/reply_keyboard_markup.py index 431a55eb..b0216803 100644 --- a/pyrogram/client/types/bots/reply_keyboard_markup.py +++ b/pyrogram/client/types/bots/reply_keyboard_markup.py @@ -52,11 +52,11 @@ class ReplyKeyboardMarkup(PyrogramType): __slots__ = ["keyboard", "resize_keyboard", "one_time_keyboard", "selective"] def __init__( - self, - keyboard: List[List[Union[KeyboardButton, str]]], - resize_keyboard: bool = None, - one_time_keyboard: bool = None, - selective: bool = None + self, + keyboard: List[List[Union[KeyboardButton, str]]], + resize_keyboard: bool = None, + one_time_keyboard: bool = None, + selective: bool = None ): super().__init__(None) diff --git a/pyrogram/client/types/bots/reply_keyboard_remove.py b/pyrogram/client/types/bots/reply_keyboard_remove.py index 2fb5fe19..3298ab6f 100644 --- a/pyrogram/client/types/bots/reply_keyboard_remove.py +++ b/pyrogram/client/types/bots/reply_keyboard_remove.py @@ -38,8 +38,8 @@ class ReplyKeyboardRemove(PyrogramType): __slots__ = ["selective"] def __init__( - self, - selective: bool = None + self, + selective: bool = None ): super().__init__(None) diff --git a/pyrogram/client/types/input_media/input_media.py b/pyrogram/client/types/input_media/input_media.py index 677d4918..aeeef350 100644 --- a/pyrogram/client/types/input_media/input_media.py +++ b/pyrogram/client/types/input_media/input_media.py @@ -21,10 +21,10 @@ class InputMedia: __slots__ = ["media", "caption", "parse_mode"] def __init__( - self, - media: str, - caption: str, - parse_mode: str + self, + media: str, + caption: str, + parse_mode: str ): self.media = media self.caption = caption diff --git a/pyrogram/client/types/input_media/input_media_animation.py b/pyrogram/client/types/input_media/input_media_animation.py index 20debb19..e77499b5 100644 --- a/pyrogram/client/types/input_media/input_media_animation.py +++ b/pyrogram/client/types/input_media/input_media_animation.py @@ -55,14 +55,14 @@ class InputMediaAnimation(InputMedia): __slots__ = ["thumb", "width", "height", "duration"] def __init__( - self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - width: int = 0, - height: int = 0, - duration: int = 0 + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + width: int = 0, + height: int = 0, + duration: int = 0 ): super().__init__(media, caption, parse_mode) diff --git a/pyrogram/client/types/input_media/input_media_audio.py b/pyrogram/client/types/input_media/input_media_audio.py index 2709a409..e8f1c257 100644 --- a/pyrogram/client/types/input_media/input_media_audio.py +++ b/pyrogram/client/types/input_media/input_media_audio.py @@ -56,14 +56,14 @@ class InputMediaAudio(InputMedia): __slots__ = ["thumb", "duration", "performer", "title"] def __init__( - self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - duration: int = 0, - performer: int = "", - title: str = "" + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + duration: int = 0, + performer: int = "", + title: str = "" ): super().__init__(media, caption, parse_mode) diff --git a/pyrogram/client/types/input_media/input_media_document.py b/pyrogram/client/types/input_media/input_media_document.py index 2c0c628d..9391e7d8 100644 --- a/pyrogram/client/types/input_media/input_media_document.py +++ b/pyrogram/client/types/input_media/input_media_document.py @@ -46,11 +46,11 @@ class InputMediaDocument(InputMedia): __slots__ = ["thumb"] def __init__( - self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "" + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "" ): super().__init__(media, caption, parse_mode) diff --git a/pyrogram/client/types/input_media/input_media_photo.py b/pyrogram/client/types/input_media/input_media_photo.py index 5618b843..e6bba03b 100644 --- a/pyrogram/client/types/input_media/input_media_photo.py +++ b/pyrogram/client/types/input_media/input_media_photo.py @@ -42,9 +42,9 @@ class InputMediaPhoto(InputMedia): __slots__ = [] def __init__( - self, - media: str, - caption: str = "", - parse_mode: str = "" + self, + media: str, + caption: str = "", + parse_mode: str = "" ): super().__init__(media, caption, parse_mode) diff --git a/pyrogram/client/types/input_media/input_media_video.py b/pyrogram/client/types/input_media/input_media_video.py index b55a9438..5c918f13 100644 --- a/pyrogram/client/types/input_media/input_media_video.py +++ b/pyrogram/client/types/input_media/input_media_video.py @@ -60,15 +60,15 @@ class InputMediaVideo(InputMedia): __slots__ = ["thumb", "width", "height", "duration", "supports_streaming"] def __init__( - self, - media: str, - thumb: str = None, - caption: str = "", - parse_mode: str = "", - width: int = 0, - height: int = 0, - duration: int = 0, - supports_streaming: bool = True + self, + media: str, + thumb: str = None, + caption: str = "", + parse_mode: str = "", + width: int = 0, + height: int = 0, + duration: int = 0, + supports_streaming: bool = True ): super().__init__(media, caption, parse_mode) diff --git a/pyrogram/client/types/input_media/input_phone_contact.py b/pyrogram/client/types/input_media/input_phone_contact.py index 340b335f..4fe7ee60 100644 --- a/pyrogram/client/types/input_media/input_phone_contact.py +++ b/pyrogram/client/types/input_media/input_phone_contact.py @@ -38,10 +38,10 @@ class InputPhoneContact: __slots__ = [] def __init__( - self, - phone: str, - first_name: str, - last_name: str = "" + self, + phone: str, + first_name: str, + last_name: str = "" ): pass diff --git a/pyrogram/client/types/messages_and_media/animation.py b/pyrogram/client/types/messages_and_media/animation.py index 978c88c9..21a01e0f 100644 --- a/pyrogram/client/types/messages_and_media/animation.py +++ b/pyrogram/client/types/messages_and_media/animation.py @@ -60,18 +60,18 @@ class Animation(PyrogramType): __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "duration"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - duration: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + duration: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/audio.py b/pyrogram/client/types/messages_and_media/audio.py index 334e022e..db49f2eb 100644 --- a/pyrogram/client/types/messages_and_media/audio.py +++ b/pyrogram/client/types/messages_and_media/audio.py @@ -60,18 +60,18 @@ class Audio(PyrogramType): __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "duration", "performer", "title"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - duration: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None, - performer: str = None, - title: str = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + duration: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None, + performer: str = None, + title: str = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/contact.py b/pyrogram/client/types/messages_and_media/contact.py index 0a897c05..5abe5319 100644 --- a/pyrogram/client/types/messages_and_media/contact.py +++ b/pyrogram/client/types/messages_and_media/contact.py @@ -45,14 +45,14 @@ class Contact(PyrogramType): __slots__ = ["phone_number", "first_name", "last_name", "user_id", "vcard"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - phone_number: str, - first_name: str, - last_name: str = None, - user_id: int = None, - vcard: str = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + phone_number: str, + first_name: str, + last_name: str = None, + user_id: int = None, + vcard: str = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/document.py b/pyrogram/client/types/messages_and_media/document.py index b3f5b586..f3ccc4f8 100644 --- a/pyrogram/client/types/messages_and_media/document.py +++ b/pyrogram/client/types/messages_and_media/document.py @@ -51,15 +51,15 @@ class Document(PyrogramType): __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/game.py b/pyrogram/client/types/messages_and_media/game.py index ddfa84af..cf0b4fa6 100644 --- a/pyrogram/client/types/messages_and_media/game.py +++ b/pyrogram/client/types/messages_and_media/game.py @@ -51,15 +51,15 @@ class Game(PyrogramType): __slots__ = ["id", "title", "short_name", "description", "photo", "animation"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - title: str, - short_name: str, - description: str, - photo: Photo, - animation: Animation = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + title: str, + short_name: str, + description: str, + photo: Photo, + animation: Animation = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/location.py b/pyrogram/client/types/messages_and_media/location.py index 0d2e6c43..3a7f6d38 100644 --- a/pyrogram/client/types/messages_and_media/location.py +++ b/pyrogram/client/types/messages_and_media/location.py @@ -36,11 +36,11 @@ class Location(PyrogramType): __slots__ = ["longitude", "latitude"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - longitude: float, - latitude: float + self, + *, + client: "pyrogram.client.ext.BaseClient", + longitude: float, + latitude: float ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 405c26d9..9a4e4314 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -246,67 +246,67 @@ class Message(PyrogramType, Update): ] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - message_id: int, - date: int = None, - chat: Chat = None, - from_user: User = None, - forward_from: User = None, - forward_from_chat: Chat = None, - forward_from_message_id: int = None, - forward_signature: str = None, - forward_date: int = None, - reply_to_message: "Message" = None, - mentioned: bool = None, - empty: bool = None, - service: bool = None, - media: bool = None, - edit_date: int = None, - media_group_id: str = None, - author_signature: str = None, - text: str = None, - entities: List["pyrogram.MessageEntity"] = None, - caption_entities: List["pyrogram.MessageEntity"] = None, - audio: "pyrogram.Audio" = None, - document: "pyrogram.Document" = None, - photo: "pyrogram.Photo" = None, - sticker: "pyrogram.Sticker" = None, - animation: "pyrogram.Animation" = None, - game: "pyrogram.Game" = None, - video: "pyrogram.Video" = None, - voice: "pyrogram.Voice" = None, - video_note: "pyrogram.VideoNote" = None, - caption: str = None, - contact: "pyrogram.Contact" = None, - location: "pyrogram.Location" = None, - venue: "pyrogram.Venue" = None, - web_page: bool = None, - poll: "pyrogram.Poll" = None, - new_chat_members: List[User] = None, - left_chat_member: User = None, - new_chat_title: str = None, - new_chat_photo: "pyrogram.Photo" = None, - delete_chat_photo: bool = None, - group_chat_created: bool = None, - supergroup_chat_created: bool = None, - channel_chat_created: bool = None, - migrate_to_chat_id: int = None, - migrate_from_chat_id: int = None, - pinned_message: "Message" = None, - game_high_score: int = None, - views: int = None, - via_bot: User = None, - outgoing: bool = None, - matches: List[Match] = None, - command: List[str] = None, - reply_markup: Union[ - "pyrogram.InlineKeyboardMarkup", - "pyrogram.ReplyKeyboardMarkup", - "pyrogram.ReplyKeyboardRemove", - "pyrogram.ForceReply" - ] = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + message_id: int, + date: int = None, + chat: Chat = None, + from_user: User = None, + forward_from: User = None, + forward_from_chat: Chat = None, + forward_from_message_id: int = None, + forward_signature: str = None, + forward_date: int = None, + reply_to_message: "Message" = None, + mentioned: bool = None, + empty: bool = None, + service: bool = None, + media: bool = None, + edit_date: int = None, + media_group_id: str = None, + author_signature: str = None, + text: str = None, + entities: List["pyrogram.MessageEntity"] = None, + caption_entities: List["pyrogram.MessageEntity"] = None, + audio: "pyrogram.Audio" = None, + document: "pyrogram.Document" = None, + photo: "pyrogram.Photo" = None, + sticker: "pyrogram.Sticker" = None, + animation: "pyrogram.Animation" = None, + game: "pyrogram.Game" = None, + video: "pyrogram.Video" = None, + voice: "pyrogram.Voice" = None, + video_note: "pyrogram.VideoNote" = None, + caption: str = None, + contact: "pyrogram.Contact" = None, + location: "pyrogram.Location" = None, + venue: "pyrogram.Venue" = None, + web_page: bool = None, + poll: "pyrogram.Poll" = None, + new_chat_members: List[User] = None, + left_chat_member: User = None, + new_chat_title: str = None, + new_chat_photo: "pyrogram.Photo" = None, + delete_chat_photo: bool = None, + group_chat_created: bool = None, + supergroup_chat_created: bool = None, + channel_chat_created: bool = None, + migrate_to_chat_id: int = None, + migrate_from_chat_id: int = None, + pinned_message: "Message" = None, + game_high_score: int = None, + views: int = None, + via_bot: User = None, + outgoing: bool = None, + matches: List[Match] = None, + command: List[str] = None, + reply_markup: Union[ + "pyrogram.InlineKeyboardMarkup", + "pyrogram.ReplyKeyboardMarkup", + "pyrogram.ReplyKeyboardRemove", + "pyrogram.ForceReply" + ] = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/message_entity.py b/pyrogram/client/types/messages_and_media/message_entity.py index fa59a5bc..160d0d1e 100644 --- a/pyrogram/client/types/messages_and_media/message_entity.py +++ b/pyrogram/client/types/messages_and_media/message_entity.py @@ -66,14 +66,14 @@ class MessageEntity(PyrogramType): } def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - type: str, - offset: int, - length: int, - url: str = None, - user: User = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + type: str, + offset: int, + length: int, + url: str = None, + user: User = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/messages.py b/pyrogram/client/types/messages_and_media/messages.py index 4a203a4e..9983a01d 100644 --- a/pyrogram/client/types/messages_and_media/messages.py +++ b/pyrogram/client/types/messages_and_media/messages.py @@ -40,11 +40,11 @@ class Messages(PyrogramType, Update): __slots__ = ["total_count", "messages"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - messages: List[Message] + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + messages: List[Message] ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/photo.py b/pyrogram/client/types/messages_and_media/photo.py index 12be919c..6f1852fb 100644 --- a/pyrogram/client/types/messages_and_media/photo.py +++ b/pyrogram/client/types/messages_and_media/photo.py @@ -44,12 +44,12 @@ class Photo(PyrogramType): __slots__ = ["id", "date", "sizes"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - id: str, - date: int, - sizes: List[PhotoSize] + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: str, + date: int, + sizes: List[PhotoSize] ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/photo_size.py b/pyrogram/client/types/messages_and_media/photo_size.py index 03569062..10d00a86 100644 --- a/pyrogram/client/types/messages_and_media/photo_size.py +++ b/pyrogram/client/types/messages_and_media/photo_size.py @@ -45,13 +45,13 @@ class PhotoSize(PyrogramType): __slots__ = ["file_id", "width", "height", "file_size"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - file_size: int + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + file_size: int ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py index fa6372d9..68667334 100644 --- a/pyrogram/client/types/messages_and_media/poll.py +++ b/pyrogram/client/types/messages_and_media/poll.py @@ -50,15 +50,15 @@ class Poll(PyrogramType): __slots__ = ["id", "closed", "question", "options", "total_voters", "option_chosen"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - closed: bool, - question: str, - options: List[PollOption], - total_voters: int, - option_chosen: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + closed: bool, + question: str, + options: List[PollOption], + total_voters: int, + option_chosen: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/poll_option.py b/pyrogram/client/types/messages_and_media/poll_option.py index 1c2d6f1b..a2be866e 100644 --- a/pyrogram/client/types/messages_and_media/poll_option.py +++ b/pyrogram/client/types/messages_and_media/poll_option.py @@ -37,12 +37,12 @@ class PollOption(PyrogramType): __slots__ = ["text", "voters", "data"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - text: str, - voters: int, - data: bytes + self, + *, + client: "pyrogram.client.ext.BaseClient", + text: str, + voters: int, + data: bytes ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/sticker.py b/pyrogram/client/types/messages_and_media/sticker.py index ce390b1d..43fb6e98 100644 --- a/pyrogram/client/types/messages_and_media/sticker.py +++ b/pyrogram/client/types/messages_and_media/sticker.py @@ -69,19 +69,19 @@ class Sticker(PyrogramType): ] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None, - emoji: str = None, - set_name: str = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None, + emoji: str = None, + set_name: str = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/user_profile_photos.py b/pyrogram/client/types/messages_and_media/user_profile_photos.py index 770b0ec8..f162b077 100644 --- a/pyrogram/client/types/messages_and_media/user_profile_photos.py +++ b/pyrogram/client/types/messages_and_media/user_profile_photos.py @@ -37,11 +37,11 @@ class UserProfilePhotos(PyrogramType): __slots__ = ["total_count", "photos"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - photos: List[Photo] + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + photos: List[Photo] ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/venue.py b/pyrogram/client/types/messages_and_media/venue.py index 5dd81093..97829142 100644 --- a/pyrogram/client/types/messages_and_media/venue.py +++ b/pyrogram/client/types/messages_and_media/venue.py @@ -47,14 +47,14 @@ class Venue(PyrogramType): __slots__ = ["location", "title", "address", "foursquare_id", "foursquare_type"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - location: Location, - title: str, - address: str, - foursquare_id: str = None, - foursquare_type: str = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + location: Location, + title: str, + address: str, + foursquare_id: str = None, + foursquare_type: str = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/video.py b/pyrogram/client/types/messages_and_media/video.py index 39ec1455..caf34ce9 100644 --- a/pyrogram/client/types/messages_and_media/video.py +++ b/pyrogram/client/types/messages_and_media/video.py @@ -60,18 +60,18 @@ class Video(PyrogramType): __slots__ = ["file_id", "thumb", "file_name", "mime_type", "file_size", "date", "width", "height", "duration"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - width: int, - height: int, - duration: int, - thumb: PhotoSize = None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + width: int, + height: int, + duration: int, + thumb: PhotoSize = None, + file_name: str = None, + mime_type: str = None, + file_size: int = None, + date: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/video_note.py b/pyrogram/client/types/messages_and_media/video_note.py index afa4ad46..a1b3856c 100644 --- a/pyrogram/client/types/messages_and_media/video_note.py +++ b/pyrogram/client/types/messages_and_media/video_note.py @@ -54,16 +54,16 @@ class VideoNote(PyrogramType): __slots__ = ["file_id", "thumb", "mime_type", "file_size", "date", "length", "duration"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - length: int, - duration: int, - thumb: PhotoSize = None, - mime_type: str = None, - file_size: int = None, - date: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + length: int, + duration: int, + thumb: PhotoSize = None, + mime_type: str = None, + file_size: int = None, + date: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/messages_and_media/voice.py b/pyrogram/client/types/messages_and_media/voice.py index d5028cd3..b4063088 100644 --- a/pyrogram/client/types/messages_and_media/voice.py +++ b/pyrogram/client/types/messages_and_media/voice.py @@ -50,15 +50,15 @@ class Voice(PyrogramType): __slots__ = ["file_id", "duration", "waveform", "mime_type", "file_size", "date"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - file_id: str, - duration: int, - waveform: bytes = None, - mime_type: str = None, - file_size: int = None, - date: int = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + file_id: str, + duration: int, + waveform: bytes = None, + mime_type: str = None, + file_size: int = None, + date: int = None ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index 81067821..5488b846 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -87,24 +87,24 @@ class Chat(PyrogramType): ] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - type: str, - title: str = None, - username: str = None, - first_name: str = None, - last_name: str = None, - photo: ChatPhoto = None, - description: str = None, - invite_link: str = None, - pinned_message=None, - sticker_set_name: str = None, - can_set_sticker_set: bool = None, - members_count: int = None, - restriction_reason: str = None, - permissions: "pyrogram.ChatPermissions" = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + type: str, + title: str = None, + username: str = None, + first_name: str = None, + last_name: str = None, + photo: ChatPhoto = None, + description: str = None, + invite_link: str = None, + pinned_message=None, + sticker_set_name: str = None, + can_set_sticker_set: bool = None, + members_count: int = None, + restriction_reason: str = None, + permissions: "pyrogram.ChatPermissions" = None ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/chat_member.py b/pyrogram/client/types/user_and_chats/chat_member.py index 07a3d190..35911210 100644 --- a/pyrogram/client/types/user_and_chats/chat_member.py +++ b/pyrogram/client/types/user_and_chats/chat_member.py @@ -54,16 +54,16 @@ class ChatMember(PyrogramType): __slots__ = ["user", "status", "date", "invited_by", "promoted_by", "restricted_by", "permissions"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - user: "pyrogram.User", - status: str, - date: int = None, - invited_by: "pyrogram.User" = None, - promoted_by: "pyrogram.User" = None, - restricted_by: "pyrogram.User" = None, - permissions: "pyrogram.ChatPermissions" = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + user: "pyrogram.User", + status: str, + date: int = None, + invited_by: "pyrogram.User" = None, + promoted_by: "pyrogram.User" = None, + restricted_by: "pyrogram.User" = None, + permissions: "pyrogram.ChatPermissions" = None ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/chat_members.py b/pyrogram/client/types/user_and_chats/chat_members.py index 0578e04e..3c89b124 100644 --- a/pyrogram/client/types/user_and_chats/chat_members.py +++ b/pyrogram/client/types/user_and_chats/chat_members.py @@ -38,11 +38,11 @@ class ChatMembers(PyrogramType): __slots__ = ["total_count", "chat_members"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - chat_members: List[ChatMember] + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + chat_members: List[ChatMember] ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/chat_photo.py b/pyrogram/client/types/user_and_chats/chat_photo.py index deec5770..6fbc779d 100644 --- a/pyrogram/client/types/user_and_chats/chat_photo.py +++ b/pyrogram/client/types/user_and_chats/chat_photo.py @@ -38,11 +38,11 @@ class ChatPhoto(PyrogramType): __slots__ = ["small_file_id", "big_file_id"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - small_file_id: str, - big_file_id: str + self, + *, + client: "pyrogram.client.ext.BaseClient", + small_file_id: str, + big_file_id: str ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/chat_preview.py b/pyrogram/client/types/user_and_chats/chat_preview.py index 9c9c71ec..ddd84b09 100644 --- a/pyrogram/client/types/user_and_chats/chat_preview.py +++ b/pyrogram/client/types/user_and_chats/chat_preview.py @@ -48,14 +48,14 @@ class ChatPreview(PyrogramType): __slots__ = ["title", "photo", "type", "members_count", "members"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - title: str, - photo: ChatPhoto, - type: str, - members_count: int, - members: List[User] = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + title: str, + photo: ChatPhoto, + type: str, + members_count: int, + members: List[User] = None ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/dialog.py b/pyrogram/client/types/user_and_chats/dialog.py index 11a1ae19..1bbd3b4b 100644 --- a/pyrogram/client/types/user_and_chats/dialog.py +++ b/pyrogram/client/types/user_and_chats/dialog.py @@ -49,15 +49,15 @@ class Dialog(PyrogramType): __slots__ = ["chat", "top_message", "unread_messages_count", "unread_mentions_count", "unread_mark", "is_pinned"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - chat: Chat, - top_message: "pyrogram.Message", - unread_messages_count: int, - unread_mentions_count: int, - unread_mark: bool, - is_pinned: bool + self, + *, + client: "pyrogram.client.ext.BaseClient", + chat: Chat, + top_message: "pyrogram.Message", + unread_messages_count: int, + unread_mentions_count: int, + unread_mark: bool, + is_pinned: bool ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/dialogs.py b/pyrogram/client/types/user_and_chats/dialogs.py index 27222a91..bd29ea83 100644 --- a/pyrogram/client/types/user_and_chats/dialogs.py +++ b/pyrogram/client/types/user_and_chats/dialogs.py @@ -39,11 +39,11 @@ class Dialogs(PyrogramType): __slots__ = ["total_count", "dialogs"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - total_count: int, - dialogs: List[Dialog] + self, + *, + client: "pyrogram.client.ext.BaseClient", + total_count: int, + dialogs: List[Dialog] ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/user.py b/pyrogram/client/types/user_and_chats/user.py index f5c00ac0..5718b917 100644 --- a/pyrogram/client/types/user_and_chats/user.py +++ b/pyrogram/client/types/user_and_chats/user.py @@ -76,23 +76,23 @@ class User(PyrogramType): ] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - id: int, - is_self: bool, - is_contact: bool, - is_mutual_contact: bool, - is_deleted: bool, - is_bot: bool, - first_name: str, - last_name: str = None, - status: UserStatus = None, - username: str = None, - language_code: str = None, - phone_number: str = None, - photo: ChatPhoto = None, - restriction_reason: str = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + id: int, + is_self: bool, + is_contact: bool, + is_mutual_contact: bool, + is_deleted: bool, + is_bot: bool, + first_name: str, + last_name: str = None, + status: UserStatus = None, + username: str = None, + language_code: str = None, + phone_number: str = None, + photo: ChatPhoto = None, + restriction_reason: str = None ): super().__init__(client) diff --git a/pyrogram/client/types/user_and_chats/user_status.py b/pyrogram/client/types/user_and_chats/user_status.py index 871978d0..170ce373 100644 --- a/pyrogram/client/types/user_and_chats/user_status.py +++ b/pyrogram/client/types/user_and_chats/user_status.py @@ -68,17 +68,17 @@ class UserStatus(PyrogramType, Update): __slots__ = ["user_id", "online", "offline", "date", "recently", "within_week", "within_month", "long_time_ago"] def __init__( - self, - *, - client: "pyrogram.client.ext.BaseClient", - user_id: int, - online: bool = None, - offline: bool = None, - date: int = None, - recently: bool = None, - within_week: bool = None, - within_month: bool = None, - long_time_ago: bool = None + self, + *, + client: "pyrogram.client.ext.BaseClient", + user_id: int, + online: bool = None, + offline: bool = None, + date: int = None, + recently: bool = None, + within_week: bool = None, + within_month: bool = None, + long_time_ago: bool = None ): super().__init__(client) diff --git a/pyrogram/session/auth.py b/pyrogram/session/auth.py index 9d8e4b16..89e5b61f 100644 --- a/pyrogram/session/auth.py +++ b/pyrogram/session/auth.py @@ -45,10 +45,10 @@ class Auth: @staticmethod def pack(data: Object) -> bytes: return ( - bytes(8) - + Long(MsgId()) - + Int(len(data.write())) - + data.write() + bytes(8) + + Long(MsgId()) + + Int(len(data.write())) + + data.write() ) @staticmethod @@ -144,13 +144,13 @@ class Auth: new_nonce = new_nonce.to_bytes(32, "little", signed=True) tmp_aes_key = ( - sha1(new_nonce + server_nonce).digest() - + sha1(server_nonce + new_nonce).digest()[:12] + sha1(new_nonce + server_nonce).digest() + + sha1(server_nonce + new_nonce).digest()[:12] ) tmp_aes_iv = ( - sha1(server_nonce + new_nonce).digest()[12:] - + sha1(new_nonce + new_nonce).digest() + new_nonce[:4] + sha1(server_nonce + new_nonce).digest()[12:] + + sha1(new_nonce + new_nonce).digest() + new_nonce[:4] ) server_nonce = int.from_bytes(server_nonce, "little", signed=True)