Initial commit: 七牛云上传飞书机器人

功能:
- 飞书交互卡片支持
- 七牛云文件上传
- 自动 CDN 刷新
- 多存储桶配置
- 跨平台部署(Linux/macOS/Windows)
- Docker 支持
This commit is contained in:
饭团
2026-03-05 14:22:26 +08:00
commit b00567762f
15 changed files with 2286 additions and 0 deletions

185
src/cards/config-card.js Normal file
View File

@@ -0,0 +1,185 @@
/**
* 配置交互卡片模板
*/
class ConfigCard {
static create(configData) {
const bucketsText = Object.entries(configData.buckets || {})
.map(([name, bucket]) => {
return `**🪣 [${name}]**\n` +
`• 存储桶:${bucket.bucket}\n` +
`• 区域:${bucket.region}\n` +
`• 域名:${bucket.domain}\n` +
`• AccessKey: ${bucket.accessKey}`;
})
.join('\n\n');
return {
"config": {
"wide_screen_mode": true
},
"header": {
"template": "grey",
"title": {
"content": "⚙️ 七牛云配置",
"tag": "plain_text"
}
},
"elements": [
{
"tag": "div",
"text": {
"content": bucketsText || '暂无配置,请先添加存储桶配置。',
"tag": "lark_md"
}
},
{
"tag": "hr"
},
{
"tag": "div",
"text": {
"content": "**💡 修改配置**\n\n使用命令`/config set <key> <value>`\n\n示例\n`/config set default.domain https://new-cdn.com`",
"tag": "lark_md"
}
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {
"content": "📤 上传文件",
"tag": "plain_text"
},
"type": "primary",
"value": {
"action": "upload_file",
"type": "upload"
}
},
{
"tag": "button",
"text": {
"content": "❓ 帮助",
"tag": "plain_text"
},
"type": "default",
"value": {
"action": "help",
"type": "help"
}
}
]
}
]
};
}
static createEditForm(bucketName) {
return {
"config": {
"wide_screen_mode": true
},
"header": {
"template": "blue",
"title": {
"content": `✏️ 编辑配置 - ${bucketName}`,
"tag": "plain_text"
}
},
"elements": [
{
"tag": "input",
"label": {
"content": "AccessKey",
"tag": "plain_text"
},
"placeholder": {
"content": "请输入七牛云 AccessKey",
"tag": "plain_text"
},
"name": "access_key"
},
{
"tag": "input",
"label": {
"content": "SecretKey",
"tag": "plain_text"
},
"placeholder": {
"content": "请输入七牛云 SecretKey",
"tag": "plain_text"
},
"name": "secret_key"
},
{
"tag": "input",
"label": {
"content": "存储桶名称",
"tag": "plain_text"
},
"placeholder": {
"content": "例如my-bucket",
"tag": "plain_text"
},
"name": "bucket_name"
},
{
"tag": "input",
"label": {
"content": "区域",
"tag": "plain_text"
},
"placeholder": {
"content": "z0/z1/z2/na0/as0",
"tag": "plain_text"
},
"name": "region"
},
{
"tag": "input",
"label": {
"content": "CDN 域名",
"tag": "plain_text"
},
"placeholder": {
"content": "https://cdn.example.com",
"tag": "plain_text"
},
"name": "domain"
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {
"content": "💾 保存",
"tag": "plain_text"
},
"type": "primary",
"value": {
"action": "save_config",
"bucket": bucketName
}
},
{
"tag": "button",
"text": {
"content": "❌ 取消",
"tag": "plain_text"
},
"type": "default",
"value": {
"action": "cancel"
}
}
]
}
]
};
}
}
module.exports = { ConfigCard };