()
| 750 | return "❌ 无法获取当前工作目录。"; |
| 751 | } |
| 752 | |
| 753 | const programDir = pwdResult.output.trim(); |
| 754 | const configPath = `${programDir}/assets/music/music_config.json`; |
| 755 | |
| 756 | // 检查配置文件是否存在 |
| 757 | const configCheck = await SystemExecutor.run(`test -f ${configPath}`); |
| 758 | if (!configCheck.success) { |
| 759 | return "ℹ️ Music 插件配置文件不存在,无需关闭代理。"; |
| 760 | } |
| 761 | |
| 762 | // 读取配置文件 |
| 763 | const readResult = await SystemExecutor.run(`cat ${configPath}`); |
| 764 | if (!readResult.success) { |
| 765 | return "❌ 无法读取 Music 配置文件。"; |
| 766 | } |
| 767 | |
| 768 | let config; |
| 769 | try { |
| 770 | config = JSON.parse(readResult.output); |
| 771 | } catch { |
| 772 | return "❌ Music 配置文件格式错误。"; |
| 773 | } |
| 774 | |
| 775 | // 检查是否已配置代理 |
| 776 | if (!config["music_ytdlp_proxy"]) { |
| 777 | return "ℹ️ Music 插件代理未配置,无需关闭。"; |
| 778 | } |
| 779 | |
| 780 | // 移除代理配置 |
| 781 | delete config["music_ytdlp_proxy"]; |
| 782 | |
| 783 | // 写回配置文件 |
| 784 | const configJson = JSON.stringify(config, null, 2); |
| 785 | const writeCmd = `cat > ${configPath} << 'EOF'\n${configJson}\nEOF`; |
| 786 | const writeResult = await SystemExecutor.run(writeCmd); |
| 787 | |
| 788 | if (!writeResult.success) { |
| 789 | return "❌ 无法更新 Music 配置文件。"; |
| 790 | } |
| 791 | |
| 792 | return `✅ Music 插件代理配置已关闭\n\n💡 <b>提示</b>: Music 插件现在将直接访问 YouTube`; |
| 793 | } catch (e: any) { |
| 794 | return `❌ 关闭 Music 代理失败: ${htmlEscape(e?.message || e)}`; |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | // 主处理 |
| 799 | private async handleWarp(msg: Api.Message): Promise<void> { |
| 800 | // 标准参数解析模式(参考规范) |
| 801 | const lines = msg.text?.trim()?.split(/\r?\n/g) || []; |
| 802 | const parts = lines?.[0]?.split(/\s+/) || []; |
| 803 | const [, ...args] = parts; // 跳过命令本身 |
| 804 | const sub = (args[0] || "").toLowerCase(); |
| 805 | |
| 806 | try { |
no test coverage detected