Remove ProfilePhotos type
This commit is contained in:
parent
c8fd446cb6
commit
797de058e8
@ -43,7 +43,6 @@ Messages & Media
|
|||||||
- :class:`Messages`
|
- :class:`Messages`
|
||||||
- :class:`MessageEntity`
|
- :class:`MessageEntity`
|
||||||
- :class:`Photo`
|
- :class:`Photo`
|
||||||
- :class:`ProfilePhotos`
|
|
||||||
- :class:`Thumbnail`
|
- :class:`Thumbnail`
|
||||||
- :class:`Audio`
|
- :class:`Audio`
|
||||||
- :class:`Document`
|
- :class:`Document`
|
||||||
@ -129,7 +128,6 @@ Details
|
|||||||
.. autoclass:: Messages()
|
.. autoclass:: Messages()
|
||||||
.. autoclass:: MessageEntity()
|
.. autoclass:: MessageEntity()
|
||||||
.. autoclass:: Photo()
|
.. autoclass:: Photo()
|
||||||
.. autoclass:: ProfilePhotos()
|
|
||||||
.. autoclass:: Thumbnail()
|
.. autoclass:: Thumbnail()
|
||||||
.. autoclass:: Audio()
|
.. autoclass:: Audio()
|
||||||
.. autoclass:: Document()
|
.. autoclass:: Document()
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from typing import Union
|
from typing import Union, List
|
||||||
|
|
||||||
import pyrogram
|
import pyrogram
|
||||||
from pyrogram.api import functions, types
|
from pyrogram.api import functions, types
|
||||||
@ -29,7 +29,7 @@ class GetProfilePhotos(BaseClient):
|
|||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
limit: int = 100
|
limit: int = 100
|
||||||
) -> "pyrogram.ProfilePhotos":
|
) -> List["pyrogram.Photo"]:
|
||||||
"""Get a list of profile pictures for a user or a chat.
|
"""Get a list of profile pictures for a user or a chat.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
@ -47,7 +47,7 @@ class GetProfilePhotos(BaseClient):
|
|||||||
Values between 1—100 are accepted. Defaults to 100.
|
Values between 1—100 are accepted. Defaults to 100.
|
||||||
|
|
||||||
Returns:
|
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:
|
Raises:
|
||||||
RPCError: In case of a Telegram RPC error.
|
RPCError: In case of a Telegram RPC error.
|
||||||
@ -55,17 +55,16 @@ class GetProfilePhotos(BaseClient):
|
|||||||
peer_id = self.resolve_peer(chat_id)
|
peer_id = self.resolve_peer(chat_id)
|
||||||
|
|
||||||
if isinstance(peer_id, types.InputPeerUser):
|
if isinstance(peer_id, types.InputPeerUser):
|
||||||
return pyrogram.ProfilePhotos._parse(
|
r = self.send(
|
||||||
self,
|
functions.photos.GetUserPhotos(
|
||||||
self.send(
|
user_id=peer_id,
|
||||||
functions.photos.GetUserPhotos(
|
offset=offset,
|
||||||
user_id=peer_id,
|
max_id=0,
|
||||||
offset=offset,
|
limit=limit
|
||||||
max_id=0,
|
|
||||||
limit=limit
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return pyrogram.List(pyrogram.Photo._parse(self, photo) for photo in r.photos)
|
||||||
else:
|
else:
|
||||||
new_chat_photos = pyrogram.Messages._parse(
|
new_chat_photos = pyrogram.Messages._parse(
|
||||||
self,
|
self,
|
||||||
@ -86,7 +85,4 @@ class GetProfilePhotos(BaseClient):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return pyrogram.ProfilePhotos(
|
return pyrogram.List([m.new_chat_photo for m in new_chat_photos.messages][:limit])
|
||||||
total_count=new_chat_photos.total_count,
|
|
||||||
profile_photos=[m.new_chat_photo for m in new_chat_photos.messages][:limit]
|
|
||||||
)
|
|
||||||
|
@ -63,7 +63,7 @@ class IterProfilePhotos(BaseClient):
|
|||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
offset=offset,
|
offset=offset,
|
||||||
limit=limit
|
limit=limit
|
||||||
).photos
|
)
|
||||||
|
|
||||||
if not photos:
|
if not photos:
|
||||||
return
|
return
|
||||||
|
@ -28,7 +28,6 @@ from .messages import Messages
|
|||||||
from .photo import Photo
|
from .photo import Photo
|
||||||
from .poll import Poll
|
from .poll import Poll
|
||||||
from .poll_option import PollOption
|
from .poll_option import PollOption
|
||||||
from .profile_photos import ProfilePhotos
|
|
||||||
from .sticker import Sticker
|
from .sticker import Sticker
|
||||||
from .stripped_thumbnail import StrippedThumbnail
|
from .stripped_thumbnail import StrippedThumbnail
|
||||||
from .thumbnail import Thumbnail
|
from .thumbnail import Thumbnail
|
||||||
@ -39,6 +38,5 @@ from .voice import Voice
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo",
|
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Messages", "Photo",
|
||||||
"Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "ProfilePhotos", "Venue", "Video", "VideoNote",
|
"Thumbnail", "StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice"
|
||||||
"Voice"
|
|
||||||
]
|
]
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
|
||||||
# Copyright (C) 2017-2019 Dan Tès <https://github.com/delivrance>
|
|
||||||
#
|
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
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
|
|
||||||
)
|
|
Loading…
Reference in New Issue
Block a user