whatsapp-pi 1.0.42 → 1.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -82,7 +82,7 @@ export class WhatsAppService {
|
|
|
82
82
|
private restoreBaileysConsoleFilter?: () => void;
|
|
83
83
|
private reconnectTimeout?: ReturnType<typeof setTimeout>;
|
|
84
84
|
private onQRCode?: (qr: string) => void;
|
|
85
|
-
private onMessage?: (m:
|
|
85
|
+
private onMessage?: (m: MessagesUpsertEvent) => void;
|
|
86
86
|
private onStatusUpdate?: (status: string) => void;
|
|
87
87
|
private lastRemoteJid: string | null = null;
|
|
88
88
|
|
|
@@ -465,7 +465,7 @@ export class WhatsAppService {
|
|
|
465
465
|
this.onQRCode = callback;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
setMessageCallback(callback: (m:
|
|
468
|
+
setMessageCallback(callback: (m: MessagesUpsertEvent) => void) {
|
|
469
469
|
this.onMessage = callback;
|
|
470
470
|
}
|
|
471
471
|
|
package/whatsapp-pi.ts
CHANGED
|
@@ -165,8 +165,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
165
165
|
|
|
166
166
|
// Handle incoming messages by injecting them as user prompts
|
|
167
167
|
whatsappService.setMessageCallback(async (m) => {
|
|
168
|
-
const msg = m.messages[0];
|
|
169
|
-
if (!msg
|
|
168
|
+
const msg = m.messages?.[0];
|
|
169
|
+
if (!msg?.message) return;
|
|
170
170
|
|
|
171
171
|
const sender = msg.key.remoteJid?.split('@')[0] || "unknown";
|
|
172
172
|
const pushName = msg.pushName || "WhatsApp User";
|