From 7f7f9768fd9c150b2ba8db72228455a64c6fe25f Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Wed, 27 Mar 2019 14:59:55 +0100 Subject: [PATCH] Add missing awaits --- pyrogram/client/client.py | 6 +++--- pyrogram/client/methods/messages/edit_message_caption.py | 2 +- pyrogram/client/methods/messages/edit_message_media.py | 2 +- pyrogram/client/methods/messages/edit_message_text.py | 2 +- pyrogram/client/methods/messages/send_animation.py | 2 +- pyrogram/client/methods/messages/send_audio.py | 2 +- pyrogram/client/methods/messages/send_cached_media.py | 2 +- pyrogram/client/methods/messages/send_document.py | 2 +- pyrogram/client/methods/messages/send_media_group.py | 2 +- pyrogram/client/methods/messages/send_message.py | 2 +- pyrogram/client/methods/messages/send_photo.py | 2 +- pyrogram/client/methods/messages/send_video.py | 2 +- pyrogram/client/methods/messages/send_voice.py | 2 +- pyrogram/client/style/html.py | 6 +++--- pyrogram/client/style/markdown.py | 4 ++-- 15 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 6f654099..bda5f437 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -1362,7 +1362,7 @@ class Client(Methods, BaseClient): if peer_id > 0: self.fetch_peers( - self.send( + await self.send( functions.users.GetUsers( id=[types.InputUser(user_id=peer_id, access_hash=0)] ) @@ -1370,13 +1370,13 @@ class Client(Methods, BaseClient): ) else: if str(peer_id).startswith("-100"): - self.send( + await self.send( functions.channels.GetChannels( id=[types.InputChannel(channel_id=int(str(peer_id)[4:]), access_hash=0)] ) ) else: - self.send( + await self.send( functions.messages.GetChats( id=[-peer_id] ) diff --git a/pyrogram/client/methods/messages/edit_message_caption.py b/pyrogram/client/methods/messages/edit_message_caption.py index 22e090fc..8fd89dc6 100644 --- a/pyrogram/client/methods/messages/edit_message_caption.py +++ b/pyrogram/client/methods/messages/edit_message_caption.py @@ -67,7 +67,7 @@ class EditMessageCaption(BaseClient): peer=await self.resolve_peer(chat_id), id=message_id, reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) diff --git a/pyrogram/client/methods/messages/edit_message_media.py b/pyrogram/client/methods/messages/edit_message_media.py index 2d9aa23b..a5ae56fe 100644 --- a/pyrogram/client/methods/messages/edit_message_media.py +++ b/pyrogram/client/methods/messages/edit_message_media.py @@ -353,7 +353,7 @@ class EditMessageMedia(BaseClient): id=message_id, reply_markup=reply_markup.write() if reply_markup else None, media=media, - **style.parse(caption) + **await style.parse(caption) ) ) diff --git a/pyrogram/client/methods/messages/edit_message_text.py b/pyrogram/client/methods/messages/edit_message_text.py index b37255a2..fac74f89 100644 --- a/pyrogram/client/methods/messages/edit_message_text.py +++ b/pyrogram/client/methods/messages/edit_message_text.py @@ -72,7 +72,7 @@ class EditMessageText(BaseClient): id=message_id, no_webpage=disable_web_page_preview or None, reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(text) + **await style.parse(text) ) ) diff --git a/pyrogram/client/methods/messages/send_animation.py b/pyrogram/client/methods/messages/send_animation.py index 507cf6f9..ffe70fd9 100644 --- a/pyrogram/client/methods/messages/send_animation.py +++ b/pyrogram/client/methods/messages/send_animation.py @@ -187,7 +187,7 @@ class SendAnimation(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_audio.py b/pyrogram/client/methods/messages/send_audio.py index ea3a0ac4..f620b25b 100644 --- a/pyrogram/client/methods/messages/send_audio.py +++ b/pyrogram/client/methods/messages/send_audio.py @@ -186,7 +186,7 @@ class SendAudio(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_cached_media.py b/pyrogram/client/methods/messages/send_cached_media.py index 9511c548..b9f00495 100644 --- a/pyrogram/client/methods/messages/send_cached_media.py +++ b/pyrogram/client/methods/messages/send_cached_media.py @@ -122,7 +122,7 @@ class SendCachedMedia(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) diff --git a/pyrogram/client/methods/messages/send_document.py b/pyrogram/client/methods/messages/send_document.py index 123a79fc..ebdae534 100644 --- a/pyrogram/client/methods/messages/send_document.py +++ b/pyrogram/client/methods/messages/send_document.py @@ -167,7 +167,7 @@ class SendDocument(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_media_group.py b/pyrogram/client/methods/messages/send_media_group.py index 40c53066..32b6af59 100644 --- a/pyrogram/client/methods/messages/send_media_group.py +++ b/pyrogram/client/methods/messages/send_media_group.py @@ -183,7 +183,7 @@ class SendMediaGroup(BaseClient): types.InputSingleMedia( media=media, random_id=self.rnd_id(), - **style.parse(i.caption) + **await style.parse(i.caption) ) ) diff --git a/pyrogram/client/methods/messages/send_message.py b/pyrogram/client/methods/messages/send_message.py index 7c36800e..090bd63c 100644 --- a/pyrogram/client/methods/messages/send_message.py +++ b/pyrogram/client/methods/messages/send_message.py @@ -76,7 +76,7 @@ class SendMessage(BaseClient): :class:`RPCError ` in case of a Telegram RPC error. """ style = self.html if parse_mode.lower() == "html" else self.markdown - message, entities = style.parse(text).values() + message, entities = (await style.parse(text)).values() r = await self.send( functions.messages.SendMessage( diff --git a/pyrogram/client/methods/messages/send_photo.py b/pyrogram/client/methods/messages/send_photo.py index 5686dfdc..00302233 100644 --- a/pyrogram/client/methods/messages/send_photo.py +++ b/pyrogram/client/methods/messages/send_photo.py @@ -164,7 +164,7 @@ class SendPhoto(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_video.py b/pyrogram/client/methods/messages/send_video.py index 00a717e4..a9c72df8 100644 --- a/pyrogram/client/methods/messages/send_video.py +++ b/pyrogram/client/methods/messages/send_video.py @@ -190,7 +190,7 @@ class SendVideo(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/methods/messages/send_voice.py b/pyrogram/client/methods/messages/send_voice.py index 588bb446..3d8bfaf2 100644 --- a/pyrogram/client/methods/messages/send_voice.py +++ b/pyrogram/client/methods/messages/send_voice.py @@ -166,7 +166,7 @@ class SendVoice(BaseClient): reply_to_msg_id=reply_to_message_id, random_id=self.rnd_id(), reply_markup=reply_markup.write() if reply_markup else None, - **style.parse(caption) + **await style.parse(caption) ) ) except FilePartMissing as e: diff --git a/pyrogram/client/style/html.py b/pyrogram/client/style/html.py index 9c0a372c..d9aec531 100644 --- a/pyrogram/client/style/html.py +++ b/pyrogram/client/style/html.py @@ -40,9 +40,9 @@ class HTML: def __init__(self, client: "pyrogram.BaseClient" = None): self.client = client - def parse(self, message: str): - entities = [] + async def parse(self, message: str): message = utils.add_surrogates(str(message or "")) + entities = [] offset = 0 for match in self.HTML_RE.finditer(message): @@ -56,7 +56,7 @@ class HTML: user_id = int(mention.group(1)) try: - input_user = self.client.resolve_peer(user_id) + input_user = await self.client.resolve_peer(user_id) except PeerIdInvalid: input_user = None diff --git a/pyrogram/client/style/markdown.py b/pyrogram/client/style/markdown.py index adb86e94..1174c639 100644 --- a/pyrogram/client/style/markdown.py +++ b/pyrogram/client/style/markdown.py @@ -57,7 +57,7 @@ class Markdown: def __init__(self, client: "pyrogram.BaseClient" = None): self.client = client - def parse(self, message: str): + async def parse(self, message: str): message = utils.add_surrogates(str(message or "")).strip() entities = [] offset = 0 @@ -73,7 +73,7 @@ class Markdown: user_id = int(mention.group(1)) try: - input_user = self.client.resolve_peer(user_id) + input_user = await self.client.resolve_peer(user_id) except PeerIdInvalid: input_user = None