2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-23 10:38:51 +00:00
microbot/ubot/modules/sticklet.py

37 lines
845 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
color_sticker = await ldr.run_async(stickcolorsync, event.args)
if color_sticker:
await event.reply(file=color_sticker)
else:
await event.reply(f"**{event.args}** is an invalid color, use #colorhex or a color name.")
def stickcolorsync(color):
try:
image = Image.new("RGBA", (512, 512), color)
except:
try:
image = Image.new("RGBA", (512, 512), "#" + color)
except:
return
image_stream = io.BytesIO()
image_stream.name = "sticker.webp"
image.save(image_stream, "WebP")
image_stream.seek(0)
return image_stream