|
@@ -78,18 +78,23 @@ async def set_user_title(_, message):
|
|
|
@app.on_message(filters.command("set_chat_photo") & ~filters.private)
|
|
@app.on_message(filters.command("set_chat_photo") & ~filters.private)
|
|
|
@adminsOnly("can_change_info")
|
|
@adminsOnly("can_change_info")
|
|
|
async def set_chat_photo(_, message):
|
|
async def set_chat_photo(_, message):
|
|
|
- if not message.reply_to_message:
|
|
|
|
|
|
|
+ reply = message.reply_to_message
|
|
|
|
|
+
|
|
|
|
|
+ if not reply:
|
|
|
return await message.reply_text(
|
|
return await message.reply_text(
|
|
|
"Reply to a photo to set it as chat_photo"
|
|
"Reply to a photo to set it as chat_photo"
|
|
|
)
|
|
)
|
|
|
- if (
|
|
|
|
|
- not message.reply_to_message.photo
|
|
|
|
|
- and not message.reply_to_message.document
|
|
|
|
|
- ):
|
|
|
|
|
|
|
+
|
|
|
|
|
+ file = reply.document or reply.photo
|
|
|
|
|
+ if not file:
|
|
|
return await message.reply_text(
|
|
return await message.reply_text(
|
|
|
- "Reply to a photo to set it as chat_photo"
|
|
|
|
|
|
|
+ "Reply to a photo or document to set it as chat_photo"
|
|
|
)
|
|
)
|
|
|
- photo = await message.reply_to_message.download()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if file.file_size > 5000000:
|
|
|
|
|
+ return await message.reply("File size too large.")
|
|
|
|
|
+
|
|
|
|
|
+ photo = await reply.download()
|
|
|
await message.chat.set_photo(photo)
|
|
await message.chat.set_photo(photo)
|
|
|
await message.reply_text("Successfully Changed Group Photo")
|
|
await message.reply_text("Successfully Changed Group Photo")
|
|
|
os.remove(photo)
|
|
os.remove(photo)
|