diff --git a/pyrogram/client/methods/password/change_cloud_password.py b/pyrogram/client/methods/password/change_cloud_password.py index 045a0cc9..e066d8ba 100644 --- a/pyrogram/client/methods/password/change_cloud_password.py +++ b/pyrogram/client/methods/password/change_cloud_password.py @@ -24,7 +24,7 @@ from ...ext import BaseClient class ChangeCloudPassword(BaseClient): - def change_cloud_password(self, current_password: str, new_password: str, new_hint: str = ""): + async def change_cloud_password(self, current_password: str, new_password: str, new_hint: str = ""): """Use this method to change your Two-Step Verification password (Cloud Password) with a new one. Args: @@ -43,7 +43,7 @@ class ChangeCloudPassword(BaseClient): Raises: :class:`Error ` """ - r = self.send(functions.account.GetPassword()) + r = await self.send(functions.account.GetPassword()) if isinstance(r, types.account.Password): current_password_hash = sha256(r.current_salt + current_password.encode() + r.current_salt).digest() @@ -51,7 +51,7 @@ class ChangeCloudPassword(BaseClient): new_salt = r.new_salt + os.urandom(8) new_password_hash = sha256(new_salt + new_password.encode() + new_salt).digest() - return self.send( + return await self.send( functions.account.UpdatePasswordSettings( current_password_hash=current_password_hash, new_settings=types.account.PasswordInputSettings( diff --git a/pyrogram/client/methods/password/enable_cloud_password.py b/pyrogram/client/methods/password/enable_cloud_password.py index 639879cb..496430ad 100644 --- a/pyrogram/client/methods/password/enable_cloud_password.py +++ b/pyrogram/client/methods/password/enable_cloud_password.py @@ -24,7 +24,7 @@ from ...ext import BaseClient class EnableCloudPassword(BaseClient): - def enable_cloud_password(self, password: str, hint: str = "", email: str = ""): + async def enable_cloud_password(self, password: str, hint: str = "", email: str = ""): """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. @@ -45,13 +45,13 @@ class EnableCloudPassword(BaseClient): Raises: :class:`Error ` """ - r = self.send(functions.account.GetPassword()) + r = await self.send(functions.account.GetPassword()) if isinstance(r, types.account.NoPassword): salt = r.new_salt + os.urandom(8) password_hash = sha256(salt + password.encode() + salt).digest() - return self.send( + return await self.send( functions.account.UpdatePasswordSettings( current_password_hash=salt, new_settings=types.account.PasswordInputSettings( diff --git a/pyrogram/client/methods/password/remove_cloud_password.py b/pyrogram/client/methods/password/remove_cloud_password.py index bfbb2c8b..5392433f 100644 --- a/pyrogram/client/methods/password/remove_cloud_password.py +++ b/pyrogram/client/methods/password/remove_cloud_password.py @@ -23,7 +23,7 @@ from ...ext import BaseClient class RemoveCloudPassword(BaseClient): - def remove_cloud_password(self, password: str): + async def remove_cloud_password(self, password: str): """Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account. Args: @@ -36,12 +36,12 @@ class RemoveCloudPassword(BaseClient): Raises: :class:`Error ` """ - r = self.send(functions.account.GetPassword()) + r = await self.send(functions.account.GetPassword()) if isinstance(r, types.account.Password): password_hash = sha256(r.current_salt + password.encode() + r.current_salt).digest() - return self.send( + return await self.send( functions.account.UpdatePasswordSettings( current_password_hash=password_hash, new_settings=types.account.PasswordInputSettings( diff --git a/pyrogram/client/methods/users/get_me.py b/pyrogram/client/methods/users/get_me.py index 80ee65e9..f191e298 100644 --- a/pyrogram/client/methods/users/get_me.py +++ b/pyrogram/client/methods/users/get_me.py @@ -21,7 +21,7 @@ from ...ext import BaseClient, utils class GetMe(BaseClient): - def get_me(self): + async def get_me(self): """A simple method for testing your authorization. Requires no parameters. Returns: @@ -31,7 +31,7 @@ class GetMe(BaseClient): :class:`Error ` """ return utils.parse_user( - self.send( + await self.send( functions.users.GetFullUser( types.InputPeerSelf() ) diff --git a/pyrogram/client/methods/users/get_user_profile_photos.py b/pyrogram/client/methods/users/get_user_profile_photos.py index 42fb84bb..a58e9d52 100644 --- a/pyrogram/client/methods/users/get_user_profile_photos.py +++ b/pyrogram/client/methods/users/get_user_profile_photos.py @@ -21,10 +21,10 @@ from ...ext import BaseClient, utils class GetUserProfilePhotos(BaseClient): - def get_user_profile_photos(self, - user_id: int or str, - offset: int = 0, - limit: int = 100): + async def get_user_profile_photos(self, + user_id: int or str, + offset: int = 0, + limit: int = 100): """Use this method to get a list of profile pictures for a user. Args: @@ -49,9 +49,9 @@ class GetUserProfilePhotos(BaseClient): :class:`Error ` """ return utils.parse_photos( - self.send( + await self.send( functions.photos.GetUserPhotos( - user_id=self.resolve_peer(user_id), + user_id=await self.resolve_peer(user_id), offset=offset, max_id=0, limit=limit diff --git a/pyrogram/client/methods/users/get_users.py b/pyrogram/client/methods/users/get_users.py index 400e35a1..33c38900 100644 --- a/pyrogram/client/methods/users/get_users.py +++ b/pyrogram/client/methods/users/get_users.py @@ -16,12 +16,14 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +import asyncio + from pyrogram.api import functions from ...ext import BaseClient, utils class GetUsers(BaseClient): - def get_users(self, user_ids): + async def get_users(self, user_ids): """Use this method to get information about a user. You can retrieve up to 200 users at once. @@ -41,9 +43,9 @@ class GetUsers(BaseClient): """ is_iterable = not isinstance(user_ids, (int, str)) user_ids = list(user_ids) if is_iterable else [user_ids] - user_ids = [self.resolve_peer(i) for i in user_ids] + user_ids = await asyncio.gather(*[self.resolve_peer(i) for i in user_ids]) - r = self.send( + r = await self.send( functions.users.GetUsers( id=user_ids )