diff --git a/modules/thumbnail.py b/modules/thumbnail.py index 0905d13..2151927 100644 --- a/modules/thumbnail.py +++ b/modules/thumbnail.py @@ -1,4 +1,5 @@ import os +import imghdr from pyrogram import Client, enums, filters from pyrogram.types import Message @@ -9,14 +10,16 @@ from utils.misc import prefix, modules_help @Client.on_message(filters.command("setthumb", prefix) & filters.me) async def setthumb(_, message: Message): THUMB_PATH = "downloads/thumb" - if message.reply_to_message == enums.MessageMediaType.PHOTO: + if message.reply_to_message: if not os.path.exists(THUMB_PATH): - os.mkdirs(THUMB_PATH) + os.makedirs(THUMB_PATH) new_thumb = await message.reply_to_message.download() - - new_path = os.path.join(THUMB_PATH, "thumb.jpg") - os.rename(new_thumb, new_path) - await message.edit_text("Thumbnail set successfully!") + type_thumb = imghdr.what(new_thumb) + if type_thumb: + if type_thumb in ["png", "jpg", "jpeg"]: + new_path = os.path.join(THUMB_PATH, "thumb.jpg") + os.rename(new_thumb, new_path) + await message.edit_text("Thumbnail set successfully!") else: await message.edit_text("Kindly reply to a PHOTO Entity!") return