mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 处理了已删除的聊天记录、修复了聊天记录重复的问题(仅在icqq测试通过) (#767)
This commit is contained in:
parent
ac52cd7dbe
commit
f1558cf107
1 changed files with 8 additions and 14 deletions
|
|
@ -10,19 +10,14 @@ export async function getChatHistoryGroup (e, num) {
|
|||
let latestChat = latestChats[0]
|
||||
if (latestChat) {
|
||||
let seq = latestChat.seq || latestChat.message_id
|
||||
let chats = []
|
||||
while (chats.length < num) {
|
||||
let chatHistory = await e.group.getChatHistory(seq, 20)
|
||||
if (!chatHistory || chatHistory.length === 0) {
|
||||
break
|
||||
}
|
||||
chats.push(...chatHistory.reverse())
|
||||
if (seq === chatHistory[chatHistory.length - 1].seq || seq === chatHistory[chatHistory.length - 1].message_id) {
|
||||
break
|
||||
}
|
||||
seq = chatHistory[chatHistory.length - 1].seq || chatHistory[chatHistory.length - 1].message_id
|
||||
}
|
||||
chats = chats.slice(0, num).reverse()
|
||||
let chats = [e]
|
||||
while(chats.length < num){
|
||||
let chatHistory = await e.group.getChatHistory(seq, 20)
|
||||
if(seq === (chatHistory[0].seq || chatHistory[0].message_id)) break
|
||||
seq = chatHistory[0].seq || chatHistory[0].message_id
|
||||
chats.unshift(...chatHistory.filter(chat => chat.sender?.user_id).slice(0, -1))
|
||||
}
|
||||
chats = chats.slice(chats.length - num)
|
||||
try {
|
||||
let mm = await e.bot.gml
|
||||
for (const chat of chats) {
|
||||
|
|
@ -45,7 +40,6 @@ export async function getChatHistoryGroup (e, num) {
|
|||
} catch (err) {
|
||||
logger.warn(err)
|
||||
}
|
||||
// console.log(chats)
|
||||
return chats
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue