2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Better way of parsing total_count for Messages and UserProfilePhotos

This commit is contained in:
Dan 2018-12-17 16:14:32 +01:00
parent e6dced80cf
commit 6bc2db7157
2 changed files with 2 additions and 5 deletions

View File

@ -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

View File

@ -16,7 +16,6 @@
# 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
@ -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