fix: thumbnail support

This commit is contained in:
Abhi
2024-06-01 10:25:29 +05:30
parent 6c6a09df67
commit 3b1fdca99b

View File

@@ -1,4 +1,5 @@
import os
import imghdr
from pyrogram import Client, enums, filters
from pyrogram.types import Message
@@ -9,11 +10,13 @@ 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()
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!")