OpenClaw OneBot
by @xucheng
OneBot 11 channel plugin for QQ messaging (NapCat/go-cqhttp). Native OpenClaw integration with private/group chat, opt-in group reactions, block streaming, v...
clawhub install openclaw-onebot📖 About This Skill
name: openclaw-onebot description: "OneBot 11 channel plugin for QQ messaging (NapCat/go-cqhttp). Native OpenClaw integration with private/group chat, opt-in group reactions, block streaming, voice pipeline, message batching, allowFrom filtering, shared-dir media staging, and authorized text-command passthrough. 120 tests." metadata: openclaw: emoji: "🐧" type: "channel-plugin" requires: config: ["channels.onebot.wsUrl", "channels.onebot.httpUrl"] bins: ["node", "npm"]
OpenClaw OneBot 11 Channel Plugin
中文
源码仓库可在 GitHub 查看。
OpenClaw 的 OneBot 11 协议通道插件,让 QQ 成为 OpenClaw 一等消息通道。
支持 NapCat、go-cqhttp 等所有兼容 OneBot 11 协议的 QQ 机器人框架。
说明:
openclaw-onebotopenclaw-onebot-pluginid 是 openclaw-onebotid 仍然是 onebotplugins.allow / plugins.entries 使用 openclaw-onebot;安装记录由 openclaw plugins install 管理channels.onebot 保持不变2026.4.26 / plugin-sdk 2026.4.26,并声明 setupEntry 与 channelConfigs manifest metadata功能
set_msg_emoji_like 给群消息加表情回应;QQ 私聊目前不稳定/通常不生效/status、/help、/commands、/model、/new、/reset 等命令allowFrom 消息来源过滤(私聊/群聊/用户级别)allowFrom 时 QQ 文本命令不会被授权;需要显式白名单或 ["*"]npm run coverage 复核快速开始
#### 1. 安装
# 推荐:直接安装已发布的 ClawHub payload
openclaw plugins install clawhub:openclaw-onebot-plugin自动安装;默认不会修改本机 OpenClaw CLI dist
bash scripts/install.sh或审查源码后手动准备本地发布包
npm install && npm run prepare:clawhub:plugin
openclaw plugins install .clawhub-plugin/openclaw-onebot-plugin
scripts/install.sh 会先在源码仓库生成 .clawhub-plugin/openclaw-onebot-plugin 精简发布包,并优先通过 openclaw plugins install 写入新版插件安装索引;旧版 OpenClaw 会回退到手动复制安装。脚本默认不会修改 OpenClaw CLI dist;只有当你的 OpenClaw 构建缺少 --shared-dir / --container-shared-dir setup 参数时,才需要显式执行 ONEBOT_SYNC_OPENCLAW_CLI=1 bash scripts/install.sh 或 npm run sync:openclaw-cli。
#### 2. 配置
在 openclaw.json 中添加:
{
"plugins": {
"allow": ["openclaw-onebot"],
"entries": {
"openclaw-onebot": {
"enabled": true
}
}
},
"channels": {
"onebot": {
"enabled": true,
"wsUrl": "ws://your-host:3001",
"httpUrl": "http://your-host:3001",
"accessToken": "your_token",
"sharedDir": "/Users/you/napcat/shared",
"containerSharedDir": "/shared",
"allowFrom": ["private:12345"],
"groupAutoReact": false,
"groupAutoReactEmojiId": 1
}
}
}
说明:
openclaw-onebotchannels.onebotallowFrom 为可信 QQ 私聊或群聊;不配置时普通消息仍可进入通道,但 /status、/model 等 OpenClaw 文本命令不会被授权accessToken 应使用强随机值,并只把 OneBot HTTP/WebSocket 端点暴露给本机或可信网络sharedDir 建议使用专用目录,不要与下载、桌面、文档等私人文件目录混用plugins.installs;新版 OpenClaw 会把插件安装记录保存在托管安装索引中,请使用 openclaw plugins install 也支持环境变量:
ONEBOT_WS_URL=ws://your-host:3001
ONEBOT_HTTP_URL=http://your-host:3001
ONEBOT_ACCESS_TOKEN=your_token # 可选
OneBot setup 也支持:
--token wsUrl,httpUrl[,accessToken[,sharedDir[,containerSharedDir]]]openclaw channels add --channel onebot --shared-dir --container-shared-dir /shared npm run sync:openclaw-cli 重新同步参数接线#### 3. 重启 Gateway
openclaw gateway restart
高级配置
{
"channels": {
"onebot": {
"enabled": true,
"wsUrl": "ws://your-host:3001",
"httpUrl": "http://your-host:3001",
"accessToken": "your_token",
"sharedDir": "/Users/you/napcat/shared",
"containerSharedDir": "/shared",
"allowFrom": ["private:12345", "group:67890"],
"groupAutoReact": false,
"groupAutoReactEmojiId": 1
}
}
}
| 参数 | 说明 |
|------|------|
| allowFrom | 消息来源白名单 — private:、group:<群号>、或 *(允许所有) |
| accessToken | HTTP API 用 Bearer token,WebSocket 用 query 参数 |
| sharedDir | 宿主机共享目录;默认 ~/napcat/shared,用于把语音/图片 stage 给 NapCat |
| containerSharedDir | 容器内共享目录;默认 /shared,与 sharedDir 对应 |
| groupAutoReact | 是否对入站群消息自动添加 reaction,默认 false |
| groupAutoReactEmojiId | 群聊自动 reaction 使用的 QQ emoji id,默认 1 |
Reaction 与流式回复
react
- 通过 NapCat set_msg_emoji_like 对群消息或指定群消息 message_id 添加表情
- QQ 私聊 reaction 目前不可靠,接口可能返回成功,但不会真正落到消息上
- 入站群消息还支持自动 reaction,受 groupAutoReact / groupAutoReactEmojiId 控制,默认关闭
{
"agents": {
"defaults": {
"blockStreamingDefault": "on"
}
}
}
{
"channels": {
"onebot": {
"streaming": {
"block": {
"coalesce": {
"minChars": 80,
"idleMs": 600
}
}
}
}
}
}
旧版 channels.onebot.blockStreamingCoalesce 仍兼容;新版 openclaw doctor --fix 会把它迁移到 channels.onebot.streaming.block.coalesce。
验证
msg=
- 再执行:npm run build
npm run react-test -- --message-id --emoji 76
- 当前建议只把这项验证用于群聊消息;私聊 reaction 在 QQ/NapCat 上通常不生效
agents.defaults.blockStreamingDefault = "on"
- 然后在 QQ 里发一条明确要求“分段回复”的消息
- 成功时,QQ 会连续收到多条消息,日志里会出现 deliver(block),最后再有 deliver(final)语音支持(可选)
支持 QQ 语音消息的完整自动处理链路:
sendRecord 发送 QQ 语音依赖:
ffmpeg — 音频格式转换uv — 运行 pilk 解码 SILK 格式(AMR 仅需 ffmpeg)不需要语音功能时可以跳过这些依赖。
消息目标格式
private: — 私聊消息group:<群号> — 群聊消息 — 自动识别为私聊开发
npm install
npm test # 120 tests
npm run build # 编译 TypeScript
npm run coverage # 覆盖率报告
npm run sync:openclaw-cli # 审查后重新同步 OpenClaw CLI 的 shared-dir 参数
English
Source code is available on GitHub.
An OpenClaw native channel plugin that connects to NapCat, go-cqhttp, or any OneBot 11 compatible QQ bot framework.
Note:
openclaw-onebotopenclaw-onebot-pluginid: openclaw-onebotid: onebotopenclaw-onebot in plugins.allow / plugins.entries; install records are managed by openclaw plugins installchannels.onebot unchanged2026.4.26 / plugin-sdk 2026.4.26 and declares setupEntry plus channelConfigs manifest metadataFeatures
set_msg_emoji_like; QQ private-chat reactions are currently unreliable/status, /help, /commands, /model, /new, /reset, etc.)allowFrom filtering (private/group/user-level)allowFrom is explicitly configurednpm run coverageQuick Start
#### 1. Install
# Recommended: install the published ClawHub payload
openclaw plugins install clawhub:openclaw-onebot-pluginAuto install; does not patch the local OpenClaw CLI dist by default
bash scripts/install.shOr prepare a local payload after reviewing the source
npm install && npm run prepare:clawhub:plugin
openclaw plugins install .clawhub-plugin/openclaw-onebot-plugin
scripts/install.sh prepares .clawhub-plugin/openclaw-onebot-plugin in the source repo first and prefers openclaw plugins install so current OpenClaw builds update the managed plugin install index. Older OpenClaw builds fall back to the legacy manual copy path. It no longer patches OpenClaw CLI dist by default; set ONEBOT_SYNC_OPENCLAW_CLI=1 only after reviewing scripts/sync-openclaw-cli.mjs and confirming your OpenClaw build lacks the shared-dir setup flags.
#### 2. Configure
Add to openclaw.json:
{
"plugins": {
"allow": ["openclaw-onebot"],
"entries": {
"openclaw-onebot": {
"enabled": true
}
}
},
"channels": {
"onebot": {
"enabled": true,
"wsUrl": "ws://your-host:3001",
"httpUrl": "http://your-host:3001",
"accessToken": "your_token",
"sharedDir": "/Users/you/napcat/shared",
"containerSharedDir": "/shared",
"allowFrom": ["private:12345"],
"groupAutoReact": false,
"groupAutoReactEmojiId": 1
}
}
}
Notes:
openclaw-onebot for plugin config keyschannels.onebotallowFrom to trusted QQ private users or groups. Without it, normal messages can still be routed, but OpenClaw text commands such as /status and /model are not authorizedaccessToken and keep OneBot HTTP/WebSocket endpoints on localhost or a trusted networksharedDir; do not point it at unrelated private filesplugins.installs by hand; current OpenClaw stores install records in a managed plugin index, so use openclaw plugins install Or via environment variables:
ONEBOT_WS_URL=ws://your-host:3001
ONEBOT_HTTP_URL=http://your-host:3001
ONEBOT_ACCESS_TOKEN=your_token # optional
OneBot setup also supports:
--token wsUrl,httpUrl[,accessToken[,sharedDir[,containerSharedDir]]]openclaw channels add --channel onebot --shared-dir --container-shared-dir /shared npm run sync:openclaw-cli from the plugin directory#### 3. Restart Gateway
openclaw gateway restart
Advanced Configuration
{
"channels": {
"onebot": {
"enabled": true,
"wsUrl": "ws://your-host:3001",
"httpUrl": "http://your-host:3001",
"accessToken": "your_token",
"sharedDir": "/Users/you/napcat/shared",
"containerSharedDir": "/shared",
"allowFrom": ["private:12345", "group:67890"],
"groupAutoReact": false,
"groupAutoReactEmojiId": 1
}
}
}
| Option | Description |
|--------|-------------|
| allowFrom | Whitelist — private:, group:, or * (allow all) |
| accessToken | Bearer token for HTTP, query param for WebSocket |
| sharedDir | Host-side shared directory; defaults to ~/napcat/shared for staging outbound media |
| containerSharedDir | Container-side mount path; defaults to /shared and should map to sharedDir |
| groupAutoReact | Whether to auto-react to inbound group messages; defaults to false |
| groupAutoReactEmojiId | QQ emoji id used for automatic group reactions; defaults to 1 |
Reactions and Streaming Replies
react channel action
- It maps to NapCat set_msg_emoji_like
- Group-message reactions are supported
- QQ private-chat reactions are currently unreliable: the API may return success while no visible reaction is persisted
- Inbound group messages can also be auto-reacted, controlled by groupAutoReact / groupAutoReactEmojiId, disabled by default
{
"agents": {
"defaults": {
"blockStreamingDefault": "on"
}
}
}
{
"channels": {
"onebot": {
"streaming": {
"block": {
"coalesce": {
"minChars": 80,
"idleMs": 600
}
}
}
}
}
}
Legacy channels.onebot.blockStreamingCoalesce remains accepted; current openclaw doctor --fix migrates it to channels.onebot.streaming.block.coalesce.
Verification
msg= from the gateway log
- Then run:npm run build
npm run react-test -- --message-id --emoji 76
- For now, treat this as a group-chat verification flow; private-chat reactions are not a reliable capability
agents.defaults.blockStreamingDefault = "on" in OpenClaw config
- Send a QQ prompt that explicitly asks for chunked or stepwise output
- Success looks like multiple QQ messages plus deliver(block) entries in the gateway log, followed by deliver(final)Voice Support (Optional)
End-to-end voice flow:
sendRecord → QQ voiceDependencies:
ffmpeguv (for SILK decoding via pilk; AMR only needs ffmpeg)Skip these if you only need text and image delivery.
Target Format
private: — Private messagegroup: — Group message — Auto-detected as privateDevelopment
npm install
npm test # Run 120 tests
npm run build # Compile TypeScript
npm run coverage # Coverage report
npm run sync:openclaw-cli # Re-apply shared-dir CLI wiring after review
License
MIT
💡 Examples
#### 1. Install
# Recommended: install the published ClawHub payload
openclaw plugins install clawhub:openclaw-onebot-pluginAuto install; does not patch the local OpenClaw CLI dist by default
bash scripts/install.shOr prepare a local payload after reviewing the source
npm install && npm run prepare:clawhub:plugin
openclaw plugins install .clawhub-plugin/openclaw-onebot-plugin
scripts/install.sh prepares .clawhub-plugin/openclaw-onebot-plugin in the source repo first and prefers openclaw plugins install so current OpenClaw builds update the managed plugin install index. Older OpenClaw builds fall back to the legacy manual copy path. It no longer patches OpenClaw CLI dist by default; set ONEBOT_SYNC_OPENCLAW_CLI=1 only after reviewing scripts/sync-openclaw-cli.mjs and confirming your OpenClaw build lacks the shared-dir setup flags.
#### 2. Configure
Add to openclaw.json:
{
"plugins": {
"allow": ["openclaw-onebot"],
"entries": {
"openclaw-onebot": {
"enabled": true
}
}
},
"channels": {
"onebot": {
"enabled": true,
"wsUrl": "ws://your-host:3001",
"httpUrl": "http://your-host:3001",
"accessToken": "your_token",
"sharedDir": "/Users/you/napcat/shared",
"containerSharedDir": "/shared",
"allowFrom": ["private:12345"],
"groupAutoReact": false,
"groupAutoReactEmojiId": 1
}
}
}
Notes:
openclaw-onebot for plugin config keyschannels.onebotallowFrom to trusted QQ private users or groups. Without it, normal messages can still be routed, but OpenClaw text commands such as /status and /model are not authorizedaccessToken and keep OneBot HTTP/WebSocket endpoints on localhost or a trusted networksharedDir; do not point it at unrelated private filesplugins.installs by hand; current OpenClaw stores install records in a managed plugin index, so use openclaw plugins install Or via environment variables:
ONEBOT_WS_URL=ws://your-host:3001
ONEBOT_HTTP_URL=http://your-host:3001
ONEBOT_ACCESS_TOKEN=your_token # optional
OneBot setup also supports:
--token wsUrl,httpUrl[,accessToken[,sharedDir[,containerSharedDir]]]openclaw channels add --channel onebot --shared-dir --container-shared-dir /shared npm run sync:openclaw-cli from the plugin directory#### 3. Restart Gateway
openclaw gateway restart
Advanced Configuration
{
"channels": {
"onebot": {
"enabled": true,
"wsUrl": "ws://your-host:3001",
"httpUrl": "http://your-host:3001",
"accessToken": "your_token",
"sharedDir": "/Users/you/napcat/shared",
"containerSharedDir": "/shared",
"allowFrom": ["private:12345", "group:67890"],
"groupAutoReact": false,
"groupAutoReactEmojiId": 1
}
}
}
| Option | Description |
|--------|-------------|
| allowFrom | Whitelist — private:, group:, or * (allow all) |
| accessToken | Bearer token for HTTP, query param for WebSocket |
| sharedDir | Host-side shared directory; defaults to ~/napcat/shared for staging outbound media |
| containerSharedDir | Container-side mount path; defaults to /shared and should map to sharedDir |
| groupAutoReact | Whether to auto-react to inbound group messages; defaults to false |
| groupAutoReactEmojiId | QQ emoji id used for automatic group reactions; defaults to 1 |
Reactions and Streaming Replies
react channel action
- It maps to NapCat set_msg_emoji_like
- Group-message reactions are supported
- QQ private-chat reactions are currently unreliable: the API may return success while no visible reaction is persisted
- Inbound group messages can also be auto-reacted, controlled by groupAutoReact / groupAutoReactEmojiId, disabled by default
{
"agents": {
"defaults": {
"blockStreamingDefault": "on"
}
}
}
{
"channels": {
"onebot": {
"streaming": {
"block": {
"coalesce": {
"minChars": 80,
"idleMs": 600
}
}
}
}
}
}
Legacy channels.onebot.blockStreamingCoalesce remains accepted; current openclaw doctor --fix migrates it to channels.onebot.streaming.block.coalesce.
Verification
msg= from the gateway log
- Then run:npm run build
npm run react-test -- --message-id --emoji 76
- For now, treat this as a group-chat verification flow; private-chat reactions are not a reliable capability
agents.defaults.blockStreamingDefault = "on" in OpenClaw config
- Send a QQ prompt that explicitly asks for chunked or stepwise output
- Success looks like multiple QQ messages plus deliver(block) entries in the gateway log, followed by deliver(final)Voice Support (Optional)
End-to-end voice flow:
sendRecord → QQ voiceDependencies:
ffmpeguv (for SILK decoding via pilk; AMR only needs ffmpeg)Skip these if you only need text and image delivery.
Target Format
private: — Private messagegroup: — Group message — Auto-detected as privateDevelopment
npm install
npm test # Run 120 tests
npm run build # Compile TypeScript
npm run coverage # Coverage report
npm run sync:openclaw-cli # Re-apply shared-dir CLI wiring after review