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:
99
scripts/verify-url.js
Executable file
99
scripts/verify-url.js
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* 飞书事件订阅 URL 验证处理器
|
||||
*
|
||||
* 用途:处理飞书开放平台的事件订阅 URL 验证请求
|
||||
* 使用方式:node verify-url.js
|
||||
*/
|
||||
|
||||
const http = require('http');
|
||||
const crypto = require('crypto');
|
||||
|
||||
// 配置
|
||||
const CONFIG = {
|
||||
port: 3000,
|
||||
verifyToken: process.env.FEISHU_VERIFY_TOKEN || 'qiniu_upload_token_2026',
|
||||
encryptKey: process.env.FEISHU_ENCRYPT_KEY || ''
|
||||
};
|
||||
|
||||
console.log('🍙 飞书 URL 验证服务');
|
||||
console.log('验证 Token:', CONFIG.verifyToken);
|
||||
console.log('加密密钥:', CONFIG.encryptKey ? '已配置' : '未配置');
|
||||
console.log('监听端口:', CONFIG.port);
|
||||
console.log('');
|
||||
console.log('📋 配置步骤:');
|
||||
console.log('1. 在飞书开放平台设置请求地址:http://你的 IP:3000');
|
||||
console.log('2. 设置验证 Token:', CONFIG.verifyToken);
|
||||
console.log('3. 点击保存,等待验证');
|
||||
console.log('');
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const url = new URL(req.url, `http://${req.headers.host}`);
|
||||
|
||||
console.log(`[${new Date().toISOString()}] ${req.method} ${url.pathname}`);
|
||||
|
||||
// 处理飞书验证请求
|
||||
if (url.pathname === '/' && req.method === 'POST') {
|
||||
let body = '';
|
||||
|
||||
req.on('data', chunk => {
|
||||
body += chunk;
|
||||
});
|
||||
|
||||
req.on('end', () => {
|
||||
try {
|
||||
const event = JSON.parse(body);
|
||||
|
||||
// 验证类型:url_verification
|
||||
if (event.type === 'url_verification') {
|
||||
console.log('✅ 收到验证请求');
|
||||
console.log('Challenge:', event.challenge);
|
||||
|
||||
// 返回 challenge
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ challenge: event.challenge }));
|
||||
|
||||
console.log('✅ 验证成功!请在飞书开放平台确认状态');
|
||||
return;
|
||||
}
|
||||
|
||||
// 其他事件类型
|
||||
console.log('事件类型:', event.type);
|
||||
console.log('事件内容:', JSON.stringify(event, null, 2));
|
||||
|
||||
res.writeHead(200);
|
||||
res.end('OK');
|
||||
|
||||
} catch (e) {
|
||||
console.error('❌ 解析失败:', e.message);
|
||||
res.writeHead(400);
|
||||
res.end('Invalid JSON');
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 健康检查
|
||||
if (url.pathname === '/health') {
|
||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||
res.end(JSON.stringify({ status: 'ok', timestamp: Date.now() }));
|
||||
return;
|
||||
}
|
||||
|
||||
// 其他请求
|
||||
res.writeHead(404);
|
||||
res.end('Not Found');
|
||||
});
|
||||
|
||||
server.listen(CONFIG.port, () => {
|
||||
console.log('');
|
||||
console.log('🚀 服务已启动');
|
||||
console.log(`📍 监听地址:http://0.0.0.0:${CONFIG.port}`);
|
||||
console.log('');
|
||||
console.log('💡 提示:');
|
||||
console.log(' - 按 Ctrl+C 停止服务');
|
||||
console.log(' - 访问 http://localhost:3000/health 检查服务状态');
|
||||
console.log('');
|
||||
});
|
||||
Reference in New Issue
Block a user