2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-22 18:19:16 +00:00
microbot/ubot/modules/sticklet.py

28 lines
699 B
Python
Raw Normal View History

2020-05-03 10:41:36 -04:00
import io
from PIL import Image
2020-05-03 10:41:36 -04:00
2020-09-13 13:50:36 -04:00
from ubot import ldr
2020-05-03 10:41:36 -04:00
@ldr.add("color")
async def stickcolor(event):
2020-05-03 10:46:02 -04:00
if not event.args:
2020-10-10 19:38:21 -04:00
await event.reply("Specify a valid color, use #colorhex or a color name.")
2020-05-03 10:46:02 -04:00
return
2020-05-03 10:41:36 -04:00
try:
image = Image.new("RGBA", (512, 512), event.args)
except:
try:
image = Image.new("RGBA", (512, 512), "#" + event.args)
except:
2020-06-06 11:04:14 -04:00
await event.reply(f"**{event.args}** is an invalid color, use #colorhex or a color name.")
2020-05-03 10:41:36 -04:00
return
image_stream = io.BytesIO()
image_stream.name = "sticker.webp"
image.save(image_stream, "WebP")
image_stream.seek(0)
await event.reply(file=image_stream)