fix issues
This commit is contained in:
@@ -125,6 +125,17 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
|
||||
} catch(e) { console.error('❌ 解析附件失败:', e); }
|
||||
}
|
||||
}
|
||||
// 安全网:消息提到图片/附件但没带附件 → AI 忘设 use_recent_image,自动补
|
||||
if (!usedRecentImage && !attachments?.length && /(图片|附件|加到|存入|关联|作为附件)/.test(originalText)) {
|
||||
console.log('🔍 安全网: 文本提及附件但无附件,自动尝试 use_recent_image');
|
||||
const recentMsg = db.prepare("SELECT attachments FROM messages WHERE room_id = ? AND attachments IS NOT NULL AND attachments != '' AND attachments != '[]' ORDER BY id DESC LIMIT 1").get(roomId);
|
||||
if (recentMsg) {
|
||||
try {
|
||||
const files = JSON.parse(recentMsg.attachments);
|
||||
if (files.length) { attachments = files; usedRecentImage = true; console.log('✅ 安全网引用图片:', files.length, '个'); }
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
|
||||
const createdTime = normalizeTime(aiResult.created_time);
|
||||
let isNew = aiResult.is_new === true;
|
||||
|
||||
Reference in New Issue
Block a user