插件化内核
内核只负责加载插件、路由事件、提供公共能力;连 IM、开后台、管会话、跑定时都是可插拔的官方插件。
ZCBOT 起步于 OneBot 11 接入端,但插件化、权限、持久化、Web 后台这些骨架从一开始就是通用的。 现在框架内核不包含任何 IM 协议实现——OneBot 11 只是 onebot_adapter 这个官方插件, 关掉它,框架照样能作为纯定时服务或 HTTP Webhook 接收器运行。
# 一个最小插件:plugins/hello/main.py
__plugin_meta__ = {
"name": "Hello",
"version": "1.0.0",
"author": "你的名字",
"desc": "一个简单的 Hello 插件",
"priority": 50,
}
def register(ctx):
ctx.command("/hello", handle_hello, description="打个招呼")
def handle_hello(event, match):
ctx.send_msg(
user_id=event.user_id,
group_id=event.group_id if event.is_group else None,
message="Hello, World!"
)git clone https://github.com/kuangxing6367/zcbot.git
cd zcbot
python main.py启动后打开 http://127.0.0.1:8080 进入 Web 管理后台。不需要 IM 接入端也能跑: 在 core_plugins.yaml 里开 http_inject,用一条 curl 就能注入事件。