Skip to content

Commit 5dc8a2b

Browse files
author
王允
committed
修复cli 定时任务创建时失败的问题
1 parent c57522c commit 5dc8a2b

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

openclaw.plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "openclaw-github-trending",
33
"name": "GitHub Trending",
4-
"version": "1.4.6",
4+
"version": "1.4.7",
55
"description": "Fetch GitHub trending repositories and push to Feishu or Email with AI summaries",
66
"author": "王允",
77
"license": "MIT",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openclaw-github-trending",
3-
"version": "1.4.6",
3+
"version": "1.4.7",
44
"description": "OpenClaw plugin for fetching GitHub trending repositories and pushing to Feishu or Email with AI summaries",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,13 @@ Cron 表达式格式:
313313
});
314314
const channelLabel = channelLabels.join('+');
315315
const jobName = `GitHub 热榜 ${periodLabel} ${channelLabel}`;
316-
317-
// 修复:使用自然语言格式而不是 JSON 格式,这样 Agent 可以正确理解和调用工具
318-
const channelsParam = channelList.join(',');
319-
const systemEventText = `请获取 GitHub ${sinceLower === 'daily' ? '今日' : sinceLower === 'weekly' ? '本周' : '本月'} 热榜项目,使用 openclaw-github-trending 工具,参数 since=${sinceLower}, channels=[${channelsParam}],推送到${channelList.map(c => c === 'feishu' ? '飞书' : '邮箱').join('和')}`;
316+
317+
// 修复:使用简洁的自然语言,避免特殊字符和过长文本
318+
const sinceText = sinceLower === 'daily' ? '今日' : sinceLower === 'weekly' ? '本周' : '本月';
319+
const channelText = channelLabels.join(',');
320+
321+
// 简洁格式:使用 openclaw-github-trending 工具,获取本月热榜,推送到飞书,邮箱
322+
const systemEventText = `使用 openclaw-github-trending 工具,获取${sinceText}热榜,推送到${channelText}`;
320323

321324
// 修复:使用 spawn 而不是 exec,避免缓冲区限制,支持低内存服务器
322325
const cp = await import('child_process');
@@ -334,7 +337,7 @@ Cron 表达式格式:
334337
'--system-event', systemEventText
335338
], {
336339
stdio: ['ignore', 'pipe', 'pipe'],
337-
timeout: 30000 // 30 秒超时
340+
timeout: 120000 // 120 秒超时
338341
});
339342

340343
let stdout = '';
@@ -390,11 +393,8 @@ Cron 表达式格式:
390393
// 备用方案:直接调用 Gateway API
391394
const execFile = cp.execFile;
392395

393-
// 简化命令,减少参数长度
394-
const simpleEvent = `GitHub 热榜 ${sinceLower} ${channelList.join(',')}`;
395-
396396
const result = await new Promise<string>((resolve, reject) => {
397-
execFile('openclaw', ['cron', 'add', '--name', jobName, '--cron', schedule!, '--system-event', simpleEvent], {
397+
execFile('openclaw', ['cron', 'add', '--name', jobName, '--cron', schedule!, '--system-event', systemEventText], {
398398
timeout: 15000 as any,
399399
maxBuffer: 5 * 1024 * 1024 as any
400400
}, (error: any, stdout: string, stderr: string) => {

0 commit comments

Comments
 (0)