mirror of
https://github.com/Nick80835/microbot
synced 2025-08-23 02:28:31 +00:00
28 lines
676 B
Python
28 lines
676 B
Python
|
# 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):
|
||
|
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)
|