Store and display sender's WhatsApp name

Use pushName from baileys to get the sender's display name instead
of just the phone number. Falls back to phone number if no name.

Includes migration to add sender_name column to existing databases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-01-31 19:32:18 +02:00
parent cbe33f4ba6
commit 22bd3d7c58
3 changed files with 15 additions and 8 deletions

View File

@@ -95,8 +95,7 @@ async function processMessage(msg: NewMessage): Promise<void> {
// Build prompt with conversation history
const lines = missedMessages.map(m => {
const time = new Date(m.timestamp).toLocaleTimeString();
const sender = m.sender.split('@')[0];
return `[${time}] ${sender}: ${m.content}`;
return `[${time}] ${m.sender_name}: ${m.content}`;
});
const prompt = lines.join('\n');
@@ -213,7 +212,7 @@ async function connectWhatsApp(): Promise<void> {
if (!msg.message) continue;
const chatJid = msg.key.remoteJid;
if (!chatJid || chatJid === 'status@broadcast') continue;
storeMessage(msg, chatJid, msg.key.fromMe || false);
storeMessage(msg, chatJid, msg.key.fromMe || false, msg.pushName || undefined);
}
});
}