-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathwhat.py
More file actions
37 lines (33 loc) · 1.12 KB
/
what.py
File metadata and controls
37 lines (33 loc) · 1.12 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
from .. import loader, utils
from PIL import Image, ImageDraw
from random import randint
from io import BytesIO
@loader.tds
class WhatMod(loader.Module):
"""wow, what is it there?"""
strings = {"name": "What?"}
async def whatcmd(self, message):
"""Draw circle in random place"""
args = utils.get_args_raw(message)
scale = int(args) if args and args.isdigit() else 50
scale = 10 if scale < 0 else scale
scale = 100 if scale > 100 else scale
reply = await message.get_reply_message()
if not reply or not reply.file.mime_type.split("/")[0].lower() == "image":
await message.edit("<b>Reply to img!</b>")
return
await message.edit("<b>What is it?</b>")
im = BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
f = (min(w,h)//100)*scale
draw = ImageDraw.Draw(im)
x, y = randint(0, w-f), randint(0, h-f)
draw.ellipse((x, y, x+randint(f//2, f), y+randint(f//2, f)), fill=None, outline="red", width=randint(3, 10))
out = BytesIO()
out.name = "what.png"
im.save(out)
out.seek(0)
await message.delete()
return await reply.reply(file=out)