MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / handleWarp

Method handleWarp

warp/warp.ts:806–995  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

804 const sub = (args[0] || "").toLowerCase();
805
806 try {
807 // 无参数时显示帮助
808 if (!sub) {
809 await msg.edit({ text: helpText, parseMode: "html" });
810 return;
811 }
812
813 // 处理 help 在前的情况:${mainPrefix}help warp [subcommand]
814 if (sub === "help" || sub === "h") {
815 if (args[1]) {
816 // 显示特定子命令的帮助
817 const subCmd = args[1].toLowerCase();
818 await this.showSubCommandHelp(subCmd, msg);
819 } else {
820 // 显示总帮助
821 await msg.edit({ text: helpText, parseMode: "html" });
822 }
823 return;
824 }
825
826 // 处理 help 在后的情况:.warp [subcommand] help
827 if (args[1] && (args[1].toLowerCase() === "help" || args[1].toLowerCase() === "h")) {
828 await this.showSubCommandHelp(sub, msg);
829 return;
830 }
831
832 switch (sub) {
833 case "help":
834 case "h":
835 await msg.edit({ text: helpText, parseMode: "html" });
836 return;
837
838 case "status": {
839 await msg.edit({ text: "🔄 正在获取状态...", parseMode: "html" });
840 const statusText = await WireproxyManager.getStatus();
841 await msg.edit({ text: statusText, parseMode: "html" });
842 return;
843 }
844
845 case "w": {
846 await msg.edit({ text: "🔄 正在检查环境...", parseMode: "html" });
847 try {
848 const { stdout } = await execAsync("systemctl is-active dnsmasq 2>/dev/null || echo 'inactive'");
849 if (stdout.trim() === 'active') {
850 await msg.edit({ text: "❌ Iptables/dnsmasq 方案似乎正在运行。请先禁用它,然后再启动 WireProxy。", parseMode: "html" });
851 return;
852 }
853 } catch {}
854
855 const port = args[1] ? parseInt(args[1], 10) : undefined;
856 await msg.edit({ text: "🔄 正在启动 wireproxy...", parseMode: "html" });
857 const ret = await WireproxyManager.setupAndStart(port);
858 await msg.edit({ text: ret, parseMode: "html" });
859 return;
860 }
861
862 case "stop": {
863 await msg.edit({ text: "🔄 正在停止 wireproxy...", parseMode: "html" });

Callers 1

WarpPluginClass · 0.95

Calls 14

showSubCommandHelpMethod · 0.95
configureProxyMethod · 0.95
removeProxyMethod · 0.95
configureMusicProxyMethod · 0.95
removeMusicProxyMethod · 0.95
getStatusMethod · 0.80
setupAndStartMethod · 0.80
stopMethod · 0.80
restartMethod · 0.80
setPortMethod · 0.80
uninstallMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected