Fix some methods not being async
This commit is contained in:
parent
4d72f84991
commit
e0fe9d3525
@ -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 <pyrogram.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(
|
||||
|
@ -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 <pyrogram.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(
|
||||
|
@ -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 <pyrogram.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(
|
||||
|
@ -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 <pyrogram.Error>`
|
||||
"""
|
||||
return utils.parse_user(
|
||||
self.send(
|
||||
await self.send(
|
||||
functions.users.GetFullUser(
|
||||
types.InputPeerSelf()
|
||||
)
|
||||
|
@ -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 <pyrogram.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
|
||||
|
@ -16,12 +16,14 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user