diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 88d5c3db..c38d66e5 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -523,7 +523,7 @@ class Message(Object, Update): if media: if isinstance(media, types.MessageMediaPhoto): - photo = Photo._parse(client, media) + photo = Photo._parse(client, media.photo, media.ttl_seconds) elif isinstance(media, types.MessageMediaGeo): location = Location._parse(client, media.geo) elif isinstance(media, types.MessageMediaContact): diff --git a/pyrogram/client/types/messages_and_media/photo.py b/pyrogram/client/types/messages_and_media/photo.py index 1edfb4e2..235f4931 100644 --- a/pyrogram/client/types/messages_and_media/photo.py +++ b/pyrogram/client/types/messages_and_media/photo.py @@ -80,9 +80,7 @@ class Photo(Object): self.thumbs = thumbs @staticmethod - def _parse(client, media_photo: types.MessageMediaPhoto) -> "Photo": - photo = media_photo.photo - + def _parse(client, photo: types.Photo, ttl_seconds: int = None) -> "Photo": if isinstance(photo, types.Photo): big = photo.sizes[-1] @@ -98,7 +96,7 @@ class Photo(Object): file_ref=encode_file_ref(photo.file_reference), width=big.w, height=big.h, - ttl_seconds=media_photo.ttl_seconds, + ttl_seconds=ttl_seconds, file_size=big.size, date=photo.date, thumbs=Thumbnail._parse(client, photo), diff --git a/pyrogram/client/types/user_and_chats/chat.py b/pyrogram/client/types/user_and_chats/chat.py index 914159e3..f1369a00 100644 --- a/pyrogram/client/types/user_and_chats/chat.py +++ b/pyrogram/client/types/user_and_chats/chat.py @@ -566,15 +566,8 @@ class Chat(Object): return await self._client.restrict_chat_member( chat_id=self.id, user_id=user_id, + permissions=permissions, until_date=until_date, - can_send_messages=permissions.can_send_messages, - can_send_media_messages=permissions.can_send_media_messages, - can_send_other_messages=permissions.can_send_other_messages, - can_add_web_page_previews=permissions.can_add_web_page_previews, - can_send_polls=permissions.can_send_polls, - can_change_info=permissions.can_change_info, - can_invite_users=permissions.can_invite_users, - can_pin_messages=permissions.can_pin_messages ) async def promote_member( @@ -725,7 +718,7 @@ class Chat(Object): """ return await self._client.export_chat_invite_link(self.id) - + async def get_member( self, user_id: Union[int, str], @@ -749,18 +742,18 @@ class Chat(Object): Returns: :obj:`ChatMember`: On success, a chat member is returned. """ - + return await self._client.get_chat_member( self.id, user_id=user_id ) - + async def get_members( self, offset: int = 0, limit: int = 200, query: str = "", - filter: str = Filters.ALL + filter: str = "all" ) -> List["pyrogram.ChatMember"]: """Bound method *get_members* of :obj:`Chat`. @@ -772,13 +765,14 @@ class Chat(Object): Example: .. code-block:: python + # Get first 200 recent members chat.get_members() Returns: List of :obj:`ChatMember`: On success, a list of chat members is returned. """ - + return await self._client.get_chat_members( self.id, offset=offset, @@ -786,12 +780,12 @@ class Chat(Object): query=query, filter=filter ) - + async def iter_members( self, limit: int = 0, query: str = "", - filter: str = Filters.ALL + filter: str = "all" ) -> Optional[Generator["pyrogram.ChatMember", None, None]]: """Bound method *iter_members* of :obj:`Chat`. @@ -811,14 +805,14 @@ class Chat(Object): Returns: ``Generator``: A generator yielding :obj:`ChatMember` objects. """ - - return self._client.iter_chat_members( + + return await self._client.iter_chat_members( self.id, limit=limit, query=query, filter=filter ) - + async def add_members( self, user_ids: Union[Union[int, str], List[Union[int, str]]], @@ -845,4 +839,4 @@ class Chat(Object): self.id, user_ids=user_ids, forward_limit=forward_limit - ) \ No newline at end of file + )