-
Notifications
You must be signed in to change notification settings - Fork 1
/
img_memes.py
159 lines (144 loc) · 5.25 KB
/
img_memes.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import cv2
import html
import os
from PIL import Image
from telegraph import upload_file
from telethon.tl.functions.users import GetFullUserRequest
from . import *
dwllpath = "./imgs/"
if not os.path.isdir(dwllpath):
os.makedirs(dwllpath)
@bot.on(d3vil_cmd(pattern=r"thug"))
@bot.on(sudo_cmd(pattern=r"thug", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
if not event.reply_to_msg_id:
return await eod(event, "Reply to a image...")
d3vil = await eor(event, "`Converting To thug Image..`")
await event.get_reply_message()
img = await convert_to_image(event, bot)
imagePath = img
maskPath = "./resources/Pics/mask.png"
cascPath = "./resources/xmls/haarcascade_frontalface_default.xml"
faceCascade = cv2.CascadeClassifier(cascPath)
image = cv2.imread(imagePath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(gray, 1.15)
background = Image.open(imagePath)
for (x, y, w, h) in faces:
mask = Image.open(maskPath)
mask = mask.resize((w, h), Image.ANTIALIAS)
offset = (x, y)
background.paste(mask, offset, mask=mask)
file_name = "thug.png"
ok = dwllpath + "/" + file_name
background.save(ok, "PNG")
await bot.send_file(event.chat_id, ok)
await d3vil.delete()
for files in (ok, img):
if files and os.path.exists(files):
os.remove(files)
@bot.on(d3vil_cmd(pattern=r"trigger"))
@bot.on(sudo_cmd(pattern=r"trigger", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
await eor(event, "`Trigggggggggerrr`")
owo = await event.get_reply_message()
img = await convert_to_image(event, bot)
url_s = upload_file(img)
imglink = f"https://telegra.ph{url_s[0]}"
doit = f"https://some-random-api.ml/canvas/triggered?avatar={imglink}"
r = requests.get(doit)
open("triggered.gif", "wb").write(r.content)
lolbruh = "triggered.gif"
await bot.send_file(
event.chat_id, lolbruh, caption="You got triggered....", reply_to=owo
)
for files in (lolbruh, img):
if files and os.path.exists(files):
os.remove(files)
@bot.on(d3vil_cmd(pattern=r"geyy"))
@bot.on(sudo_cmd(pattern=r"geyy", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
await eor(event, "`Geyyyy`")
owo = await event.get_reply_message()
img = await convert_to_image(event, bot)
url_s = upload_file(img)
imglink = f"https://telegra.ph{url_s[0]}"
doit = f"https://some-random-api.ml/canvas/gay?avatar={imglink}"
r = requests.get(doit)
open("geys.png", "wb").write(r.content)
lolbruh = "geys.png"
await bot.send_file(
event.chat_id, lolbruh, caption="`You Gey.`", reply_to=owo
)
for files in (lolbruh, img):
if files and os.path.exists(files):
os.remove(files)
@bot.on(d3vil_cmd(pattern=r"pix"))
@bot.on(sudo_cmd(pattern=r"pix", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
await eor(event, "`Pixing This Image.`")
owo = await event.get_reply_message()
img = await convert_to_image(event, bot)
url_s = upload_file(img)
imglink = f"https://telegra.ph{url_s[0]}"
doit = f"https://some-random-api.ml/canvas/pixelate?avatar={imglink}"
r = requests.get(doit)
open("pix.png", "wb").write(r.content)
lolbruh = "pix.png"
await bot.send_file(
event.chat_id, lolbruh, caption="`Pixeled This Image.`", reply_to=owo
)
for files in (lolbruh, img):
if files and os.path.exists(files):
os.remove(files)
@bot.on(d3vil_cmd(pattern="ytc"))
@bot.on(sudo_cmd(pattern="ytc", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
d3vil = await eor(event, "`Making a youthuub comment...`")
owo = await event.get_reply_message()
senderr = await event.client(GetFullUserRequest(owo.sender_id))
if not senderr.profile_photo:
imglink = 'https://telegra.ph/file/93e181ec03a3761a63918.jpg'
elif senderr.profile_photo:
img = await bot.download_media(senderr.profile_photo, dwllpath)
url_s = upload_file(img)
imglink = f"https://telegra.ph{url_s[0]}"
first_name = html.escape(senderr.user.first_name)
if first_name is not None:
first_name = first_name.replace("\u2060", "")
if owo.text is None:
comment = 'Give Some Text'
else:
comment = owo.raw_text
doit = f"https://some-random-api.ml/canvas/youtube-comment?avatar={imglink}&username={first_name}&comment={comment}"
r = requests.get(doit)
open("ytc.png", "wb").write(r.content)
lolbruh = "ytc.png"
await d3vil.delete()
await bot.send_file(
event.chat_id, lolbruh, reply_to=owo
)
for files in (lolbruh, img):
if files and os.path.exists(files):
os.remove(files)
CmdHelp("img_memes").add_command(
"ytc", "<reply to a msg>", "Makes a fake youtube comment."
).add_command(
"pix", "<reply to a img>", "Pixilates the replied image."
).add_command(
"geyy", "<reply to a img>", "Makes the replied image gey."
).add_command(
"trigger", "<reply to a img>", "Makes a triggered gif of replied image."
).add_command(
"thug", "<reply to a img>", "Adds a thug life glasses and cigar to face detected in replied image."
).add()