From 8e9a7a33bd7113f7773669a421c70f8adcfdb61f Mon Sep 17 00:00:00 2001 From: Alisson Lauffer Date: Wed, 20 Nov 2019 02:51:42 -0300 Subject: [PATCH] Add missing awaits --- pyrogram/client/methods/chats/add_chat_members.py | 12 ++++++------ pyrogram/client/methods/chats/create_channel.py | 4 ++-- pyrogram/client/methods/chats/create_group.py | 6 +++--- pyrogram/client/methods/chats/create_supergroup.py | 4 ++-- pyrogram/client/methods/chats/delete_channel.py | 6 +++--- pyrogram/client/methods/chats/delete_supergroup.py | 6 +++--- .../client/methods/chats/set_chat_permissions.py | 2 +- pyrogram/client/methods/messages/send_poll.py | 6 +++--- pyrogram/client/methods/users/get_common_chats.py | 6 +++--- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/pyrogram/client/methods/chats/add_chat_members.py b/pyrogram/client/methods/chats/add_chat_members.py index 8dbad1a3..ace35cf8 100644 --- a/pyrogram/client/methods/chats/add_chat_members.py +++ b/pyrogram/client/methods/chats/add_chat_members.py @@ -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 ] ) diff --git a/pyrogram/client/methods/chats/create_channel.py b/pyrogram/client/methods/chats/create_channel.py index 9dde8781..c768ccce 100644 --- a/pyrogram/client/methods/chats/create_channel.py +++ b/pyrogram/client/methods/chats/create_channel.py @@ -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, diff --git a/pyrogram/client/methods/chats/create_group.py b/pyrogram/client/methods/chats/create_group.py index a9013d81..c69d8ff8 100644 --- a/pyrogram/client/methods/chats/create_group.py +++ b/pyrogram/client/methods/chats/create_group.py @@ -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] ) ) diff --git a/pyrogram/client/methods/chats/create_supergroup.py b/pyrogram/client/methods/chats/create_supergroup.py index 28b3fd1b..ddeb42bf 100644 --- a/pyrogram/client/methods/chats/create_supergroup.py +++ b/pyrogram/client/methods/chats/create_supergroup.py @@ -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, diff --git a/pyrogram/client/methods/chats/delete_channel.py b/pyrogram/client/methods/chats/delete_channel.py index 74fbea13..b306773b 100644 --- a/pyrogram/client/methods/chats/delete_channel.py +++ b/pyrogram/client/methods/chats/delete_channel.py @@ -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) ) ) diff --git a/pyrogram/client/methods/chats/delete_supergroup.py b/pyrogram/client/methods/chats/delete_supergroup.py index a1eb198d..3c291424 100644 --- a/pyrogram/client/methods/chats/delete_supergroup.py +++ b/pyrogram/client/methods/chats/delete_supergroup.py @@ -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) ) ) diff --git a/pyrogram/client/methods/chats/set_chat_permissions.py b/pyrogram/client/methods/chats/set_chat_permissions.py index 158cc269..e1494ac3 100644 --- a/pyrogram/client/methods/chats/set_chat_permissions.py +++ b/pyrogram/client/methods/chats/set_chat_permissions.py @@ -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, diff --git a/pyrogram/client/methods/messages/send_poll.py b/pyrogram/client/methods/messages/send_poll.py index a684dda9..50ba9cc1 100644 --- a/pyrogram/client/methods/messages/send_poll.py +++ b/pyrogram/client/methods/messages/send_poll.py @@ -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, diff --git a/pyrogram/client/methods/users/get_common_chats.py b/pyrogram/client/methods/users/get_common_chats.py index f2c9ac00..2207e09f 100644 --- a/pyrogram/client/methods/users/get_common_chats.py +++ b/pyrogram/client/methods/users/get_common_chats.py @@ -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,