mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 21:07:59 +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
|
# 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/>.
|
||||||
|
|
||||||
|
import pyrogram
|
||||||
from pyrogram.api import functions
|
from pyrogram.api import functions
|
||||||
from ...ext import BaseClient, utils
|
from ...ext import BaseClient
|
||||||
|
|
||||||
|
|
||||||
class GetUserProfilePhotos(BaseClient):
|
class GetUserProfilePhotos(BaseClient):
|
||||||
@ -47,7 +48,8 @@ class GetUserProfilePhotos(BaseClient):
|
|||||||
Raises:
|
Raises:
|
||||||
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
:class:`Error <pyrogram.Error>` in case of a Telegram RPC error.
|
||||||
"""
|
"""
|
||||||
return utils.parse_profile_photos(
|
return pyrogram.UserProfilePhotos.parse(
|
||||||
|
self,
|
||||||
self.send(
|
self.send(
|
||||||
functions.photos.GetUserPhotos(
|
functions.photos.GetUserPhotos(
|
||||||
user_id=self.resolve_peer(user_id),
|
user_id=self.resolve_peer(user_id),
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
# 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 pyrogram.api import types
|
||||||
|
from .photo import Photo
|
||||||
from ..pyrogram_type import PyrogramType
|
from ..pyrogram_type import PyrogramType
|
||||||
|
|
||||||
|
|
||||||
@ -35,3 +37,12 @@ class UserProfilePhotos(PyrogramType):
|
|||||||
|
|
||||||
self.total_count = total_count
|
self.total_count = total_count
|
||||||
self.photos = photos
|
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…
x
Reference in New Issue
Block a user