Add missing awaits

This commit is contained in:
Dan 2019-03-27 14:59:55 +01:00
parent 654a432d99
commit 7f7f9768fd
15 changed files with 20 additions and 20 deletions

View File

@ -1362,7 +1362,7 @@ class Client(Methods, BaseClient):
if peer_id > 0: if peer_id > 0:
self.fetch_peers( self.fetch_peers(
self.send( await self.send(
functions.users.GetUsers( functions.users.GetUsers(
id=[types.InputUser(user_id=peer_id, access_hash=0)] id=[types.InputUser(user_id=peer_id, access_hash=0)]
) )
@ -1370,13 +1370,13 @@ class Client(Methods, BaseClient):
) )
else: else:
if str(peer_id).startswith("-100"): if str(peer_id).startswith("-100"):
self.send( await self.send(
functions.channels.GetChannels( functions.channels.GetChannels(
id=[types.InputChannel(channel_id=int(str(peer_id)[4:]), access_hash=0)] id=[types.InputChannel(channel_id=int(str(peer_id)[4:]), access_hash=0)]
) )
) )
else: else:
self.send( await self.send(
functions.messages.GetChats( functions.messages.GetChats(
id=[-peer_id] id=[-peer_id]
) )

View File

@ -67,7 +67,7 @@ class EditMessageCaption(BaseClient):
peer=await self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
id=message_id, id=message_id,
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )

View File

@ -353,7 +353,7 @@ class EditMessageMedia(BaseClient):
id=message_id, id=message_id,
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
media=media, media=media,
**style.parse(caption) **await style.parse(caption)
) )
) )

View File

@ -72,7 +72,7 @@ class EditMessageText(BaseClient):
id=message_id, id=message_id,
no_webpage=disable_web_page_preview or None, no_webpage=disable_web_page_preview or None,
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(text) **await style.parse(text)
) )
) )

View File

@ -187,7 +187,7 @@ class SendAnimation(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )
except FilePartMissing as e: except FilePartMissing as e:

View File

@ -186,7 +186,7 @@ class SendAudio(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )
except FilePartMissing as e: except FilePartMissing as e:

View File

@ -122,7 +122,7 @@ class SendCachedMedia(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )

View File

@ -167,7 +167,7 @@ class SendDocument(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )
except FilePartMissing as e: except FilePartMissing as e:

View File

@ -183,7 +183,7 @@ class SendMediaGroup(BaseClient):
types.InputSingleMedia( types.InputSingleMedia(
media=media, media=media,
random_id=self.rnd_id(), random_id=self.rnd_id(),
**style.parse(i.caption) **await style.parse(i.caption)
) )
) )

View File

@ -76,7 +76,7 @@ class SendMessage(BaseClient):
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error. :class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
""" """
style = self.html if parse_mode.lower() == "html" else self.markdown 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( r = await self.send(
functions.messages.SendMessage( functions.messages.SendMessage(

View File

@ -164,7 +164,7 @@ class SendPhoto(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )
except FilePartMissing as e: except FilePartMissing as e:

View File

@ -190,7 +190,7 @@ class SendVideo(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )
except FilePartMissing as e: except FilePartMissing as e:

View File

@ -166,7 +166,7 @@ class SendVoice(BaseClient):
reply_to_msg_id=reply_to_message_id, reply_to_msg_id=reply_to_message_id,
random_id=self.rnd_id(), random_id=self.rnd_id(),
reply_markup=reply_markup.write() if reply_markup else None, reply_markup=reply_markup.write() if reply_markup else None,
**style.parse(caption) **await style.parse(caption)
) )
) )
except FilePartMissing as e: except FilePartMissing as e:

View File

@ -40,9 +40,9 @@ class HTML:
def __init__(self, client: "pyrogram.BaseClient" = None): def __init__(self, client: "pyrogram.BaseClient" = None):
self.client = client self.client = client
def parse(self, message: str): async def parse(self, message: str):
entities = []
message = utils.add_surrogates(str(message or "")) message = utils.add_surrogates(str(message or ""))
entities = []
offset = 0 offset = 0
for match in self.HTML_RE.finditer(message): for match in self.HTML_RE.finditer(message):
@ -56,7 +56,7 @@ class HTML:
user_id = int(mention.group(1)) user_id = int(mention.group(1))
try: try:
input_user = self.client.resolve_peer(user_id) input_user = await self.client.resolve_peer(user_id)
except PeerIdInvalid: except PeerIdInvalid:
input_user = None input_user = None

View File

@ -57,7 +57,7 @@ class Markdown:
def __init__(self, client: "pyrogram.BaseClient" = None): def __init__(self, client: "pyrogram.BaseClient" = None):
self.client = client self.client = client
def parse(self, message: str): async def parse(self, message: str):
message = utils.add_surrogates(str(message or "")).strip() message = utils.add_surrogates(str(message or "")).strip()
entities = [] entities = []
offset = 0 offset = 0
@ -73,7 +73,7 @@ class Markdown:
user_id = int(mention.group(1)) user_id = int(mention.group(1))
try: try:
input_user = self.client.resolve_peer(user_id) input_user = await self.client.resolve_peer(user_id)
except PeerIdInvalid: except PeerIdInvalid:
input_user = None input_user = None