backup codes
This commit is contained in:
@@ -406,12 +406,13 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
|
|||||||
}
|
}
|
||||||
if (aiResult.action === 'purchase') {
|
if (aiResult.action === 'purchase') {
|
||||||
// 引用最近图片:用户要求把之前的图片关联到某采购
|
// 引用最近图片:用户要求把之前的图片关联到某采购
|
||||||
|
let usedRecentImage = false;
|
||||||
if (aiResult.use_recent_image) {
|
if (aiResult.use_recent_image) {
|
||||||
const recentMsg = db.prepare("SELECT attachments FROM messages WHERE room_id = ? AND attachments IS NOT NULL AND attachments != '' ORDER BY timestamp DESC LIMIT 1").get(roomId);
|
const recentMsg = db.prepare("SELECT attachments FROM messages WHERE room_id = ? AND attachments IS NOT NULL AND attachments != '' ORDER BY timestamp DESC LIMIT 1").get(roomId);
|
||||||
if (recentMsg) {
|
if (recentMsg) {
|
||||||
try {
|
try {
|
||||||
const files = JSON.parse(recentMsg.attachments);
|
const files = JSON.parse(recentMsg.attachments);
|
||||||
if (files.length) attachments = files;
|
if (files.length) { attachments = files; usedRecentImage = true; }
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +479,12 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) {
|
|||||||
if (attachments?.length) {
|
if (attachments?.length) {
|
||||||
const insertAttach = db.prepare('INSERT INTO purchase_attachments (purchase_id, file_path, uploaded_by, timestamp) VALUES (?,?,?,?)');
|
const insertAttach = db.prepare('INSERT INTO purchase_attachments (purchase_id, file_path, uploaded_by, timestamp) VALUES (?,?,?,?)');
|
||||||
attachments.forEach(fp => insertAttach.run(purchase.id, fp, username, now));
|
attachments.forEach(fp => insertAttach.run(purchase.id, fp, username, now));
|
||||||
|
if (usedRecentImage) {
|
||||||
|
replyText = `📎 已为「${aiResult.purchase_item}」关联 ${attachments.length} 个附件`;
|
||||||
|
db.prepare('INSERT INTO purchase_history (purchase_id, action, user, timestamp) VALUES (?,?,?,?)').run(purchase.id, `添加附件:${attachments.length} 个`, username, now);
|
||||||
|
}
|
||||||
|
} else if (usedRecentImage) {
|
||||||
|
replyText = `❌ 未找到最近的图片消息,请先发送图片再试。`;
|
||||||
}
|
}
|
||||||
storeAndBroadcastText(roomId, '小财', replyText);
|
storeAndBroadcastText(roomId, '小财', replyText);
|
||||||
addToHistory(roomId, 'assistant', replyText);
|
addToHistory(roomId, 'assistant', replyText);
|
||||||
|
|||||||
Reference in New Issue
Block a user