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:
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user