openclaw-onebot

小龙虾 openclaw 的 onebot 接入框架,可用于接入 QQ

143
Stars
30
Forks
TypeScript
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/LSTM-Kirigaya/openclaw-onebot

快速入门

使用 openclaw-onebot 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

openclaw-onebot

OpenClawOneBot v11 协议(QQ/Lagrange.Core、go-cqhttp 等)渠道插件。

npm version GitHub stars License: MIT Node.js TypeScript OpenClaw


安装

openclaw plugins install @kirigaya/openclaw-onebot
openclaw onebot setup

教程

让 QQ 接入 openclaw!让你的助手掌管千人大群

功能

  • ✅ 私聊:所有消息 AI 都会回复
  • ✅ 触发:支持 @触发 和基于关键字的触发
  • ✅ 自动获取上下文
  • ✅ 自定义新成员入群欢迎触发器
  • ✅ 自动合并转发长消息:超过阈值可渲染为图片发送或者合并发送
  • ✅ 支持文件,图像读取/发送
  • ✅ 支持黑白名单系统

安装 onebot 服务端

你需要安装 onebot 服务端,QQ 目前比较常用的是 onebot 服务端是 NapCat,可以查看 官网 了解安装方法

连接类型

类型说明
forward-websocket插件主动连接 OneBot(go-cqhttp、Lagrange.Core 正向 WS/WSS)
backward-websocket插件作为服务端,OneBot 连接过来

💡 提示:支持 ws://wss://(WebSocket Secure)协议,可填写完整 URL 如 wss://ws-napcatqq.example.com

环境变量

可替代配置文件,适用于 Lagrange 等:

变量说明
ONEBOT_WS_TYPEforward-websocket / backward-websocket
ONEBOT_WS_HOST主机地址
ONEBOT_WS_PORT端口
ONEBOT_WS_ACCESS_TOKEN访问令牌

使用

  1. 安装并配置
  2. 重启 Gateway:openclaw gateway restart
  3. 在 QQ 私聊或群聊中发消息(群聊需 @ 机器人,或配置关键字触发)

关键字触发回复

除了 @ 机器人外,还可以配置关键字检测,当群消息中包含指定关键字时自动触发回复(无需 @)。

{
  "channels": {
    "onebot": {
      "keywordTriggers": {
        "enabled": true,
        "keywords": ["AI", "助手", "帮我问"],
        "caseSensitive": false
      }
    }
  }
}
配置项说明
enabled是否启用关键字触发
keywords关键字列表,包含任一关键字即触发
caseSensitive是否区分大小写

长消息处理与 OG 图片渲染

当单次回复超过长消息阈值(默认 300 字)时,可选用三种模式(openclaw onebot setup 中配置):

