Merge branch 'main' into pr-289

This commit is contained in:
Re-bin 2026-02-07 17:54:33 +00:00
commit d258f5beba
2 changed files with 12 additions and 6 deletions

View File

@ -20,6 +20,7 @@ const VERSION = '0.1.0';
export interface InboundMessage { export interface InboundMessage {
id: string; id: string;
sender: string; sender: string;
pn: string;
content: string; content: string;
timestamp: number; timestamp: number;
isGroup: boolean; isGroup: boolean;
@ -123,6 +124,7 @@ export class WhatsAppClient {
this.options.onMessage({ this.options.onMessage({
id: msg.key.id || '', id: msg.key.id || '',
sender: msg.key.remoteJid || '', sender: msg.key.remoteJid || '',
pn: msg.key.remoteJidAlt || '',
content, content,
timestamp: msg.messageTimestamp as number, timestamp: msg.messageTimestamp as number,
isGroup, isGroup,

View File

@ -100,21 +100,25 @@ class WhatsAppChannel(BaseChannel):
if msg_type == "message": if msg_type == "message":
# Incoming message from WhatsApp # Incoming message from WhatsApp
# Deprecated by whatsapp: old phone number style typically: <phone>@s.whatspp.net
pn = data.get("pn", "")
# New LID sytle typically:
sender = data.get("sender", "") sender = data.get("sender", "")
content = data.get("content", "") content = data.get("content", "")
# sender is typically: <phone>@s.whatsapp.net # Extract just the phone number or lid as chat_id
# Extract just the phone number as chat_id user_id = pn if pn else sender
chat_id = sender.split("@")[0] if "@" in sender else sender sender_id = user_id.split("@")[0] if "@" in user_id else user_id
logger.info(f"Sender {sender}")
# Handle voice transcription if it's a voice message # Handle voice transcription if it's a voice message
if content == "[Voice Message]": if content == "[Voice Message]":
logger.info(f"Voice message received from {chat_id}, but direct download from bridge is not yet supported.") logger.info(f"Voice message received from {sender_id}, but direct download from bridge is not yet supported.")
content = "[Voice Message: Transcription not available for WhatsApp yet]" content = "[Voice Message: Transcription not available for WhatsApp yet]"
await self._handle_message( await self._handle_message(
sender_id=chat_id, sender_id=sender_id,
chat_id=sender, # Use full JID for replies chat_id=sender, # Use full LID for replies
content=content, content=content,
metadata={ metadata={
"message_id": data.get("id"), "message_id": data.get("id"),