(msg: Api.Message)
| 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+/); |
no test coverage detected