2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Merge pull request #345 from alissonlauffer/asyncio-dev

Add missing awaits for the asyncio-dev branch
This commit is contained in:
Dan 2019-12-23 15:05:09 +01:00 committed by GitHub
commit 48aaaf9a0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 26 deletions

View File

@ -23,7 +23,7 @@ from ...ext import BaseClient
class AddChatMembers(BaseClient): class AddChatMembers(BaseClient):
def add_chat_members( async def add_chat_members(
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
user_ids: Union[Union[int, str], List[Union[int, str]]], user_ids: Union[Union[int, str], List[Union[int, str]]],
@ -60,26 +60,26 @@ class AddChatMembers(BaseClient):
# Change forward_limit (for basic groups only) # Change forward_limit (for basic groups only)
app.add_chat_members(chat_id, user_id, forward_limit=25) app.add_chat_members(chat_id, user_id, forward_limit=25)
""" """
peer = self.resolve_peer(chat_id) peer = await self.resolve_peer(chat_id)
if not isinstance(user_ids, list): if not isinstance(user_ids, list):
user_ids = [user_ids] user_ids = [user_ids]
if isinstance(peer, types.InputPeerChat): if isinstance(peer, types.InputPeerChat):
for user_id in user_ids: for user_id in user_ids:
self.send( await self.send(
functions.messages.AddChatUser( functions.messages.AddChatUser(
chat_id=peer.chat_id, chat_id=peer.chat_id,
user_id=self.resolve_peer(user_id), user_id=await self.resolve_peer(user_id),
fwd_limit=forward_limit fwd_limit=forward_limit
) )
) )
else: else:
self.send( await self.send(
functions.channels.InviteToChannel( functions.channels.InviteToChannel(
channel=peer, channel=peer,
users=[ users=[
self.resolve_peer(user_id) await self.resolve_peer(user_id)
for user_id in user_ids for user_id in user_ids
] ]
) )

View File

@ -22,7 +22,7 @@ from ...ext import BaseClient
class CreateChannel(BaseClient): class CreateChannel(BaseClient):
def create_channel( async def create_channel(
self, self,
title: str, title: str,
description: str = "" description: str = ""
@ -44,7 +44,7 @@ class CreateChannel(BaseClient):
app.create_channel("Channel Title", "Channel Description") app.create_channel("Channel Title", "Channel Description")
""" """
r = self.send( r = await self.send(
functions.channels.CreateChannel( functions.channels.CreateChannel(
title=title, title=title,
about=description, about=description,

View File

@ -24,7 +24,7 @@ from ...ext import BaseClient
class CreateGroup(BaseClient): class CreateGroup(BaseClient):
def create_group( async def create_group(
self, self,
title: str, title: str,
users: Union[Union[int, str], List[Union[int, str]]] users: Union[Union[int, str], List[Union[int, str]]]
@ -55,10 +55,10 @@ class CreateGroup(BaseClient):
if not isinstance(users, list): if not isinstance(users, list):
users = [users] users = [users]
r = self.send( r = await self.send(
functions.messages.CreateChat( functions.messages.CreateChat(
title=title, title=title,
users=[self.resolve_peer(u) for u in users] users=[await self.resolve_peer(u) for u in users]
) )
) )

View File

@ -22,7 +22,7 @@ from ...ext import BaseClient
class CreateSupergroup(BaseClient): class CreateSupergroup(BaseClient):
def create_supergroup( async def create_supergroup(
self, self,
title: str, title: str,
description: str = "" description: str = ""
@ -48,7 +48,7 @@ class CreateSupergroup(BaseClient):
app.create_supergroup("Supergroup Title", "Supergroup Description") app.create_supergroup("Supergroup Title", "Supergroup Description")
""" """
r = self.send( r = await self.send(
functions.channels.CreateChannel( functions.channels.CreateChannel(
title=title, title=title,
about=description, about=description,

View File

@ -24,7 +24,7 @@ from ...ext import BaseClient
class DeleteChannel(BaseClient): class DeleteChannel(BaseClient):
def delete_channel(self, chat_id: Union[int, str]) -> bool: async def delete_channel(self, chat_id: Union[int, str]) -> bool:
"""Delete a channel. """Delete a channel.
Parameters: Parameters:
@ -39,9 +39,9 @@ class DeleteChannel(BaseClient):
app.delete_channel(channel_id) app.delete_channel(channel_id)
""" """
self.send( await self.send(
functions.channels.DeleteChannel( functions.channels.DeleteChannel(
channel=self.resolve_peer(chat_id) channel=await self.resolve_peer(chat_id)
) )
) )

View File

@ -24,7 +24,7 @@ from ...ext import BaseClient
class DeleteSupergroup(BaseClient): class DeleteSupergroup(BaseClient):
def delete_supergroup(self, chat_id: Union[int, str]) -> bool: async def delete_supergroup(self, chat_id: Union[int, str]) -> bool:
"""Delete a supergroup. """Delete a supergroup.
Parameters: Parameters:
@ -39,9 +39,9 @@ class DeleteSupergroup(BaseClient):
app.delete_supergroup(supergroup_id) app.delete_supergroup(supergroup_id)
""" """
self.send( await self.send(
functions.channels.DeleteChannel( functions.channels.DeleteChannel(
channel=self.resolve_peer(chat_id) channel=await self.resolve_peer(chat_id)
) )
) )

View File

@ -107,7 +107,7 @@ class SetChatPermissions(BaseClient):
r = await self.send( r = await self.send(
functions.messages.EditChatDefaultBannedRights( functions.messages.EditChatDefaultBannedRights(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
banned_rights=types.ChatBannedRights( banned_rights=types.ChatBannedRights(
until_date=0, until_date=0,
send_messages=send_messages, send_messages=send_messages,

View File

@ -24,7 +24,7 @@ from pyrogram.client.ext import BaseClient
class SendPoll(BaseClient): class SendPoll(BaseClient):
def send_poll( async def send_poll(
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
question: str, question: str,
@ -75,9 +75,9 @@ class SendPoll(BaseClient):
app.send_poll(chat_id, "Is this a poll question?", ["Yes", "No", "Maybe"]) app.send_poll(chat_id, "Is this a poll question?", ["Yes", "No", "Maybe"])
""" """
r = self.send( r = await self.send(
functions.messages.SendMedia( functions.messages.SendMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaPoll( media=types.InputMediaPoll(
poll=types.Poll( poll=types.Poll(
id=0, id=0,

View File

@ -24,7 +24,7 @@ from ...ext import BaseClient
class GetCommonChats(BaseClient): class GetCommonChats(BaseClient):
def get_common_chats(self, user_id: Union[int, str]) -> list: async def get_common_chats(self, user_id: Union[int, str]) -> list:
"""Get the common chats you have with a user. """Get the common chats you have with a user.
Parameters: Parameters:
@ -46,10 +46,10 @@ class GetCommonChats(BaseClient):
print(common) print(common)
""" """
peer = self.resolve_peer(user_id) peer = await self.resolve_peer(user_id)
if isinstance(peer, types.InputPeerUser): if isinstance(peer, types.InputPeerUser):
r = self.send( r = await self.send(
functions.messages.GetCommonChats( functions.messages.GetCommonChats(
user_id=peer, user_id=peer,
max_id=0, max_id=0,