initial: 七牛云上传 OpenClaw Skill
功能特性: - 支持 /upload, /u 命令上传文件到七牛云 - 支持 /qiniu-config 配置管理 - 支持飞书卡片交互 - 支持指定上传路径和存储桶 - 自动刷新 CDN 缓存 - 支持文件覆盖上传 包含组件: - OpenClaw 处理器 (openclaw-processor.js) - 独立监听器 (scripts/feishu-listener.js) - 核心上传脚本 (scripts/upload-to-qiniu.js) - 部署脚本 (deploy.sh) - 完整文档 部署方式: 1. 复制 skill 到 ~/.openclaw/workspace/skills/ 2. 配置 ~/.openclaw/credentials/qiniu-config.json 3. 重启 OpenClaw Gateway
This commit is contained in:
82
scripts/openclaw-bridge.js
Normal file
82
scripts/openclaw-bridge.js
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* OpenClaw 桥接脚本
|
||||
*
|
||||
* 功能:
|
||||
* 1. 从 OpenClaw 接收消息
|
||||
* 2. 调用上传脚本
|
||||
* 3. 回复结果
|
||||
*
|
||||
* 使用方式(由 OpenClaw 调用):
|
||||
* node scripts/openclaw-bridge.js <command> [args...]
|
||||
*/
|
||||
|
||||
const { exec } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
const UPLOAD_SCRIPT = path.join(__dirname, 'upload-to-qiniu.js');
|
||||
|
||||
// 从命令行获取参数
|
||||
const args = process.argv.slice(2);
|
||||
const command = args[0];
|
||||
|
||||
if (!command) {
|
||||
console.error('用法:node openclaw-bridge.js <command> [args...]');
|
||||
console.error('命令:upload, config, help');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 执行对应的命令
|
||||
switch (command) {
|
||||
case 'upload':
|
||||
executeUpload(args.slice(1));
|
||||
break;
|
||||
case 'config':
|
||||
executeConfig(args.slice(1));
|
||||
break;
|
||||
case 'help':
|
||||
executeHelp();
|
||||
break;
|
||||
default:
|
||||
console.error(`未知命令:${command}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function executeUpload(uploadArgs) {
|
||||
const cmd = `node ${UPLOAD_SCRIPT} upload ${uploadArgs.join(' ')}`;
|
||||
console.log(`执行:${cmd}`);
|
||||
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`上传失败:${error.message}`);
|
||||
console.error(stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(stdout);
|
||||
});
|
||||
}
|
||||
|
||||
function executeConfig(configArgs) {
|
||||
const cmd = `node ${UPLOAD_SCRIPT} config ${configArgs.join(' ')}`;
|
||||
console.log(`执行:${cmd}`);
|
||||
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`配置操作失败:${error.message}`);
|
||||
console.error(stderr);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(stdout);
|
||||
});
|
||||
}
|
||||
|
||||
function executeHelp() {
|
||||
const cmd = `node ${UPLOAD_SCRIPT} --help`;
|
||||
exec(cmd, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
// 忽略帮助命令的错误
|
||||
}
|
||||
console.log(stdout);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user