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

Method handleImport

search/search.ts:366–380  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

364 }
365
366 private async handleImport(msg: Api.Message) {
367 const replied = await safeGetReplyMessage(msg);
368 if (!replied || !replied.document) throw new Error("❌ 请回复备份文件。");
369
370 const buffer = await this.client.downloadMedia(replied.media!);
371 if (!buffer) throw new Error("下载文件失败。");
372
373 const handles = buffer.toString().split("\n").map((h: string) => h.trim()).filter(Boolean);
374 if (handles.length === 0) throw new Error("备份文件无效。");
375
376 await msg.edit({ text: `⚙️ 正在导入 ${handles.length} 个源...` });
377 this.config.channelList = [];
378 this.config.defaultChannel = null;
379 await this.handleAdd(msg, handles.join("\\"));
380 }
381
382 private async handleAd(msg: Api.Message, args: string) {
383 const parts = args.split(/\s+/);

Callers 1

handleMethod · 0.95

Calls 3

handleAddMethod · 0.95
downloadMediaMethod · 0.45
editMethod · 0.45

Tested by

no test coverage detected