(filePath: string)
| 91 | * @returns 聊天列表,如果格式不支持多聊天则抛出错误 |
| 92 | */ |
| 93 | export async function scanMultiChatFile(filePath: string): Promise<MultiChatInfo[]> { |
| 94 | const feature = sniffer.sniff(filePath) |
| 95 | if (!feature) { |
| 96 | throw new Error(`无法识别文件格式: ${filePath}`) |
| 97 | } |
| 98 | |
| 99 | if (!feature.multiChat) { |
| 100 | throw new Error(`格式 "${feature.name}" 不是多聊天格式`) |
| 101 | } |
| 102 | |
| 103 | const module = formats.find((m) => m.feature.id === feature.id) |
| 104 | if (!module?.scanChats) { |
| 105 | throw new Error(`格式 "${feature.name}" 声明了 multiChat 但未实现 scanChats`) |
| 106 | } |
| 107 | |
| 108 | return module.scanChats(filePath) |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * 检查文件是否需要预处理 |
no test coverage detected