-
Notifications
You must be signed in to change notification settings - Fork 22
/
mirror_flip.py
59 lines (48 loc) · 1.96 KB
/
mirror_flip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# original module https://raw.githubusercontent.com/KeyZenD/modules/master/MirrorFlipV2.py | t.me/the_kzd
import os
from pyrogram import Client, 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
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>")
@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>")
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",
}