Rename Photos to ProfilePhotos

This commit is contained in:
Dan 2019-06-06 19:09:52 +02:00
parent 8151270a94
commit b205c6cce0
4 changed files with 18 additions and 17 deletions

View File

@ -45,7 +45,7 @@ Messages & Media
- :class:`Messages`
- :class:`MessageEntity`
- :class:`Photo`
- :class:`Photos`
- :class:`ProfilePhotos`
- :class:`Thumbnail`
- :class:`Audio`
- :class:`Document`
@ -133,7 +133,7 @@ Details
.. autoclass:: Messages()
.. autoclass:: MessageEntity()
.. autoclass:: Photo()
.. autoclass:: Photos()
.. autoclass:: ProfilePhotos()
.. autoclass:: Thumbnail()
.. autoclass:: Audio()
.. autoclass:: Document()

View File

@ -29,7 +29,7 @@ class GetProfilePhotos(BaseClient):
chat_id: Union[int, str],
offset: int = 0,
limit: int = 100
) -> "pyrogram.Photos":
) -> "pyrogram.ProfilePhotos":
"""Get a list of profile pictures for a user or a chat.
Parameters:
@ -47,7 +47,7 @@ class GetProfilePhotos(BaseClient):
Values between 1100 are accepted. Defaults to 100.
Returns:
:obj:`Photos`: On success, an object containing a list of the profile photos is returned.
:obj:`ProfilePhotos`: On success, an object containing a list of the profile photos is returned.
Raises:
RPCError: In case of a Telegram RPC error.
@ -55,7 +55,7 @@ class GetProfilePhotos(BaseClient):
peer_id = self.resolve_peer(chat_id)
if isinstance(peer_id, types.InputPeerUser):
return pyrogram.Photos._parse(
return pyrogram.ProfilePhotos._parse(
self,
self.send(
functions.photos.GetUserPhotos(
@ -86,7 +86,7 @@ class GetProfilePhotos(BaseClient):
)
)
return pyrogram.Photos(
return pyrogram.ProfilePhotos(
total_count=new_chat_photos.total_count,
photos=[m.new_chat_photo for m in new_chat_photos.messages][:limit]
profile_photos=[m.new_chat_photo for m in new_chat_photos.messages][:limit]
)

View File

@ -28,10 +28,10 @@ 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
from .photos import Photos
from .venue import Venue
from .video import Video
from .video_note import VideoNote
@ -39,5 +39,6 @@ from .voice import Voice
__all__ = [
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo",
"Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "Photos", "Venue", "Video", "VideoNote", "Voice"
"Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "ProfilePhotos", "Venue", "Video", "VideoNote",
"Voice"
]

View File

@ -23,35 +23,35 @@ from .photo import Photo
from ..object import Object
class Photos(Object):
class ProfilePhotos(Object):
"""Contains a user's profile pictures.
Parameters:
total_count (``int``):
Total number of profile pictures the target user has.
photos (List of :obj:`Photo`):
profile_photos (List of :obj:`Photo`):
Requested profile pictures.
"""
__slots__ = ["total_count", "photos"]
__slots__ = ["total_count", "profile_photos"]
def __init__(
self,
*,
client: "pyrogram.BaseClient" = None,
total_count: int,
photos: List[Photo]
profile_photos: List[Photo]
):
super().__init__(client)
self.total_count = total_count
self.photos = photos
self.profile_photos = profile_photos
@staticmethod
def _parse(client, photos) -> "Photos":
return Photos(
def _parse(client, photos) -> "ProfilePhotos":
return ProfilePhotos(
total_count=getattr(photos, "count", len(photos.photos)),
photos=[Photo._parse(client, photo) for photo in photos.photos],
profile_photos=[Photo._parse(client, photo) for photo in photos.photos],
client=client
)