fix: 修复和优化群聊文件读取逻辑

This commit is contained in:
ikechan8370 2023-12-11 00:46:38 +08:00
parent d254163fa7
commit e61d4ff3fa
3 changed files with 17 additions and 6 deletions

View file

@ -1674,8 +1674,8 @@ export class chatgpt extends plugin {
seq = e.source.message_id
}
let msgs = e.isGroup ? await e.group.getChatHistory(seq, 1) : await e.friend.getChatHistory(seq, 1)
let sourceMsg = msgs[0]
let fileMsgElem = sourceMsg.message.find(msg => msg.type === 'file')
let sourceMsg = msgs[msgs.length - 1]
let fileMsgElem = sourceMsg.file || sourceMsg.message.find(msg => msg.type === 'file')
if (fileMsgElem) {
toSummaryFileContent = await extractContentFromFile(fileMsgElem, e)
}