mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Refactor UserProfilePhotos
This commit is contained in:
parent
a683e3e917
commit
8cbb9c9316
@ -16,8 +16,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram.api import functions
|
||||
from ...ext import BaseClient, utils
|
||||
from ...ext import BaseClient
|
||||
|
||||
|
||||
class GetUserProfilePhotos(BaseClient):
|
||||
@ -47,7 +48,8 @@ class GetUserProfilePhotos(BaseClient):
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||
"""
|
||||
return utils.parse_profile_photos(
|
||||
return pyrogram.UserProfilePhotos.parse(
|
||||
self,
|
||||
self.send(
|
||||
functions.photos.GetUserPhotos(
|
||||
user_id=self.resolve_peer(user_id),
|
||||
|
@ -16,6 +16,8 @@
|
||||
# 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 pyrogram.api import types
|
||||
from .photo import Photo
|
||||
from ..pyrogram_type import PyrogramType
|
||||
|
||||
|
||||
@ -35,3 +37,12 @@ class UserProfilePhotos(PyrogramType):
|
||||
|
||||
self.total_count = total_count
|
||||
self.photos = photos
|
||||
|
||||
@staticmethod
|
||||
def parse(client, photos) -> "UserProfilePhotos":
|
||||
return UserProfilePhotos(
|
||||
total_count=len(photos.photos) if isinstance(photos, types.photos.Photos) else photos.count,
|
||||
photos=[Photo.parse(client, photo) for photo in photos.photos],
|
||||
client=client,
|
||||
raw=photos
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user