Skip to content

Milky ​

Milky(QQ 的一个本地协议实现)适配器。支持正向 WS、反向 WS、HTTP 三种连接,发送走本地 HTTP API(需 Milky 开启 EnabledHttp)。

适配器类型:"milky" 源码:src/adapter/milky/ 协议:Milky(QQ 的一个本地协议实现,通常跑在 127.0.0.1 某个端口)。

说明 ​

特点 ​

  • 支持三种连接方式:正向 WS、反向 WS、HTTP(webhook)
  • 发送走 Milky 本地 HTTP API(POST /api/{action})
  • userId/groupId 为 QQ 号

原理 ​

  • 接收:Milky 通过 WS 或 HTTP 上报 QQ 消息事件
  • 发送:POST http://127.0.0.1:{port}/api/{action},需 Milky 开启 EnabledHttp

前提 ​

  • 已部署 Milky 并登录 QQ 号
  • Milky 已开启 EnabledHttp(发送必需)
  • Milky 已配置对应连接方式

安装 ​

适配器安装 ​

bash
van adapter install milky

依赖库 ​

bash
npm install ws

配置 ​

方式一:正向 WS(本框架连 Milky 事件 WS)——默认 ​

jsonc
{
  "botId": "Milky-Bot",
  "type": "milky",
  "mode": "ws",
  "host": "127.0.0.1",
  "port": 3000,
  "path": "/event",
  "token": ""
}

方式二:反向 WS(本框架起 WS 服务) ​

jsonc
{
  "botId": "Milky-Bot",
  "type": "milky",
  "mode": "ws_reverse",
  "port": 3000,
  "path": "/event",
  "token": ""
}

方式三:HTTP(webhook) ​

jsonc
{
  "botId": "Milky-Bot",
  "type": "milky",
  "mode": "http",
  "port": 3001,
  "path": "/event",
  "token": ""
}

配置说明 ​

配置项必填说明
mode可选连接方式:ws(默认)/ ws_reverse / http
hostwsMilky 服务地址,默认 127.0.0.1
port✅端口(ws 模式为 Milky 端口,ws_reverse/http 为本框架监听端口)
path可选事件路径,默认 /event
token可选鉴权 token

接收事件 ​

Milky 事件框架事件
群消息group_message
私聊private_message
通知类notice

userId/groupId 为 QQ 号。

API 调用 ​

适配器把 OneBot 风格的 action 转发为 Milky 的 HTTP 接口:

ts
// 发群消息
await bot.callApi("send_group_msg", { group_id: 123456789, message: "你好" })
// → POST /api/send_group { params: { gid: 123456789, message } }

// 发私聊
await bot.callApi("send_private_msg", { user_id: 123456, message: "你好" })
// → POST /api/send_private { params: { uid: 123456, message } }

// 自动判断
await bot.callApi("send_msg", { group_id: 123456789, message: "你好" })

message 支持字符串或消息段数组(text/image 等)。

常见问题 ​

  • 发送失败:确认 Milky 已开启 EnabledHttp,三种模式下发送都走 HTTP API。
  • 收不到消息:确认 Milky 已配置对应连接方式并开启事件上报。

相关项目 ​

Just run の Bot · 一套插件,全平台机器人