fix: 修复上下文聊天大于20时记录顺序错误的问题

This commit is contained in:
ikechan8370 2025-02-14 00:14:23 +08:00
parent 2ad77d8112
commit 88360ecc42
3 changed files with 9 additions and 8 deletions

View file

@ -16,13 +16,13 @@ export async function getChatHistoryGroup (e, num) {
if (!chatHistory || chatHistory.length === 0) {
break
}
chats.push(...chatHistory)
if (seq === chatHistory[0].seq || seq === chatHistory[0].message_id) {
chats.push(...chatHistory.reverse())
if (seq === chatHistory[chatHistory.length - 1].seq || seq === chatHistory[chatHistory.length - 1].message_id) {
break
}
seq = chatHistory[0].seq || chatHistory[0].message_id
seq = chatHistory[chatHistory.length - 1].seq || chatHistory[chatHistory.length - 1].message_id
}
chats = chats.slice(0, num)
chats = chats.slice(0, num).reverse()
try {
let mm = await e.bot.gml
for (const chat of chats) {