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