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

32 lines
801 B
Python
Raw Normal View History

2020-05-03 10:41:36 -04:00
# SPDX-License-Identifier: GPL-2.0-or-later
import io
from PIL import Image, ImageColor
from ubot.micro_bot import micro_bot
ldr = micro_bot.loader
@ldr.add("color")
async def stickcolor(event):
2020-05-03 10:46:02 -04:00
if not event.args:
await event.reply(f"`Specify a valid color, use #colorhex or a color name.`")
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:
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)