mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-19 12:59:09 +08:00
feat: 平台类型修改
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
import * as fs from 'fs'
|
||||
import * as readline from 'readline'
|
||||
import * as path from 'path'
|
||||
import { ChatPlatform, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import { KNOWN_PLATFORMS, ChatType, MessageType, type ChatPlatform } from '../../../../src/types/chat'
|
||||
import type {
|
||||
FormatFeature,
|
||||
FormatModule,
|
||||
@@ -111,7 +111,7 @@ function parseLine(line: string): JsonlLine | null {
|
||||
export const feature: FormatFeature = {
|
||||
id: 'chatlab-jsonl',
|
||||
name: 'ChatLab JSONL',
|
||||
platform: ChatPlatform.UNKNOWN,
|
||||
platform: KNOWN_PLATFORMS.UNKNOWN,
|
||||
priority: 2, // 仅次于 ChatLab JSON
|
||||
extensions: ['.jsonl'],
|
||||
signatures: {
|
||||
@@ -163,7 +163,7 @@ async function* parseChatLabJsonl(options: ParseOptions): AsyncGenerator<ParseEv
|
||||
if (!headerParsed) {
|
||||
meta = {
|
||||
name: parsed.meta.name || extractNameFromFilePath(filePath),
|
||||
platform: (parsed.meta.platform as ChatPlatform) || ChatPlatform.UNKNOWN,
|
||||
platform: parsed.meta.platform || KNOWN_PLATFORMS.UNKNOWN,
|
||||
type: (parsed.meta.type as ChatType) || ChatType.GROUP,
|
||||
groupId: parsed.meta.groupId,
|
||||
groupAvatar: parsed.meta.groupAvatar,
|
||||
@@ -189,7 +189,7 @@ async function* parseChatLabJsonl(options: ParseOptions): AsyncGenerator<ParseEv
|
||||
if (!meta) {
|
||||
meta = {
|
||||
name: extractNameFromFilePath(filePath),
|
||||
platform: ChatPlatform.UNKNOWN,
|
||||
platform: KNOWN_PLATFORMS.UNKNOWN,
|
||||
type: ChatType.GROUP,
|
||||
}
|
||||
yield { type: 'meta', data: meta }
|
||||
@@ -234,7 +234,7 @@ async function* parseChatLabJsonl(options: ParseOptions): AsyncGenerator<ParseEv
|
||||
if (!meta) {
|
||||
meta = {
|
||||
name: extractNameFromFilePath(filePath),
|
||||
platform: ChatPlatform.UNKNOWN,
|
||||
platform: KNOWN_PLATFORMS.UNKNOWN,
|
||||
type: ChatType.GROUP,
|
||||
}
|
||||
yield { type: 'meta', data: meta }
|
||||
|
||||
@@ -13,7 +13,7 @@ import { parser } from 'stream-json'
|
||||
import { pick } from 'stream-json/filters/Pick'
|
||||
import { streamValues } from 'stream-json/streamers/StreamValues'
|
||||
import { chain } from 'stream-chain'
|
||||
import { ChatPlatform, ChatType } from '../../../../src/types/chat'
|
||||
import { KNOWN_PLATFORMS, ChatType } from '../../../../src/types/chat'
|
||||
import type {
|
||||
FormatFeature,
|
||||
FormatModule,
|
||||
@@ -45,7 +45,7 @@ function extractNameFromFilePath(filePath: string): string {
|
||||
export const feature: FormatFeature = {
|
||||
id: 'chatlab',
|
||||
name: 'ChatLab JSON',
|
||||
platform: ChatPlatform.UNKNOWN, // ChatLab 格式可能包含多平台数据
|
||||
platform: KNOWN_PLATFORMS.UNKNOWN, // ChatLab 格式可能包含多平台数据
|
||||
priority: 1, // 最高优先级
|
||||
extensions: ['.json'],
|
||||
signatures: {
|
||||
@@ -93,7 +93,7 @@ async function* parseChatLab(options: ParseOptions): AsyncGenerator<ParseEvent,
|
||||
// 解析 meta
|
||||
let meta: ParsedMeta = {
|
||||
name: '未知群聊',
|
||||
platform: ChatPlatform.UNKNOWN,
|
||||
platform: KNOWN_PLATFORMS.UNKNOWN,
|
||||
type: ChatType.GROUP,
|
||||
}
|
||||
try {
|
||||
@@ -124,7 +124,7 @@ async function* parseChatLab(options: ParseOptions): AsyncGenerator<ParseEvent,
|
||||
const metaObj = JSON.parse(metaJson)
|
||||
meta = {
|
||||
name: metaObj.name || '未知群聊',
|
||||
platform: (metaObj.platform as ChatPlatform) || ChatPlatform.UNKNOWN,
|
||||
platform: metaObj.platform || KNOWN_PLATFORMS.UNKNOWN,
|
||||
type: (metaObj.type as ChatType) || ChatType.GROUP,
|
||||
groupId: metaObj.groupId,
|
||||
groupAvatar: metaObj.groupAvatar,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as readline from 'readline'
|
||||
import { ChatPlatform, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import { KNOWN_PLATFORMS, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import type {
|
||||
FormatFeature,
|
||||
FormatModule,
|
||||
@@ -46,7 +46,7 @@ function extractNameFromFilePath(filePath: string): string {
|
||||
export const feature: FormatFeature = {
|
||||
id: 'qq-native-txt',
|
||||
name: 'QQ 官方导出 (TXT)',
|
||||
platform: ChatPlatform.QQ,
|
||||
platform: KNOWN_PLATFORMS.QQ,
|
||||
priority: 30,
|
||||
extensions: ['.txt'],
|
||||
signatures: {
|
||||
@@ -271,7 +271,7 @@ async function* parseTxt(options: ParseOptions): AsyncGenerator<ParseEvent, void
|
||||
// 发送 meta(如果群名仍是默认值,使用文件名作为后备)
|
||||
const meta: ParsedMeta = {
|
||||
name: groupName === '未知群聊' ? extractNameFromFilePath(filePath) : groupName,
|
||||
platform: ChatPlatform.QQ,
|
||||
platform: KNOWN_PLATFORMS.QQ,
|
||||
type: ChatType.GROUP,
|
||||
}
|
||||
yield { type: 'meta', data: meta }
|
||||
|
||||
@@ -23,7 +23,7 @@ import { parser } from 'stream-json'
|
||||
import { pick } from 'stream-json/filters/Pick'
|
||||
import { streamValues } from 'stream-json/streamers/StreamValues'
|
||||
import { chain } from 'stream-chain'
|
||||
import { ChatPlatform, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import { KNOWN_PLATFORMS, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import type {
|
||||
FormatFeature,
|
||||
FormatModule,
|
||||
@@ -41,7 +41,7 @@ import { getFileSize, createProgress, readFileHeadBytes, parseTimestamp, isValid
|
||||
export const feature: FormatFeature = {
|
||||
id: 'shuakami-qq-exporter-v4',
|
||||
name: 'shuakami/qq-chat-exporter V4',
|
||||
platform: ChatPlatform.QQ,
|
||||
platform: KNOWN_PLATFORMS.QQ,
|
||||
priority: 10,
|
||||
extensions: ['.json'],
|
||||
signatures: {
|
||||
@@ -259,7 +259,7 @@ async function* parseV4(options: ParseOptions): AsyncGenerator<ParseEvent, void,
|
||||
// 发送 meta(包含群头像)
|
||||
const meta: ParsedMeta = {
|
||||
name: chatInfo.name || extractNameFromFilePath(filePath),
|
||||
platform: ChatPlatform.QQ,
|
||||
platform: KNOWN_PLATFORMS.QQ,
|
||||
type: chatType,
|
||||
groupAvatar: chatInfo.avatar, // 从 chatInfo.avatar 提取群头像
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import * as path from 'path'
|
||||
import { parser } from 'stream-json'
|
||||
import { streamArray } from 'stream-json/streamers/StreamArray'
|
||||
import { chain } from 'stream-chain'
|
||||
import { ChatPlatform, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import { KNOWN_PLATFORMS, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import type {
|
||||
FormatFeature,
|
||||
FormatModule,
|
||||
@@ -47,7 +47,7 @@ function extractNameFromFilePath(filePath: string): string {
|
||||
export const feature: FormatFeature = {
|
||||
id: 'wechat-default',
|
||||
name: '微信数据库导出 (JSON)',
|
||||
platform: ChatPlatform.WECHAT,
|
||||
platform: KNOWN_PLATFORMS.WECHAT,
|
||||
priority: 20,
|
||||
extensions: ['.json'],
|
||||
signatures: {
|
||||
@@ -232,7 +232,7 @@ async function* parseWechatDefault(options: ParseOptions): AsyncGenerator<ParseE
|
||||
// 发送 meta
|
||||
const meta: ParsedMeta = {
|
||||
name: otherName,
|
||||
platform: ChatPlatform.WECHAT,
|
||||
platform: KNOWN_PLATFORMS.WECHAT,
|
||||
type: ChatType.PRIVATE,
|
||||
}
|
||||
yield { type: 'meta', data: meta }
|
||||
|
||||
@@ -19,7 +19,7 @@ import { parser } from 'stream-json'
|
||||
import { pick } from 'stream-json/filters/Pick'
|
||||
import { streamValues } from 'stream-json/streamers/StreamValues'
|
||||
import { chain } from 'stream-chain'
|
||||
import { ChatPlatform, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import { KNOWN_PLATFORMS, ChatType, MessageType } from '../../../../src/types/chat'
|
||||
import type {
|
||||
FormatFeature,
|
||||
FormatModule,
|
||||
@@ -48,7 +48,7 @@ function extractNameFromFilePath(filePath: string): string {
|
||||
export const feature: FormatFeature = {
|
||||
id: 'ycccccccy-echotrace',
|
||||
name: 'ycccccccy/echotrace 微信导出',
|
||||
platform: ChatPlatform.WECHAT,
|
||||
platform: KNOWN_PLATFORMS.WECHAT,
|
||||
priority: 15,
|
||||
extensions: ['.json'],
|
||||
signatures: {
|
||||
@@ -357,7 +357,7 @@ async function* parseEchotrace(options: ParseOptions): AsyncGenerator<ParseEvent
|
||||
// 发送 meta
|
||||
const meta: ParsedMeta = {
|
||||
name: chatName,
|
||||
platform: ChatPlatform.WECHAT,
|
||||
platform: KNOWN_PLATFORMS.WECHAT,
|
||||
type: chatType,
|
||||
groupId,
|
||||
groupAvatar,
|
||||
|
||||
Reference in New Issue
Block a user