()
| 620 | return "❌ 无法获取当前工作目录。"; |
| 621 | } |
| 622 | |
| 623 | const programDir = pwdResult.output.trim(); |
| 624 | const configPath = `${programDir}/config.json`; |
| 625 | |
| 626 | // 检查配置文件是否存在 |
| 627 | const configCheck = await SystemExecutor.run(`test -f ${configPath}`); |
| 628 | if (!configCheck.success) { |
| 629 | return `❌ 找不到配置文件: ${htmlEscape(configPath)}`; |
| 630 | } |
| 631 | |
| 632 | // 读取配置文件 |
| 633 | const readResult = await SystemExecutor.run(`cat ${configPath}`); |
| 634 | if (!readResult.success) { |
| 635 | return "❌ 无法读取 config.json 文件。"; |
| 636 | } |
| 637 | |
| 638 | let config; |
| 639 | try { |
| 640 | config = JSON.parse(readResult.output); |
| 641 | } catch { |
| 642 | return "❌ config.json 文件格式错误。"; |
| 643 | } |
| 644 | |
| 645 | // 检查是否已配置代理 |
| 646 | if (!config.proxy) { |
| 647 | return "ℹ️ Telegram 代理未配置,无需关闭。"; |
| 648 | } |
| 649 | |
| 650 | // 移除代理配置 |
| 651 | delete config.proxy; |
| 652 | |
| 653 | // 写回配置文件 |
| 654 | const configJson = JSON.stringify(config, null, 2); |
| 655 | const writeCmd = `cat > ${configPath} << 'EOF'\n${configJson}\nEOF`; |
| 656 | const writeResult = await SystemExecutor.runSudo(writeCmd); |
| 657 | |
| 658 | if (!writeResult.success) { |
| 659 | return "❌ 无法写入配置文件。"; |
| 660 | } |
| 661 | |
| 662 | return `✅ Telegram 代理配置已关闭\n\n⚠️ <b>注意</b>: 需要重启 TeleBox 生效`; |
| 663 | } catch (e: any) { |
| 664 | return `❌ 关闭代理失败: ${htmlEscape(e?.message || e)}`; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | // 配置 Music 插件代理 |
| 669 | private async configureMusicProxy(): Promise<string> { |
| 670 | try { |
| 671 | // 检查 WireProxy 是否运行 |
| 672 | const svcCheck = await SystemExecutor.run("systemctl is-active wireproxy"); |
| 673 | if (!svcCheck.success || svcCheck.output !== "active") { |
| 674 | return `❌ WireProxy 未运行。请先使用 <code>${htmlEscape(mainPrefix)}warp w</code> 启动 WireProxy。`; |
| 675 | } |
| 676 |
no test coverage detected