From 6bc2db7157c3ac24e2ccbef72e2e5e6ee27312c4 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 17 Dec 2018 16:14:32 +0100 Subject: [PATCH] Better way of parsing total_count for Messages and UserProfilePhotos --- pyrogram/client/types/messages_and_media/messages.py | 4 +--- .../client/types/messages_and_media/user_profile_photos.py | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/messages.py b/pyrogram/client/types/messages_and_media/messages.py index 5619b968..cd53c38a 100644 --- a/pyrogram/client/types/messages_and_media/messages.py +++ b/pyrogram/client/types/messages_and_media/messages.py @@ -43,10 +43,8 @@ class Messages(PyrogramType): users = {i.id: i for i in messages.users} chats = {i.id: i for i in messages.chats} - total_count = getattr(messages, "count", len(messages.messages)) - return Messages( - total_count=total_count, + total_count=getattr(messages, "count", len(messages.messages)), messages=[Message.parse(client, message, users, chats) for message in messages.messages], client=client, raw=messages diff --git a/pyrogram/client/types/messages_and_media/user_profile_photos.py b/pyrogram/client/types/messages_and_media/user_profile_photos.py index ca277a95..2196608f 100644 --- a/pyrogram/client/types/messages_and_media/user_profile_photos.py +++ b/pyrogram/client/types/messages_and_media/user_profile_photos.py @@ -16,7 +16,6 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . -from pyrogram.api import types from .photo import Photo from ..pyrogram_type import PyrogramType @@ -41,7 +40,7 @@ class UserProfilePhotos(PyrogramType): @staticmethod def parse(client, photos) -> "UserProfilePhotos": return UserProfilePhotos( - total_count=len(photos.photos) if isinstance(photos, types.photos.Photos) else photos.count, + total_count=getattr(photos, "count", len(photos.photos)), photos=[Photo.parse(client, photo) for photo in photos.photos], client=client, raw=photos