From b412622bc74bbe66e818d7b483a88ca61992c9c4 Mon Sep 17 00:00:00 2001 From: wulan17 Date: Mon, 2 Sep 2024 20:31:50 +0700 Subject: [PATCH] pyrofork: Fix get_chat_photo incase photo not found and limit param is enabled Signed-off-by: wulan17 --- pyrogram/methods/users/get_chat_photos.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pyrogram/methods/users/get_chat_photos.py b/pyrogram/methods/users/get_chat_photos.py index 6c34d6a5..1c1fa129 100644 --- a/pyrogram/methods/users/get_chat_photos.py +++ b/pyrogram/methods/users/get_chat_photos.py @@ -96,10 +96,16 @@ class GetChatPhotos: ) ) - extra = [message.new_chat_photo for message in r] + extra = [message.new_chat_photo for message in r] if r else [] if extra: - if current: + if ( + current + and + len(current) > 0 + and + isinstance(current[0], types.Photo) + ): photos = (current + extra) if current[0].file_id != extra[0].file_id else extra else: photos = extra @@ -111,6 +117,9 @@ class GetChatPhotos: current = 0 + if len(photos) == 0 or (len(photos) == 1 and not isinstance(photos[0], types.Photo)): + return + for photo in photos: yield photo