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

33 lines
863 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
2020-05-03 10:41:36 -04:00
2020-06-19 14:40:41 -04:00
from ubot.micro_bot 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-06-06 11:04:14 -04:00
await event.reply(f"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)
2020-06-06 14:48:45 -04:00
if event.args == "black":
await event.client.send_message(event.chat_id, "Racism is no more!")