Files
konabot/konabot/plugins/marchtoy/__init__.py
alcoholicgirl b720504e48 bug fixes
2026-04-27 01:26:42 +08:00

19 lines
765 B
Python

from nonebot import on_command
from nonebot.adapters import Message
from nonebot_plugin_alconna import UniMessage
from nonebot.params import CommandArg
import konabot.plugins.marchtoy.gl_render as render
import io
cmd_marchtoy = on_command("march")
@cmd_marchtoy.handle()
async def _(args: Message = CommandArg()):
if cmd := args.extract_plain_text():
try:
img = await render.render(cmd, (512, 512))
buffer = io.BytesIO()
# img.show()
img.save(buffer, format="PNG")
buffer.seek(0)
await cmd_marchtoy.send(await UniMessage().image(raw=buffer).export())
except Exception as e:
await cmd_marchtoy.send(await UniMessage.text(f"发生了错误: {e}").export())