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

Method handleInstall

openlist/openlist.ts:162–272  ·  view source on GitHub ↗
(msg: Api.Message, dirArg?: string)

Source from the content-addressed store, hash-verified

160 if (!(await this.isSavedMessages(msg))) {
161 await msg.edit({ text: "⚠️ 此命令仅限在「收藏夹」中使用" });
162 return;
163 }
164 await this.handleLogin(msg, args[2], args[3]);
165 break;
166 case "setdefault":
167 await this.handleSetDefault(msg, args[2]);
168 break;
169 default:
170 await msg.edit({ text: helpText, parseMode: "html" });
171 }
172 }
173
174 private async handleInstall(msg: Api.Message, dirArg?: string) {
175 try {
176 if (process.platform !== "linux") {
177 await msg.edit({ text: "仅支持 Linux(systemd)环境" });
178 return;
179 }
180
181 const hasSystemd = await this.hasCmd("systemctl");
182 const hasCurl = await this.hasCmd("curl");
183 const hasTar = await this.hasCmd("tar");
184 if (!hasSystemd || !hasCurl || !hasTar) {
185 const missing = [
186 !hasSystemd ? "systemctl" : "",
187 !hasCurl ? "curl" : "",
188 !hasTar ? "tar" : "",
189 ]
190 .filter(Boolean)
191 .join(", ");
192 await msg.edit({ text: `缺少依赖:${missing}` });
193 return;
194 }
195
196 const arch = this.mapArch(process.arch);
197 if (!arch) {
198 await msg.edit({ text: `暂不支持当前架构:${process.arch}` });
199 return;
200 }
201
202 const sanitized = this.sanitizeInstallPath(dirArg);
203 if (!sanitized.ok) {
204 await msg.edit({ text: `⚠️ ${sanitized.reason}`, parseMode: "html" });
205 return;
206 }
207 const installPath = sanitized.path;
208
209 if (await this.fileExists(`${installPath}/openlist`)) {
210 await msg.edit({ text: `检测到已安装于:${codeTag(installPath)}\n请使用:${codeTag(`${commandName} update`)}`, parseMode: "html" });
211 return;
212 }
213
214 await msg.edit({ text: `开始安装到:${codeTag(installPath)}`, parseMode: "html" });
215 await execAsync(`mkdir -p "${installPath}"`);
216
217 const tarPath = "/tmp/openlist.tar.gz";
218 const url = `${GH_BASE_DOWNLOAD}/openlist-linux-musl-${arch}.tar.gz`;
219 await execAsync(

Callers 1

handleCommandMethod · 0.95

Calls 8

hasCmdMethod · 0.95
mapArchMethod · 0.95
normalizeInstallPathMethod · 0.95
fileExistsMethod · 0.95
codeTagFunction · 0.70
htmlEscapeFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected