diff --git a/docs/source/api/types.rst b/docs/source/api/types.rst index 957cfa52..a18e01a6 100644 --- a/docs/source/api/types.rst +++ b/docs/source/api/types.rst @@ -43,7 +43,6 @@ Messages & Media - :class:`Messages` - :class:`MessageEntity` - :class:`Photo` - - :class:`ProfilePhotos` - :class:`Thumbnail` - :class:`Audio` - :class:`Document` @@ -129,7 +128,6 @@ Details .. autoclass:: Messages() .. autoclass:: MessageEntity() .. autoclass:: Photo() -.. autoclass:: ProfilePhotos() .. autoclass:: Thumbnail() .. autoclass:: Audio() .. autoclass:: Document() diff --git a/pyrogram/client/methods/users/get_profile_photos.py b/pyrogram/client/methods/users/get_profile_photos.py index e4e202e0..32e7e513 100644 --- a/pyrogram/client/methods/users/get_profile_photos.py +++ b/pyrogram/client/methods/users/get_profile_photos.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from typing import Union +from typing import Union, List import pyrogram from pyrogram.api import functions, types @@ -29,7 +29,7 @@ class GetProfilePhotos(BaseClient): chat_id: Union[int, str], offset: int = 0, limit: int = 100 - ) -> "pyrogram.ProfilePhotos": + ) -> List["pyrogram.Photo"]: """Get a list of profile pictures for a user or a chat. Parameters: @@ -47,7 +47,7 @@ class GetProfilePhotos(BaseClient): Values between 1—100 are accepted. Defaults to 100. Returns: - :obj:`ProfilePhotos`: On success, an object containing a list of the profile photos is returned. + List of :obj:`Photo`: On success, a list of profile photos is returned. Raises: RPCError: In case of a Telegram RPC error. @@ -55,17 +55,16 @@ class GetProfilePhotos(BaseClient): peer_id = self.resolve_peer(chat_id) if isinstance(peer_id, types.InputPeerUser): - return pyrogram.ProfilePhotos._parse( - self, - self.send( - functions.photos.GetUserPhotos( - user_id=peer_id, - offset=offset, - max_id=0, - limit=limit - ) + r = self.send( + functions.photos.GetUserPhotos( + user_id=peer_id, + offset=offset, + max_id=0, + limit=limit ) ) + + return pyrogram.List(pyrogram.Photo._parse(self, photo) for photo in r.photos) else: new_chat_photos = pyrogram.Messages._parse( self, @@ -86,7 +85,4 @@ class GetProfilePhotos(BaseClient): ) ) - return pyrogram.ProfilePhotos( - total_count=new_chat_photos.total_count, - profile_photos=[m.new_chat_photo for m in new_chat_photos.messages][:limit] - ) + return pyrogram.List([m.new_chat_photo for m in new_chat_photos.messages][:limit]) diff --git a/pyrogram/client/methods/users/iter_profile_photos.py b/pyrogram/client/methods/users/iter_profile_photos.py index 1773634e..49317f87 100644 --- a/pyrogram/client/methods/users/iter_profile_photos.py +++ b/pyrogram/client/methods/users/iter_profile_photos.py @@ -63,7 +63,7 @@ class IterProfilePhotos(BaseClient): chat_id=chat_id, offset=offset, limit=limit - ).photos + ) if not photos: return diff --git a/pyrogram/client/types/messages_and_media/__init__.py b/pyrogram/client/types/messages_and_media/__init__.py index 17a6e36a..2de2c6a3 100644 --- a/pyrogram/client/types/messages_and_media/__init__.py +++ b/pyrogram/client/types/messages_and_media/__init__.py @@ -28,7 +28,6 @@ from .messages import Messages from .photo import Photo from .poll import Poll from .poll_option import PollOption -from .profile_photos import ProfilePhotos from .sticker import Sticker from .stripped_thumbnail import StrippedThumbnail from .thumbnail import Thumbnail @@ -39,6 +38,5 @@ from .voice import Voice __all__ = [ "Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo", - "Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "ProfilePhotos", "Venue", "Video", "VideoNote", - "Voice" + "Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice" ] diff --git a/pyrogram/client/types/messages_and_media/profile_photos.py b/pyrogram/client/types/messages_and_media/profile_photos.py deleted file mode 100644 index 11b8e4dd..00000000 --- a/pyrogram/client/types/messages_and_media/profile_photos.py +++ /dev/null @@ -1,57 +0,0 @@ -# Pyrogram - Telegram MTProto API Client Library for Python -# Copyright (C) 2017-2019 Dan Tès -# -# This file is part of Pyrogram. -# -# Pyrogram is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Pyrogram is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with Pyrogram. If not, see . - -from typing import List - -import pyrogram -from .photo import Photo -from ..object import Object - - -class ProfilePhotos(Object): - """Contains a user's profile pictures. - - Parameters: - total_count (``int``): - Total number of profile pictures the target user has. - - profile_photos (List of :obj:`Photo`): - Requested profile pictures. - """ - - __slots__ = ["total_count", "profile_photos"] - - def __init__( - self, - *, - client: "pyrogram.BaseClient" = None, - total_count: int, - profile_photos: List[Photo] - ): - super().__init__(client) - - self.total_count = total_count - self.profile_photos = profile_photos - - @staticmethod - def _parse(client, photos) -> "ProfilePhotos": - return ProfilePhotos( - total_count=getattr(photos, "count", len(photos.photos)), - profile_photos=[Photo._parse(client, photo) for photo in photos.photos], - client=client - )