From bf5b79c62b8cd423eda1f593da6808c8bf7b7aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A5=AD=E5=9B=A2?= Date: Fri, 6 Mar 2026 08:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20=E6=B7=BB=E5=8A=A0=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=AE=A1=E7=90=86=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 功能: 1. 简化预设路径配置(原文件名 + ipa) 2. 添加/path 命令管理预设路径 - /path list - 查看预设路径 - /path add <名称> <路径> - 添加预设路径 - /path remove <名称> - 删除预设路径 配置示例: { "uploadPaths": { "原文件名": "", "ipa": "/ipa/gamehall_jinxianv2.ipa" } } 使用示例: /path add backup /backup/files/ /path list /path remove backup --- src/index.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/index.js b/src/index.js index a722152..0fccc14 100644 --- a/src/index.js +++ b/src/index.js @@ -94,6 +94,8 @@ async function handleMessage(event) { }); } else if (text.startsWith('/config') || text.startsWith('/qc ')) { await handleConfigCommandV2(messageData, messageContent, feishu, uploader); + } else if (text.startsWith('/path')) { + await handlePathCommandV2(messageData, messageContent, feishu); } else if (text.startsWith('/help') || text.startsWith('/qh')) { await handleHelpCommandV2(chatId, feishu); } else if (messageType === 'file' || messageContent.file_key) { @@ -399,6 +401,72 @@ async function handleConfigCommandV2(message, content, feishu, uploader) { } } +async function handlePathCommandV2(message, content, feishu) { + const chatId = message.chat_id; + const text = content.text || ''; + const args = text.replace(/^\/path\s*/i, '').trim().split(/\s+/); + const subCommand = args[0]; + + const configPath = path.join(process.cwd(), 'config', 'qiniu-config.json'); + + try { + const fullConfig = loadFullConfig(); + + if (subCommand === 'list' || !subCommand) { + // 列出所有预设路径 + const paths = fullConfig.uploadPaths || {}; + let pathText = '**预设路径列表:**\n\n'; + for (const [name, pathValue] of Object.entries(paths)) { + pathText += `• **${name}**: ${pathValue || '(原文件名)'}\n`; + } + await feishu.sendMessage(chatId, { + msg_type: 'text', + content: { text: pathText } + }); + } else if (subCommand === 'add') { + // 添加预设路径:/path add <名称> <路径> + if (args.length < 3) { + throw new Error('用法:/path add <名称> <路径>\n示例:/path add ipa /ipa/gamehall.ipa'); + } + const name = args[1]; + const pathValue = args[2]; + + fullConfig.uploadPaths = fullConfig.uploadPaths || {}; + fullConfig.uploadPaths[name] = pathValue; + + fs.writeFileSync(configPath, JSON.stringify(fullConfig, null, 2)); + await feishu.sendMessage(chatId, { + msg_type: 'text', + content: { text: `✅ 已添加预设路径:**${name}** → ${pathValue}` } + }); + } else if (subCommand === 'remove' || subCommand === 'del') { + // 删除预设路径:/path remove <名称> + if (args.length < 2) { + throw new Error('用法:/path remove <名称>'); + } + const name = args[1]; + + if (!fullConfig.uploadPaths || !fullConfig.uploadPaths[name]) { + throw new Error(`预设路径 "${name}" 不存在`); + } + + delete fullConfig.uploadPaths[name]; + fs.writeFileSync(configPath, JSON.stringify(fullConfig, null, 2)); + await feishu.sendMessage(chatId, { + msg_type: 'text', + content: { text: `✅ 已删除预设路径:**${name}**` } + }); + } else { + throw new Error(`未知命令:${subCommand}\n可用命令:list, add, remove`); + } + } catch (error) { + await feishu.sendMessage(chatId, { + msg_type: 'text', + content: { text: `❌ 路径管理失败:${error.message}` } + }); + } +} + async function handleHelpCommandV2(chatId, feishu) { await feishu.sendMessage(chatId, { msg_type: 'text', @@ -414,10 +482,19 @@ async function handleHelpCommandV2(chatId, feishu) { /config list - 查看配置 /config set - 修改配置 +📁 路径管理: + /path list - 查看预设路径 + /path add <名称> <路径> - 添加预设路径 + /path remove <名称> - 删除预设路径 + 💡 提示: - 支持多存储桶配置 - 支持预设路径 - 上传同名文件会自动覆盖 + +示例: + /path add backup /backup/ + /path remove backup ` } }); }