fix issues

This commit is contained in:
2026-07-22 18:03:15 +08:00
parent 17385335fd
commit b7eabb1b11
2 changed files with 12 additions and 1 deletions

View File

@@ -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;