-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathboy_cott_image_gen.py
More file actions
55 lines (51 loc) · 1.88 KB
/
Copy pathboy_cott_image_gen.py
File metadata and controls
55 lines (51 loc) · 1.88 KB
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
# Copyright (C) 2020-2021 by DevsExpo@Github, < https://github.com/DevsExpo >.
#
# This file is part of < https://github.com/DevsExpo/FridayUserBot > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/DevsExpo/blob/master/LICENSE >
#
# All rights reserved.
import os
from main_startup.core.decorators import friday_on_cmd
from main_startup.helper_func.basic_helpers import edit_or_reply
from main_startup.helper_func.plugin_helpers import convert_to_image
from PIL import Image
@friday_on_cmd(
["boycott"],
is_official=False,
cmd_help={
"help": "Creates Boycott Image!",
"example": "{ch}boycott (reply to image)",
},
)
async def boycott_kangs(client, message):
tgi = await edit_or_reply(message, "`Applying BoyCott Magic!`")
if not message.reply_to_message:
await tgi.edit("`Please, Reply To Media To Add Boycott Magic!`")
return
img = await convert_to_image(message, client)
if not img:
await tgi.edit("`Reply to a valid media first.`")
return
if not os.path.exists(img):
await tgi.edit("`Invalid Media!`")
return
background = Image.open(img).convert("RGBA")
foreground = Image.open("./xtraplugins/helper_files/x-cross.png").convert("RGBA")
x, y = foreground.size
foreground = foreground.resize(background.size)
background.paste(foreground, (0, 0), foreground)
file_name = "bcig.webp"
background.save(file_name, "WebP")
if message.reply_to_message:
await client.send_sticker(
message.chat.id,
sticker=file_name,
reply_to_message_id=message.reply_to_message.message_id,
)
else:
await client.send_sticker(message.chat.id, sticker=file_name)
await tgi.delete()
for files in (file_name, img):
if files and os.path.exists(files):
os.remove(files)