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):
def add_chat_members(
async def add_chat_members(
self,
chat_id: 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)
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):
user_ids = [user_ids]
if isinstance(peer, types.InputPeerChat):
for user_id in user_ids:
self.send(
await self.send(
functions.messages.AddChatUser(
chat_id=peer.chat_id,
user_id=self.resolve_peer(user_id),
user_id=await self.resolve_peer(user_id),
fwd_limit=forward_limit
)
)
else:
self.send(
await self.send(
functions.channels.InviteToChannel(
channel=peer,
users=[
self.resolve_peer(user_id)
await self.resolve_peer(user_id)
for user_id in user_ids
]
)

View File

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

View File

@ -24,7 +24,7 @@ from ...ext import BaseClient
class CreateGroup(BaseClient):
def create_group(
async def create_group(
self,
title: str,
users: Union[Union[int, str], List[Union[int, str]]]
@ -55,10 +55,10 @@ class CreateGroup(BaseClient):
if not isinstance(users, list):
users = [users]
r = self.send(
r = await self.send(
functions.messages.CreateChat(
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):
def create_supergroup(
async def create_supergroup(
self,
title: str,
description: str = ""
@ -48,7 +48,7 @@ class CreateSupergroup(BaseClient):
app.create_supergroup("Supergroup Title", "Supergroup Description")
"""
r = self.send(
r = await self.send(
functions.channels.CreateChannel(
title=title,
about=description,

View File

@ -24,7 +24,7 @@ from ...ext import 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.
Parameters:
@ -39,9 +39,9 @@ class DeleteChannel(BaseClient):
app.delete_channel(channel_id)
"""
self.send(
await self.send(
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):
def delete_supergroup(self, chat_id: Union[int, str]) -> bool:
async def delete_supergroup(self, chat_id: Union[int, str]) -> bool:
"""Delete a supergroup.
Parameters:
@ -39,9 +39,9 @@ class DeleteSupergroup(BaseClient):
app.delete_supergroup(supergroup_id)
"""
self.send(
await self.send(
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(
functions.messages.EditChatDefaultBannedRights(
peer=self.resolve_peer(chat_id),
peer=await self.resolve_peer(chat_id),
banned_rights=types.ChatBannedRights(
until_date=0,
send_messages=send_messages,

View File

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

View File

@ -24,7 +24,7 @@ from ...ext import 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.
Parameters:
@ -46,10 +46,10 @@ class GetCommonChats(BaseClient):
print(common)
"""
peer = self.resolve_peer(user_id)
peer = await self.resolve_peer(user_id)
if isinstance(peer, types.InputPeerUser):
r = self.send(
r = await self.send(
functions.messages.GetCommonChats(
user_id=peer,
max_id=0,