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

Method handleSetPort

openlist/openlist.ts:517–543  ·  view source on GitHub ↗
(msg: Api.Message, port?: string)

Source from the content-addressed store, hash-verified

515 await db.update((data) => {
516 data.defaultPath = "";
517 });
518 await msg.edit({ text: "✅ 默认上传路径已清空,将恢复为宿主机 /root/Openlist 路径。" });
519 return;
520 }
521 await db.update((data) => {
522 data.defaultPath = path;
523 });
524 await msg.edit({ text: `✅ 默认上传路径已设置为: ${codeTag(path)}\n\n现在使用 ${codeTag(`${commandName} save`)} 时若不指定路径,将默认上传到此位置。`, parseMode: "html" });
525 }
526
527 private async updateStoredCredentials(user?: string, pass?: string) {
528 const db = await this.getDb();
529 await db.update((data) => {
530 if (user) data.username = user;
531 if (pass) data.password = pass;
532 });
533 }
534
535 private async getDb() {
536 const dbPath = path.join(createDirectoryInAssets("openlist"), "credentials.json");
537 return await JSONFilePreset(dbPath, { username: "", password: "", defaultPath: "" });
538 }
539
540 private async handleSetPort(msg: Api.Message, port?: string) {
541 try {
542 if (!port || !/^\d+$/.test(port)) {
543 await msg.edit({ text: `用法: ${commandName} setport [端口号]` });
544 return;
545 }
546

Callers 1

handleCommandMethod · 0.95

Calls 3

detectInstalledPathMethod · 0.95
fileExistsMethod · 0.95
editMethod · 0.45

Tested by

no test coverage detected