2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-22 01:58:17 +00:00
microbot/ubot/modules/sticklet.py
2023-10-16 09:54:07 -04:00

28 lines
699 B
Python

import io
from PIL import Image
from ubot import ldr
@ldr.add("color")
async def stickcolor(event):
if not event.args:
await event.reply("Specify a valid color, use #colorhex or a color name.")
return
try:
image = Image.new("RGBA", (512, 512), event.args)
except:
try:
image = Image.new("RGBA", (512, 512), "#" + event.args)
except:
await event.reply(f"**{event.args}** is an invalid color, use #colorhex or a color name.")
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)