Add missing async/await keywords

This commit is contained in:
Dan 2018-08-23 21:07:19 +02:00
parent aaaba4b847
commit 4f9b38765e
2 changed files with 21 additions and 21 deletions

View File

@ -21,7 +21,7 @@ from ...ext import BaseClient, utils
class GetChatMember(BaseClient): class GetChatMember(BaseClient):
def get_chat_member(self, async def get_chat_member(self,
chat_id: int or str, chat_id: int or str,
user_id: int or str): user_id: int or str):
"""Use this method to get information about one member of a chat. """Use this method to get information about one member of a chat.
@ -41,11 +41,11 @@ class GetChatMember(BaseClient):
Raises: Raises:
:class:`Error <pyrogram.Error>` :class:`Error <pyrogram.Error>`
""" """
chat_id = self.resolve_peer(chat_id) chat_id = await self.resolve_peer(chat_id)
user_id = self.resolve_peer(user_id) user_id = await self.resolve_peer(user_id)
if isinstance(chat_id, types.InputPeerChat): if isinstance(chat_id, types.InputPeerChat):
full_chat = self.send( full_chat = await self.send(
functions.messages.GetFullChat( functions.messages.GetFullChat(
chat_id=chat_id.chat_id chat_id=chat_id.chat_id
) )
@ -57,7 +57,7 @@ class GetChatMember(BaseClient):
else: else:
raise errors.UserNotParticipant raise errors.UserNotParticipant
elif isinstance(chat_id, types.InputPeerChannel): elif isinstance(chat_id, types.InputPeerChannel):
r = self.send( r = await self.send(
functions.channels.GetParticipant( functions.channels.GetParticipant(
channel=chat_id, channel=chat_id,
user_id=user_id user_id=user_id

View File

@ -31,7 +31,7 @@ from pyrogram.client.types import (
class EditMessageMedia(BaseClient): class EditMessageMedia(BaseClient):
def edit_message_media(self, async def edit_message_media(self,
chat_id: int or str, chat_id: int or str,
message_id: int, message_id: int,
media, media,
@ -41,11 +41,11 @@ class EditMessageMedia(BaseClient):
if isinstance(media, InputMediaPhoto): if isinstance(media, InputMediaPhoto):
if os.path.exists(media.media): if os.path.exists(media.media):
media = self.send( media = await self.send(
functions.messages.UploadMedia( functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaUploadedPhoto( media=types.InputMediaUploadedPhoto(
file=self.save_file(media.media) file=await self.save_file(media.media)
) )
) )
) )
@ -85,12 +85,12 @@ class EditMessageMedia(BaseClient):
if isinstance(media, InputMediaVideo): if isinstance(media, InputMediaVideo):
if os.path.exists(media.media): if os.path.exists(media.media):
media = self.send( media = await self.send(
functions.messages.UploadMedia( functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
file=self.save_file(media.media), file=await self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeVideo( types.DocumentAttributeVideo(
supports_streaming=media.supports_streaming or None, supports_streaming=media.supports_streaming or None,
@ -139,12 +139,12 @@ class EditMessageMedia(BaseClient):
if isinstance(media, InputMediaAudio): if isinstance(media, InputMediaAudio):
if os.path.exists(media.media): if os.path.exists(media.media):
media = self.send( media = await self.send(
functions.messages.UploadMedia( functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "audio/mpeg"), mime_type=mimetypes.types_map.get("." + media.media.split(".")[-1], "audio/mpeg"),
file=self.save_file(media.media), file=await self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeAudio( types.DocumentAttributeAudio(
duration=media.duration, duration=media.duration,
@ -192,12 +192,12 @@ class EditMessageMedia(BaseClient):
if isinstance(media, InputMediaAnimation): if isinstance(media, InputMediaAnimation):
if os.path.exists(media.media): if os.path.exists(media.media):
media = self.send( media = await self.send(
functions.messages.UploadMedia( functions.messages.UploadMedia(
peer=self.resolve_peer(chat_id), peer=await self.resolve_peer(chat_id),
media=types.InputMediaUploadedDocument( media=types.InputMediaUploadedDocument(
mime_type=mimetypes.types_map[".mp4"], mime_type=mimetypes.types_map[".mp4"],
file=self.save_file(media.media), file=await self.save_file(media.media),
attributes=[ attributes=[
types.DocumentAttributeVideo( types.DocumentAttributeVideo(
supports_streaming=True, supports_streaming=True,
@ -245,9 +245,9 @@ class EditMessageMedia(BaseClient):
) )
) )
r = self.send( r = await self.send(
functions.messages.EditMessage( functions.messages.EditMessage(
peer=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,
media=media, media=media,
@ -257,7 +257,7 @@ class EditMessageMedia(BaseClient):
for i in r.updates: for i in r.updates:
if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)): if isinstance(i, (types.UpdateEditMessage, types.UpdateEditChannelMessage)):
return utils.parse_messages( return await utils.parse_messages(
self, i.message, self, i.message,
{i.id: i for i in r.users}, {i.id: i for i in r.users},
{i.id: i for i in r.chats} {i.id: i for i in r.chats}