mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-05-03 19:51:17 +08:00
feat: 各个解析器重新支持回复消息导入
This commit is contained in:
@@ -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++
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
|
||||
@@ -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++
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -451,6 +451,7 @@ async function* parseEchotrace(options: ParseOptions): AsyncGenerator<ParseEvent
|
||||
}
|
||||
|
||||
return {
|
||||
platformMessageId: String(msg.localId), // 消息的平台原始 ID(用于回复关联查询)
|
||||
senderPlatformId: platformId,
|
||||
senderAccountName: accountName,
|
||||
// echotrace 格式没有单独的群昵称字段,使用 null 而非 undefined(SQLite 兼容)
|
||||
@@ -458,6 +459,7 @@ async function* parseEchotrace(options: ParseOptions): AsyncGenerator<ParseEvent
|
||||
timestamp: msg.createTime,
|
||||
type,
|
||||
content,
|
||||
// 注意:echotrace 导出格式不包含被引用消息的 ID,所以 replyToMessageId 为空
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user