模式说明
normal准流式分段发送:边生成边聚合,按时间窗口或长度阈值增量发送
og_image将 Markdown 转为 HTML 再生成图片发送(需安装 satorisharp
forward合并转发(发给自己后打包转发)

normal 模式默认会开启块流式接收,并在插件侧做短时间聚合,默认规则:

  • normalModeFlushIntervalMs: 1200
  • normalModeFlushChars: 160

也就是回复不会逐 token 刷屏,而是大约每 1.2 秒或累计到 160 字左右就发送一段。可在 openclaw.json 中手动调整:

{
  "channels": {
    "onebot": {
      "longMessageMode": "normal",
      "normalModeFlushIntervalMs": 1200,
      "normalModeFlushChars": 160
    }
  }
}

选择 生成图片发送(og_image) 时,会额外询问渲染主题

选项说明
default无额外样式,默认白底黑字
dust内置主题:暖色、旧纸质感
custom自定义:在 ogImageRenderThemePath 中填写 CSS 文件绝对路径

配置项(枚举 + 可选路径):

  • ogImageRenderTheme"default" | "dust" | "custom"
  • ogImageRenderThemePath:当为 custom 时必填,CSS 文件绝对路径

示例(openclaw.json):

{
  "channels": {
    "onebot": {
      "longMessageMode": "og_image",
      "longMessageThreshold": 300,
      "ogImageRenderTheme": "dust"
    }
  }
}

自定义主题示例:

{
  "channels": {
    "onebot": {
      "longMessageMode": "og_image",
      "ogImageRenderTheme": "custom",
      "ogImageRenderThemePath": "C:/path/to/your-theme.css"
    }
  }
}

主动发送消息

通过 openclaw message send CLI(无需 Agent 工具):

# 发送文本
openclaw message send --channel onebot --target user:123456789 --message "你好"

# 发送图片
openclaw message send --channel onebot --target group:987654321 --media "file:///path/to/image.png"

--target 格式:user:QQ号group:群号。回复场景由 deliver 自动投递,Agent 输出 text/mediaUrl 即会送达。

新成员入群欢迎(自定义图片)

当有新成员加入群时,可根据其 ID 信息生成欢迎图片并发送。详见 receive.md

  1. openclaw.json 中配置:
{
  "channels": {
    "onebot": {
      "groupIncrease": {
        "enabled": true,
        "command": "npx tsx src/openclaw/trigger/welcome.ts",
        "cwd": "C:/path/to/Tiphareth"
      }
    }
  }
}
  1. commandcwd 下用系统 shell 执行,环境变量传入 GROUP_IDGROUP_NAMEUSER_IDUSER_NAMEAVATAR_URL。命令可调用 openclaw message send 自行发送,或向 stdout 输出 JSON 行供 handler 发送。

  2. 测试:npm run test:group-increase-handler(DRY_RUN 模式,仅生成图片)

回复白名单

默认为空回复所有人的消息。如果设置的话,那么机器人就只会回复设置的数组里的用户的消息。

{
  "channels": {
    "onebot": {
      "whitelistUserIds": [1193466151]
    }
  }
}

黑名单

在群里有时候有些人需要被屏蔽,不管他怎么 @ 还是怎么,都屏蔽他的消息不触发。

{
  "channels": {
    "onebot": {
      "blacklistUserIds": [123456789]
    }
  }
}

注意:白名单优先级高于黑名单。如果同时设置了白名单和黑名单,只有白名单内的用户才能触发,且黑名单内的白名单用户也会被屏蔽。

新人入群触发器

如果有人入群之后,可以通过这个来实现触发器。

{
  "channels": {
    "onebot": {
      "groupIncrease": {
        "enabled": true,
        "command": "npx tsx welcome.ts",
        "cwd": "/path/to/triggers"
      }
    }
  }
}

实现的脚本必须支持这三个参数:

--userId ${userId} --username ${username} --groupId ${groupId}

测试

测试连接

项目内提供测试脚本(需 .env 或环境变量):

cd openclaw-onebot
npm run test:connect

测试 OG 图片渲染效果

用于预览「Markdown 转图片」在不同主题下的渲染效果(需安装 satorisharp):

cd openclaw-onebot
# 无额外样式
npm run test:render-og-image -- default
# 内置 dust 主题
npm run test:render-og-image -- dust
# 自定义 CSS 文件(绝对路径)
npm run test:render-og-image -- "C:/path/to/your-theme.css"

生成图片保存在 test/output-render-<主题>.png,可直接打开查看。

参考

联系

zhelonghuang@qq.com

要是我不回你,可以选择进我的QQ群。782833642

License

MIT © LSTM-Kirigaya

常见问题

What is openclaw-onebot?

openclaw-onebot is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by LSTM-Kirigaya. 小龙虾 openclaw 的 onebot 接入框架,可用于接入 QQ. It has 143 GitHub stars.

Is openclaw-onebot safe to use?

openclaw-onebot returned warnings in SkillsLLM's automated security scan. It has no critical vulnerabilities, but review the flagged issues in the Security Report section before adding it to your workflow.

How do I install openclaw-onebot?

Clone the repository with "git clone https://github.com/LSTM-Kirigaya/openclaw-onebot" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is openclaw-onebot written in?

openclaw-onebot is primarily written in TypeScript. It is open-source under LSTM-Kirigaya on GitHub, so you can review or fork the full source.

Are there alternatives to openclaw-onebot?

Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh openclaw-onebot against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情