mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 15:34:52 +00:00
Fix some methods not being async
This commit is contained in:
parent
4d72f84991
commit
e0fe9d3525
6 changed files with 22 additions and 20 deletions
|
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class ChangeCloudPassword(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.
|
"""Use this method to change your Two-Step Verification password (Cloud Password) with a new one.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -43,7 +43,7 @@ class ChangeCloudPassword(BaseClient):
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>`
|
:class:`Error <pyrogram.Error>`
|
||||||
"""
|
"""
|
||||||
r = self.send(functions.account.GetPassword())
|
r = await self.send(functions.account.GetPassword())
|
||||||
|
|
||||||
if isinstance(r, types.account.Password):
|
if isinstance(r, types.account.Password):
|
||||||
current_password_hash = sha256(r.current_salt + current_password.encode() + r.current_salt).digest()
|
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_salt = r.new_salt + os.urandom(8)
|
||||||
new_password_hash = sha256(new_salt + new_password.encode() + new_salt).digest()
|
new_password_hash = sha256(new_salt + new_password.encode() + new_salt).digest()
|
||||||
|
|
||||||
return self.send(
|
return await self.send(
|
||||||
functions.account.UpdatePasswordSettings(
|
functions.account.UpdatePasswordSettings(
|
||||||
current_password_hash=current_password_hash,
|
current_password_hash=current_password_hash,
|
||||||
new_settings=types.account.PasswordInputSettings(
|
new_settings=types.account.PasswordInputSettings(
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class EnableCloudPassword(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.
|
"""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.
|
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:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>`
|
:class:`Error <pyrogram.Error>`
|
||||||
"""
|
"""
|
||||||
r = self.send(functions.account.GetPassword())
|
r = await self.send(functions.account.GetPassword())
|
||||||
|
|
||||||
if isinstance(r, types.account.NoPassword):
|
if isinstance(r, types.account.NoPassword):
|
||||||
salt = r.new_salt + os.urandom(8)
|
salt = r.new_salt + os.urandom(8)
|
||||||
password_hash = sha256(salt + password.encode() + salt).digest()
|
password_hash = sha256(salt + password.encode() + salt).digest()
|
||||||
|
|
||||||
return self.send(
|
return await self.send(
|
||||||
functions.account.UpdatePasswordSettings(
|
functions.account.UpdatePasswordSettings(
|
||||||
current_password_hash=salt,
|
current_password_hash=salt,
|
||||||
new_settings=types.account.PasswordInputSettings(
|
new_settings=types.account.PasswordInputSettings(
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class RemoveCloudPassword(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.
|
"""Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -36,12 +36,12 @@ class RemoveCloudPassword(BaseClient):
|
||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>`
|
:class:`Error <pyrogram.Error>`
|
||||||
"""
|
"""
|
||||||
r = self.send(functions.account.GetPassword())
|
r = await self.send(functions.account.GetPassword())
|
||||||
|
|
||||||
if isinstance(r, types.account.Password):
|
if isinstance(r, types.account.Password):
|
||||||
password_hash = sha256(r.current_salt + password.encode() + r.current_salt).digest()
|
password_hash = sha256(r.current_salt + password.encode() + r.current_salt).digest()
|
||||||
|
|
||||||
return self.send(
|
return await self.send(
|
||||||
functions.account.UpdatePasswordSettings(
|
functions.account.UpdatePasswordSettings(
|
||||||
current_password_hash=password_hash,
|
current_password_hash=password_hash,
|
||||||
new_settings=types.account.PasswordInputSettings(
|
new_settings=types.account.PasswordInputSettings(
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from ...ext import BaseClient, utils
|
||||||
|
|
||||||
|
|
||||||
class GetMe(BaseClient):
|
class GetMe(BaseClient):
|
||||||
def get_me(self):
|
async def get_me(self):
|
||||||
"""A simple method for testing your authorization. Requires no parameters.
|
"""A simple method for testing your authorization. Requires no parameters.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
@ -31,7 +31,7 @@ class GetMe(BaseClient):
|
||||||
:class:`Error <pyrogram.Error>`
|
:class:`Error <pyrogram.Error>`
|
||||||
"""
|
"""
|
||||||
return utils.parse_user(
|
return utils.parse_user(
|
||||||
self.send(
|
await self.send(
|
||||||
functions.users.GetFullUser(
|
functions.users.GetFullUser(
|
||||||
types.InputPeerSelf()
|
types.InputPeerSelf()
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ from ...ext import BaseClient, utils
|
||||||
|
|
||||||
|
|
||||||
class GetUserProfilePhotos(BaseClient):
|
class GetUserProfilePhotos(BaseClient):
|
||||||
def get_user_profile_photos(self,
|
async def get_user_profile_photos(self,
|
||||||
user_id: int or str,
|
user_id: int or str,
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
limit: int = 100):
|
limit: int = 100):
|
||||||
|
|
@ -49,9 +49,9 @@ class GetUserProfilePhotos(BaseClient):
|
||||||
:class:`Error <pyrogram.Error>`
|
:class:`Error <pyrogram.Error>`
|
||||||
"""
|
"""
|
||||||
return utils.parse_photos(
|
return utils.parse_photos(
|
||||||
self.send(
|
await self.send(
|
||||||
functions.photos.GetUserPhotos(
|
functions.photos.GetUserPhotos(
|
||||||
user_id=self.resolve_peer(user_id),
|
user_id=await self.resolve_peer(user_id),
|
||||||
offset=offset,
|
offset=offset,
|
||||||
max_id=0,
|
max_id=0,
|
||||||
limit=limit
|
limit=limit
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,14 @@
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from pyrogram.api import functions
|
from pyrogram.api import functions
|
||||||
from ...ext import BaseClient, utils
|
from ...ext import BaseClient, utils
|
||||||
|
|
||||||
|
|
||||||
class GetUsers(BaseClient):
|
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.
|
"""Use this method to get information about a user.
|
||||||
You can retrieve up to 200 users at once.
|
You can retrieve up to 200 users at once.
|
||||||
|
|
||||||
|
|
@ -41,9 +43,9 @@ class GetUsers(BaseClient):
|
||||||
"""
|
"""
|
||||||
is_iterable = not isinstance(user_ids, (int, str))
|
is_iterable = not isinstance(user_ids, (int, str))
|
||||||
user_ids = list(user_ids) if is_iterable else [user_ids]
|
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(
|
functions.users.GetUsers(
|
||||||
id=user_ids
|
id=user_ids
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue