Files
HeXi/dev/plugin_template/nonebot_plugin_template/__init__.py
T

39 lines
1.2 KiB
Python
Raw Normal View History

"""<插件名> — MTSS 结构 + 统一配置标准参考模板。
放在 hexi/plugins/ 后改名:目录 nonebot_plugin_<name>,并替换所有
`nonebot_plugin_template` / `template` 占位(建议全局搜索替换)。
结构:Trigger(handlers) → Service(services) → Model(repository/models)。
配置在 config.py 统一注册,Web 可读可改。
"""
from nonebot import require
from nonebot.plugin import PluginMetadata
require("nonebot_plugin_alconna")
__plugin_meta__ = PluginMetadata(
name="插件模板",
description="MTSS 结构 + 统一配置标准参考模板",
usage="模板指令 [参数]",
type="application",
)
# 入口只做四件事:require / meta / 导入子模块 / 配置注册
from . import config as _config # noqa: E402,F401
from . import handlers as _handlers # noqa: E402,F401
from . import web as _web # noqa: E402,F401
from hexi.web_plugin_registry import register_web_plugin # noqa: E402
_config.register_config()
# 注册到统一 Web 管理台(/hub):hub 启动时自动挂载 /api/template
register_web_plugin(
"template",
"插件模板",
"user",
lambda: _web.build_admin_app(),
module_name=__name__,
)