@wahooks/channel 0.5.0 → 0.5.1
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/dist/index.js +7 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -336,12 +336,16 @@ function connectWebSocket() {
|
|
|
336
336
|
const event = JSON.parse(data.toString());
|
|
337
337
|
const eventType = event.event ?? "";
|
|
338
338
|
const payload = event.payload ?? {};
|
|
339
|
-
// Only handle
|
|
340
|
-
if (
|
|
339
|
+
// Only handle "message" events (skip "message.any", "message.ack" to avoid duplicates)
|
|
340
|
+
if (eventType !== "message")
|
|
341
|
+
return;
|
|
342
|
+
// Skip outbound messages (sent by us)
|
|
343
|
+
if (payload.fromMe)
|
|
341
344
|
return;
|
|
342
345
|
const from = (payload.from ?? "")
|
|
343
346
|
.replace("@c.us", "")
|
|
344
|
-
.replace("@s.whatsapp.net", "")
|
|
347
|
+
.replace("@s.whatsapp.net", "")
|
|
348
|
+
.replace("@lid", "");
|
|
345
349
|
const text = payload.body ?? payload.text ?? "";
|
|
346
350
|
const messageId = payload.id?._serialized ?? payload.id ?? `msg_${Date.now()}`;
|
|
347
351
|
if (!from || !text)
|