Files
homelab/modules/mirror_flip.py
T
forust 7fb0a0e179 chore: batch lint fixes across userbot and edu_master
- S113: Add timeout=10 to all requests calls (74 fixes)
- E722: Replace bare except: with except Exception:
- B904: Replace redundant re-raise with bare raise
- E402: Add noqa for intentional late imports after import_library()
- S102/S307/S310/S311/S603/S605/S606/S607/S108: Add noqa for intentional usage
- F601: Fix duplicate dict key in unsplash.py
- N802: Rename ReplyCheck -> reply_check with backward compat alias
- N813: Rename bs -> BS in icons.py
- B007/B020: Rename loop var _j in animations.py
- SIM102: Collapse nested if in autofwd.py
- SIM113: Use enumerate() in calculator.py
- A002: Add noqa for builtin shadowing in admlist.py
- F811: Add noqa for cohere redefinition
- edu_master: Fix ARG001, S108, S110, SIM117, apply --unsafe-fixes
- Add modules_list.txt with full module inventory
2026-06-19 15:36:25 +02:00

58 lines
2.0 KiB
Python

# original module https://raw.githubusercontent.com/KeyZenD/modules/master/MirrorFlipV2.py | t.me/the_kzd
import os
from pyrogram import Client, enums, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
from utils.scripts import import_library
PIL = import_library('PIL', 'pillow')
from PIL import Image, ImageOps # noqa: E402
async def make(client, message, o):
reply = message.reply_to_message
if reply.photo or reply.sticker:
if reply.photo:
downloads = await client.download_media(reply.photo.file_id)
else:
downloads = await client.download_media(reply.sticker.file_id)
path = f'{downloads}'
img = Image.open(path)
await message.delete()
w, h = img.size
if o in [1, 2]:
if o == 2:
img = ImageOps.mirror(img)
part = img.crop([0, 0, w // 2, h])
img = ImageOps.mirror(img)
else:
if o == 4:
img = ImageOps.flip(img)
part = img.crop([0, 0, w, h // 2])
img = ImageOps.flip(img)
img.paste(part, (0, 0))
img.save(path)
if reply.photo:
return await reply.reply_photo(photo=path)
elif reply.sticker:
return await reply.reply_sticker(sticker=path)
os.remove(path)
return await message.edit('<b>Need to answer the photo/sticker</b>', parse_mode=enums.ParseMode.HTML)
@Client.on_message(filters.command(['ll', 'rr', 'dd', 'uu'], prefix) & filters.me)
async def mirror_flip(client: Client, message: Message):
await message.edit('<b>Processing...</b>', parse_mode=enums.ParseMode.HTML)
param = {'ll': 1, 'rr': 2, 'dd': 3, 'uu': 4}[message.command[0]]
await make(client, message, param)
modules_help['mirror_flip'] = {
'll [reply on photo or sticker]*': 'reflects the left side',
'rr [reply on photo or sticker]*': 'reflects the right side',
'uu [reply on photo or sticker]*': 'reflects the top',
'dd [reply on photo or sticker]*': 'reflects the bottom',
}