feat: 各个解析器重新支持回复消息导入

This commit is contained in:
digua
2026-01-09 00:13:16 +08:00
committed by digua
parent 32fd5139d4
commit d03177082d
5 changed files with 16 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ interface JsonlMember {
interface JsonlMessage {
_type: 'message'
sender: string
platformMessageId?: string
accountName: string
groupNickname?: string
timestamp: number
@@ -216,6 +217,7 @@ async function* parseChatLabJsonl(options: ParseOptions): AsyncGenerator<ParseEv
timestamp: parsed.timestamp,
type: parsed.type as MessageType,
content: parsed.content,
platformMessageId: parsed.platformMessageId,
replyToMessageId: parsed.replyToMessageId,
})
messagesProcessed++

View File

@@ -59,6 +59,7 @@ export const feature: FormatFeature = {
// ==================== 消息结构 ====================
interface ChatLabMessage {
platformMessageId?: string // 消息的平台原始 ID用于回复关联查询
sender: string // platformId
accountName: string // 发送时的账号名称
groupNickname?: string // 发送时的群昵称
@@ -205,6 +206,7 @@ async function* parseChatLab(options: ParseOptions): AsyncGenerator<ParseEvent,
timestamp: msg.timestamp,
type: msg.type,
content: msg.content,
platformMessageId: msg.platformMessageId,
replyToMessageId: msg.replyToMessageId,
})

View File

@@ -60,6 +60,7 @@ interface V4RawMessage {
}
interface V4Message {
messageId?: string // 消息的唯一 ID
timestamp: string
sender: {
uid?: string
@@ -73,6 +74,12 @@ interface V4Message {
text: string
resources?: Array<{ type: string }>
emojis?: Array<{ type: string }>
reply?: {
messageId?: string
referencedMessageId?: string // 被引用消息的 ID
senderName?: string
content?: string
}
}
rawMessage?: V4RawMessage
}
@@ -323,12 +330,14 @@ async function* parseV4(options: ParseOptions): AsyncGenerator<ParseEvent, void,
if (value.isRecalled) textContent = '[已撤回] ' + textContent
messageBatch.push({
platformMessageId: value.messageId, // 消息的平台原始 ID
senderPlatformId: platformId,
senderAccountName: accountName,
senderGroupNickname: groupNickname,
timestamp,
type,
content: textContent || null,
replyToMessageId: value.content?.reply?.referencedMessageId, // 被引用消息的 ID
})
messagesProcessed++

View File

@@ -381,6 +381,7 @@ async function* parseDiscordExporter(options: ParseOptions): AsyncGenerator<Pars
}
batchCollector.push({
platformMessageId: msg.id, // 消息的平台原始 ID
senderPlatformId: author.id,
senderAccountName: author.name,
senderGroupNickname: author.nickname || null,

View File

@@ -451,6 +451,7 @@ async function* parseEchotrace(options: ParseOptions): AsyncGenerator<ParseEvent
}
return {
platformMessageId: String(msg.localId), // 消息的平台原始 ID用于回复关联查询
senderPlatformId: platformId,
senderAccountName: accountName,
// echotrace 格式没有单独的群昵称字段,使用 null 而非 undefinedSQLite 兼容)
@@ -458,6 +459,7 @@ async function* parseEchotrace(options: ParseOptions): AsyncGenerator<ParseEvent
timestamp: msg.createTime,
type,
content,
// 注意echotrace 导出格式不包含被引用消息的 ID所以 replyToMessageId 为空
}
}