diff --git a/konabot/plugins/marchtoy/__init__.py b/konabot/plugins/marchtoy/__init__.py new file mode 100644 index 0000000..7ed576e --- /dev/null +++ b/konabot/plugins/marchtoy/__init__.py @@ -0,0 +1,15 @@ +from nonebot import on_command +from nonebot.adapters import Message +from nonebot_plugin_alconna import UniMessage +from nonebot.params import CommandArg +import render +import io +cmd_marchtoy = on_command("march", priority=10, block=True) +@cmd_marchtoy.handle() +async def _(args: Message = CommandArg()): + if cmd := args.extract_plain_text(): + img = await render.render(cmd, 256, 256) + buffer = io.BytesIO() + img.save(buffer, format="PNG") + buffer.seek(0) + await cmd_marchtoy.send(await UniMessage().image(raw=buffer).export()) \ No newline at end of file diff --git a/konabot/plugins/sksl/marchtoy/command.py b/konabot/plugins/marchtoy/command.py similarity index 97% rename from konabot/plugins/sksl/marchtoy/command.py rename to konabot/plugins/marchtoy/command.py index e1d3157..3fa72e1 100644 --- a/konabot/plugins/sksl/marchtoy/command.py +++ b/konabot/plugins/marchtoy/command.py @@ -18,8 +18,8 @@ from dataclasses import dataclass import re import numpy as np from dataclasses import dataclass -from obj import Object, Camera, OBJECT_ENTRIES -from op import OPERATION_ENTRIES +from konabot.plugins.marchtoy.obj import Object, Camera, OBJECT_ENTRIES +from konabot.plugins.marchtoy.op import OPERATION_ENTRIES from typing import Optional @dataclass diff --git a/konabot/plugins/sksl/marchtoy/obj.py b/konabot/plugins/marchtoy/obj.py similarity index 96% rename from konabot/plugins/sksl/marchtoy/obj.py rename to konabot/plugins/marchtoy/obj.py index 6cba20f..0c3e62f 100644 --- a/konabot/plugins/sksl/marchtoy/obj.py +++ b/konabot/plugins/marchtoy/obj.py @@ -1,6 +1,6 @@ import numpy as np -from texture import Texture -from utilities import ArgParser, SkslFormatter +from konabot.plugins.marchtoy.texture import Texture +from konabot.plugins.marchtoy.utilities import ArgParser, SkslFormatter OBJECT_ENTRIES = {} diff --git a/konabot/plugins/sksl/marchtoy/op.py b/konabot/plugins/marchtoy/op.py similarity index 93% rename from konabot/plugins/sksl/marchtoy/op.py rename to konabot/plugins/marchtoy/op.py index cfea952..bc04601 100644 --- a/konabot/plugins/sksl/marchtoy/op.py +++ b/konabot/plugins/marchtoy/op.py @@ -1,6 +1,6 @@ -from obj import Object +from konabot.plugins.marchtoy.obj import Object import numpy as np -from utilities import ArgParser +from konabot.plugins.marchtoy.utilities import ArgParser OPERATION_ENTRIES = {} diff --git a/konabot/plugins/sksl/marchtoy/render.py b/konabot/plugins/marchtoy/render.py similarity index 96% rename from konabot/plugins/sksl/marchtoy/render.py rename to konabot/plugins/marchtoy/render.py index 8a87425..df7ac84 100644 --- a/konabot/plugins/sksl/marchtoy/render.py +++ b/konabot/plugins/marchtoy/render.py @@ -1,4 +1,4 @@ -from command import Scene +from konabot.plugins.marchtoy.command import Scene import skia import struct from PIL import Image diff --git a/konabot/plugins/sksl/marchtoy/shaders/raymarch.sksl b/konabot/plugins/marchtoy/shaders/raymarch.sksl similarity index 100% rename from konabot/plugins/sksl/marchtoy/shaders/raymarch.sksl rename to konabot/plugins/marchtoy/shaders/raymarch.sksl diff --git a/konabot/plugins/sksl/marchtoy/texture.py b/konabot/plugins/marchtoy/texture.py similarity index 100% rename from konabot/plugins/sksl/marchtoy/texture.py rename to konabot/plugins/marchtoy/texture.py diff --git a/konabot/plugins/sksl/marchtoy/utilities.py b/konabot/plugins/marchtoy/utilities.py similarity index 97% rename from konabot/plugins/sksl/marchtoy/utilities.py rename to konabot/plugins/marchtoy/utilities.py index ed2ed55..efe79e3 100644 --- a/konabot/plugins/sksl/marchtoy/utilities.py +++ b/konabot/plugins/marchtoy/utilities.py @@ -1,5 +1,5 @@ import numpy as np -from texture import COLORS +from konabot.plugins.marchtoy.texture import COLORS class SkslFormatter: diff --git a/konabot/plugins/sksl/__init__.py b/konabot/plugins/sksl/__init__.py index 8661df5..bc60df9 100644 --- a/konabot/plugins/sksl/__init__.py +++ b/konabot/plugins/sksl/__init__.py @@ -2,11 +2,6 @@ from nonebot_plugin_alconna import Alconna, Args, Option, UniMessage, on_alconna from konabot.common.nb.exc import BotExceptionMessage from konabot.plugins.sksl.run_sksl import render_sksl_shader_to_gif -from nonebot import on_command -from nonebot.adapters import Bot, Event, Message -from nonebot.params import CommandArg -import marchtoy -import io cmd_run_sksl = on_alconna( Alconna( @@ -49,15 +44,4 @@ async def _( except (ValueError, RuntimeError) as e: await cmd_run_sksl.send( await UniMessage().text(f"渲染时遇到了问题:\n\n{e}").export() - ) - - -cmd_marchtoy = on_command("march", priority=10, block=True) -@cmd_marchtoy.handle() -async def _(args: Message = CommandArg()): - if cmd := args.extract_plain_text(): - img = await marchtoy.render.render(cmd, 256, 256) - buffer = io.BytesIO() - img.save(buffer, format="PNG") - buffer.seek(0) - await cmd_run_sksl.send(await UniMessage().image(raw=buffer).export()) \ No newline at end of file + ) \ No newline at end of file diff --git a/konabot/plugins/sksl/marchtoy/__init__.py b/konabot/plugins/sksl/marchtoy/__init__.py deleted file mode 100644 index 17e1f95..0000000 --- a/konabot/plugins/sksl/marchtoy/__init__.py +++ /dev/null @@ -1 +0,0 @@ -import render \ No newline at end of file