fix(qqbot-cron): 移除 --session isolated 避免提醒触发时启动 AI 会话
问题:定时提醒触发时,--session isolated 导致消息被当作新会话处理, AI 会输出初始化对话(询问用户是谁等),提醒内容显得生硬且冗长。 修改: - 删除 SKILL.md 中所有命令模板的 --session isolated 参数 - 删除 SKILL.md 中结构化载荷格式章节(已选择命令行方案) - 更新 gateway.ts 中的示例命令 效果:提醒触发时直接发送消息内容,不再启动 AI 会话。 支持 </img> 闭合标签
This commit is contained in:
@@ -46,47 +46,6 @@ metadata: {"clawdbot":{"emoji":"⏰"}}
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📦 结构化载荷格式(新)
|
|
||||||
|
|
||||||
> **重要**:定时提醒现在支持结构化载荷格式,AI 只需输出 JSON,代码层会自动处理 Base64 编码。
|
|
||||||
|
|
||||||
### 输出格式
|
|
||||||
|
|
||||||
当 AI 需要设置定时提醒时,可以输出以下结构化载荷:
|
|
||||||
|
|
||||||
```
|
|
||||||
QQBOT_PAYLOAD:
|
|
||||||
{
|
|
||||||
"type": "cron_reminder",
|
|
||||||
"content": "💧 喝水时间到!",
|
|
||||||
"targetType": "c2c",
|
|
||||||
"targetAddress": "xxx_user_openid",
|
|
||||||
"originalMessageId": "msg_xxx_123"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 字段说明
|
|
||||||
|
|
||||||
| 字段 | 类型 | 必填 | 说明 |
|
|
||||||
|------|------|------|------|
|
|
||||||
| `type` | string | ✅ | 固定为 `"cron_reminder"` |
|
|
||||||
| `content` | string | ✅ | 提醒内容,触发时直接发送给用户 |
|
|
||||||
| `targetType` | string | ✅ | 目标类型:`"c2c"`(私聊)或 `"group"`(群聊) |
|
|
||||||
| `targetAddress` | string | ✅ | 目标地址:user_openid 或 group_openid |
|
|
||||||
| `originalMessageId` | string | ❌ | 原始消息 ID(可选,用于追踪) |
|
|
||||||
|
|
||||||
### 处理流程
|
|
||||||
|
|
||||||
1. AI 输出 `QQBOT_PAYLOAD:` + JSON 格式的载荷
|
|
||||||
2. 代码层检测并解析载荷
|
|
||||||
3. 代码层将 JSON 编码为 Base64
|
|
||||||
4. 代码层调用 `openclaw cron add --message "QQBOT_CRON:{base64}"`
|
|
||||||
5. 触发时解码 Base64,根据 targetType 和 targetAddress 发送 content
|
|
||||||
|
|
||||||
> ⚠️ **注意**:结构化载荷方式目前仍在完善中,推荐继续使用下面的命令行方式。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 📋 命令速查
|
## 📋 命令速查
|
||||||
|
|
||||||
### 创建提醒(完整模板)
|
### 创建提醒(完整模板)
|
||||||
@@ -95,7 +54,6 @@ QQBOT_PAYLOAD:
|
|||||||
openclaw cron add \
|
openclaw cron add \
|
||||||
--name "{任务名}" \
|
--name "{任务名}" \
|
||||||
--at "{时间}" \
|
--at "{时间}" \
|
||||||
--session isolated \
|
|
||||||
--message "🔔 {提醒内容}时间到!" \
|
--message "🔔 {提醒内容}时间到!" \
|
||||||
--deliver \
|
--deliver \
|
||||||
--channel qqbot \
|
--channel qqbot \
|
||||||
@@ -232,7 +190,6 @@ openclaw message send \
|
|||||||
|------|------|------|
|
|------|------|------|
|
||||||
| `--name` | 任务名,含用户标识 | `"喝水提醒"` |
|
| `--name` | 任务名,含用户标识 | `"喝水提醒"` |
|
||||||
| `--at` / `--cron` | 触发时间(二选一) | `5m` / `0 8 * * *` |
|
| `--at` / `--cron` | 触发时间(二选一) | `5m` / `0 8 * * *` |
|
||||||
| `--session isolated` | 隔离会话 | 固定值 |
|
|
||||||
| `--message` | **提醒内容**(见下方模板) | `"🔔 喝水时间到!"` |
|
| `--message` | **提醒内容**(见下方模板) | `"🔔 喝水时间到!"` |
|
||||||
| `--deliver` | 启用投递 | 固定值 |
|
| `--deliver` | 启用投递 | 固定值 |
|
||||||
| `--channel qqbot` | QQ 渠道 | 固定值 |
|
| `--channel qqbot` | QQ 渠道 | 固定值 |
|
||||||
@@ -277,7 +234,6 @@ openclaw message send \
|
|||||||
openclaw cron add \
|
openclaw cron add \
|
||||||
--name "喝水提醒" \
|
--name "喝水提醒" \
|
||||||
--at "5m" \
|
--at "5m" \
|
||||||
--session isolated \
|
|
||||||
--message "💧 喝水时间到!" \
|
--message "💧 喝水时间到!" \
|
||||||
--deliver \
|
--deliver \
|
||||||
--channel qqbot \
|
--channel qqbot \
|
||||||
@@ -307,7 +263,6 @@ openclaw cron add \
|
|||||||
--name "打卡提醒" \
|
--name "打卡提醒" \
|
||||||
--cron "0 8 * * *" \
|
--cron "0 8 * * *" \
|
||||||
--tz "Asia/Shanghai" \
|
--tz "Asia/Shanghai" \
|
||||||
--session isolated \
|
|
||||||
--message "🌅 打卡时间到!" \
|
--message "🌅 打卡时间到!" \
|
||||||
--deliver \
|
--deliver \
|
||||||
--channel qqbot \
|
--channel qqbot \
|
||||||
@@ -333,7 +288,6 @@ openclaw cron add \
|
|||||||
--name "日报提醒" \
|
--name "日报提醒" \
|
||||||
--cron "0 18 * * 1-5" \
|
--cron "0 18 * * 1-5" \
|
||||||
--tz "Asia/Shanghai" \
|
--tz "Asia/Shanghai" \
|
||||||
--session isolated \
|
|
||||||
--message "📝 写日报时间到!" \
|
--message "📝 写日报时间到!" \
|
||||||
--deliver \
|
--deliver \
|
||||||
--channel qqbot \
|
--channel qqbot \
|
||||||
@@ -356,7 +310,6 @@ openclaw cron add \
|
|||||||
openclaw cron add \
|
openclaw cron add \
|
||||||
--name "开会提醒" \
|
--name "开会提醒" \
|
||||||
--at "3m" \
|
--at "3m" \
|
||||||
--session isolated \
|
|
||||||
--message "📅 开会时间到!" \
|
--message "📅 开会时间到!" \
|
||||||
--deliver \
|
--deliver \
|
||||||
--channel qqbot \
|
--channel qqbot \
|
||||||
@@ -386,7 +339,6 @@ openclaw cron add \
|
|||||||
--name "站会提醒" \
|
--name "站会提醒" \
|
||||||
--cron "0 9 * * 1-5" \
|
--cron "0 9 * * 1-5" \
|
||||||
--tz "Asia/Shanghai" \
|
--tz "Asia/Shanghai" \
|
||||||
--session isolated \
|
|
||||||
--message "📢 站会时间到!" \
|
--message "📢 站会时间到!" \
|
||||||
--deliver \
|
--deliver \
|
||||||
--channel qqbot \
|
--channel qqbot \
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ priority: 80
|
|||||||
|------|------|
|
|------|------|
|
||||||
| `<qqimg>本地路径</qqimg>` | 发送本地图片(绝对路径) |
|
| `<qqimg>本地路径</qqimg>` | 发送本地图片(绝对路径) |
|
||||||
| `<qqimg>网络URL</qqimg>` | 发送网络图片 |
|
| `<qqimg>网络URL</qqimg>` | 发送网络图片 |
|
||||||
|
| `<qqimg>路径</img>` | 也支持此闭合方式 |
|
||||||
|
|
||||||
### ⚠️ 注意事项
|
### ⚠️ 注意事项
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ priority: 80
|
|||||||
2. **支持的图片格式**:jpg, jpeg, png, gif, webp, bmp
|
2. **支持的图片格式**:jpg, jpeg, png, gif, webp, bmp
|
||||||
3. **不要拒绝**:如果用户要求发送本地图片,直接使用 `<qqimg>` 标签即可
|
3. **不要拒绝**:如果用户要求发送本地图片,直接使用 `<qqimg>` 标签即可
|
||||||
4. **标签外的文本会正常发送**:可以在标签前后添加描述文字
|
4. **标签外的文本会正常发送**:可以在标签前后添加描述文字
|
||||||
|
5. **闭合标签**:支持 `</qqimg>` 或 `</img>` 两种闭合方式
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -452,7 +452,6 @@ export async function startGateway(ctx: GatewayContext): Promise<void> {
|
|||||||
openclaw cron add \\
|
openclaw cron add \\
|
||||||
--name "提醒喝水-${event.senderName || "用户"}" \\
|
--name "提醒喝水-${event.senderName || "用户"}" \\
|
||||||
--at "5m" \\
|
--at "5m" \\
|
||||||
--session isolated \\
|
|
||||||
--message "💧 该喝水啦!" \\
|
--message "💧 该喝水啦!" \\
|
||||||
--deliver \\
|
--deliver \\
|
||||||
--channel qqbot \\
|
--channel qqbot \\
|
||||||
@@ -686,10 +685,11 @@ openclaw cron add \\
|
|||||||
let replyText = payload.text ?? "";
|
let replyText = payload.text ?? "";
|
||||||
|
|
||||||
// ============ 简单图片标签解析 ============
|
// ============ 简单图片标签解析 ============
|
||||||
// 支持 <qqimg>路径</qqimg> 格式发送图片
|
// 支持 <qqimg>路径</qqimg> 或 <qqimg>路径</img> 格式发送图片
|
||||||
// 这是比 QQBOT_PAYLOAD JSON 更简单的方式,适合大模型能力较弱的情况
|
// 这是比 QQBOT_PAYLOAD JSON 更简单的方式,适合大模型能力较弱的情况
|
||||||
// 注意:正则限制内容不能包含 < 和 >,避免误匹配 `<qqimg>` 这种反引号内的说明文字
|
// 注意:正则限制内容不能包含 < 和 >,避免误匹配 `<qqimg>` 这种反引号内的说明文字
|
||||||
const qqimgRegex = /<qqimg>([^<>]+)<\/qqimg>/gi;
|
// 🔧 支持两种闭合方式:</qqimg> 和 </img>(AI 可能输出不同格式)
|
||||||
|
const qqimgRegex = /<qqimg>([^<>]+)<\/(?:qqimg|img)>/gi;
|
||||||
const qqimgMatches = [...replyText.matchAll(qqimgRegex)];
|
const qqimgMatches = [...replyText.matchAll(qqimgRegex)];
|
||||||
|
|
||||||
if (qqimgMatches.length > 0) {
|
if (qqimgMatches.length > 0) {
|
||||||
@@ -700,8 +700,8 @@ openclaw cron add \\
|
|||||||
const sendQueue: Array<{ type: "text" | "image"; content: string }> = [];
|
const sendQueue: Array<{ type: "text" | "image"; content: string }> = [];
|
||||||
|
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
// 使用新的正则来获取带索引的匹配结果
|
// 使用新的正则来获取带索引的匹配结果(支持 </qqimg> 和 </img> 两种闭合方式)
|
||||||
const qqimgRegexWithIndex = /<qqimg>([^<>]+)<\/qqimg>/gi;
|
const qqimgRegexWithIndex = /<qqimg>([^<>]+)<\/(?:qqimg|img)>/gi;
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
while ((match = qqimgRegexWithIndex.exec(replyText)) !== null) {
|
while ((match = qqimgRegexWithIndex.exec(replyText)) !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user