@kirigaya/openclaw-onebot 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/channel.d.ts +100 -0
- package/dist/channel.js +173 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +62 -0
- package/dist/connection.d.ts +94 -0
- package/dist/connection.js +426 -0
- package/dist/debug-log.d.ts +7 -0
- package/dist/debug-log.js +24 -0
- package/dist/gateway-proxy.d.ts +8 -0
- package/dist/gateway-proxy.js +36 -0
- package/dist/handlers/group-increase.d.ts +21 -0
- package/dist/handlers/group-increase.js +95 -0
- package/dist/handlers/process-inbound.d.ts +11 -0
- package/dist/handlers/process-inbound.js +224 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +33 -0
- package/dist/load-script.d.ts +5 -0
- package/dist/load-script.js +22 -0
- package/dist/message.d.ts +6 -0
- package/dist/message.js +24 -0
- package/dist/reply-context.d.ts +12 -0
- package/dist/reply-context.js +33 -0
- package/dist/scheduler.d.ts +19 -0
- package/dist/scheduler.js +70 -0
- package/dist/sdk.d.ts +9 -0
- package/dist/sdk.js +36 -0
- package/dist/send.d.ts +23 -0
- package/dist/send.js +98 -0
- package/dist/service.d.ts +4 -0
- package/dist/service.js +71 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +65 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.js +188 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +4 -0
- package/openclaw.plugin.json +72 -0
- package/package.json +74 -0
- package/skills/onebot-ops/SKILL.md +61 -0
- package/skills/onebot-ops/config.md +55 -0
- package/skills/onebot-ops/receive.md +85 -0
- package/skills/onebot-ops/send.md +39 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# 消息接收规则
|
|
2
|
+
|
|
3
|
+
## 私聊与群聊
|
|
4
|
+
|
|
5
|
+
- **私聊 (private)**:所有消息 AI 都会回复
|
|
6
|
+
- **群聊 (group)**:默认仅当用户 @ 机器人时 AI 才回复
|
|
7
|
+
|
|
8
|
+
## 回复投递(deliver)
|
|
9
|
+
|
|
10
|
+
Agent 的回复通过 deliver 自动发送,支持:
|
|
11
|
+
- **text**:纯文本消息
|
|
12
|
+
- **mediaUrl**:图片(`file://`、`http://`、`base64://`)
|
|
13
|
+
- 无需 Agent 工具,Agent 输出即会送达
|
|
14
|
+
|
|
15
|
+
## 使用 message 工具发送时
|
|
16
|
+
|
|
17
|
+
若 Agent 调用 `message` 工具(action: send)发送消息或图片:
|
|
18
|
+
- **target 必须使用 `ctx.To` 或 `ctx.ConversationLabel`**,二者在 OneBot 中均表示回复目标
|
|
19
|
+
- **群聊**:target 为 `group:群号`(如 `group:1046693162`),**切勿使用 SenderId**(那是用户 QQ 号,会发到私聊)
|
|
20
|
+
- **私聊**:target 为 `user:用户号` 或用户号
|
|
21
|
+
|
|
22
|
+
## 表情回应(仿飞书,Lagrange/QQ NT)
|
|
23
|
+
|
|
24
|
+
用户发消息后,会**立即**在用户的消息上添加表情回应(如点赞),让用户知道已收到。AI 回复完成后再取消该表情。使用 `set_msg_emoji_like` API,需 Lagrange.Core 等支持。可通过 `thinkingEmojiId` 配置,详见 [config.md](config.md)。
|
|
25
|
+
|
|
26
|
+
## @ 逻辑
|
|
27
|
+
|
|
28
|
+
可通过 `requireMention: false` 改为群聊全部回复,详见 [config.md](config.md)。
|
|
29
|
+
|
|
30
|
+
## 新成员入群欢迎
|
|
31
|
+
|
|
32
|
+
在 `openclaw.json` 中配置:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"channels": {
|
|
37
|
+
"onebot": {
|
|
38
|
+
"groupIncrease": {
|
|
39
|
+
"enabled": true,
|
|
40
|
+
"message": "欢迎 {name} 加入 {groupName}!"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 占位符(message 模板)
|
|
48
|
+
|
|
49
|
+
| 占位符 | 说明 |
|
|
50
|
+
|--------|------|
|
|
51
|
+
| `{name}` | 新成员昵称(群名片或 QQ 昵称) |
|
|
52
|
+
| `{userId}` | 新成员 QQ 号 |
|
|
53
|
+
| `{groupName}` | 群名 |
|
|
54
|
+
| `{groupId}` | 群号 |
|
|
55
|
+
| `{avatarUrl}` | 新成员头像链接 |
|
|
56
|
+
|
|
57
|
+
### 自定义 handler 脚本
|
|
58
|
+
|
|
59
|
+
需要生成图片、调用外部 API 时,可配置 `handler` 路径(.mjs 或 .ts/.mts):
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"channels": {
|
|
64
|
+
"onebot": {
|
|
65
|
+
"groupIncrease": {
|
|
66
|
+
"enabled": true,
|
|
67
|
+
"handler": "./welcome.mjs"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
脚本接收上下文 `ctx`,返回 `{ text?, imagePath?, imageUrl? }`:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
// welcome.mjs 或 welcome.ts
|
|
78
|
+
export default async function (ctx) {
|
|
79
|
+
// ctx: { groupId, groupName, userId, userName, avatarUrl }
|
|
80
|
+
// 可用 ctx.avatarUrl 获取头像,生成图片后写入文件
|
|
81
|
+
const path = "./welcome-out.png";
|
|
82
|
+
// ... 你的图片生成逻辑 ...
|
|
83
|
+
return { text: `欢迎 ${ctx.userName}!`, imagePath: path };
|
|
84
|
+
}
|
|
85
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# 发送消息(openclaw message send)
|
|
2
|
+
|
|
3
|
+
通过 OpenClaw 的 `openclaw message send` CLI 主动发送消息,由 Channel outbound 处理,无需 Agent 工具。
|
|
4
|
+
|
|
5
|
+
## 前置条件
|
|
6
|
+
|
|
7
|
+
- Gateway 已启动:`openclaw gateway`
|
|
8
|
+
- OneBot 渠道已配置并连接
|
|
9
|
+
|
|
10
|
+
## target 格式
|
|
11
|
+
|
|
12
|
+
| 格式 | 说明 |
|
|
13
|
+
|------|------|
|
|
14
|
+
| `user:123456789` | 私聊该 QQ 号 |
|
|
15
|
+
| `group:987654321` | 群聊该群号 |
|
|
16
|
+
| `123456789` | 纯数字且 > 100000000 时按用户处理,否则按群处理 |
|
|
17
|
+
| `onebot:group:xxx` / `qq:user:xxx` | 支持 onebot/qq/lagrange 前缀 |
|
|
18
|
+
|
|
19
|
+
## 发送文本
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
openclaw message send --channel onebot --target user:1193466151 --message "你好"
|
|
23
|
+
openclaw message send --channel onebot --target group:123456789 --message "群公告内容"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 发送图片(mediaUrl)
|
|
27
|
+
|
|
28
|
+
`--media` 支持 `file://` 路径、`http://` URL 或 `base64://`:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
openclaw message send --channel onebot --target user:1193466151 --media "file:///tmp/screenshot.png"
|
|
32
|
+
openclaw message send --channel onebot --target group:123456789 --media "https://example.com/pic.jpg" --message "附带说明"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 说明
|
|
36
|
+
|
|
37
|
+
- **回复场景**(用户发消息 → Agent 回复):由 deliver 自动处理,Agent 输出 text/mediaUrl 即会送达
|
|
38
|
+
- **主动发送**(CLI 或工作流):使用上述 `openclaw message send` 命令
|
|
39
|
+
- 无 Agent 工具挂载,减少 token 消耗,提升扩展性
|