wa-multi-mongodb 3.9.9 → 3.10.0
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/Messaging/index.d.ts.map +1 -1
- package/dist/Messaging/index.js +75 -30
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Messaging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,SAAS,CAAC;AAGnD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAOlB,eAAO,MAAM,eAAe,GAAU,4CAMnC,gBAAgB,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Messaging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,SAAS,CAAC;AAGnD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAOlB,eAAO,MAAM,eAAe,GAAU,4CAMnC,gBAAgB,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CA0I7D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAU,sDAO9C,2BAA2B,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAgKxE,CAAC;AAaF,eAAO,MAAM,SAAS,GAAU,wEAS7B,cAAc,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAiM3D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,6CAMjC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAyHzE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,6CAM/B,cAAc,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAuH3D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAU,uCAK9B,eAAe,KAAG,OAAO,CAAC,IAAI,CAuEhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAU,qBAG/B,aAAa,KAAG,OAAO,CAAC,IAAI,CA6B9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAU,qBAGjC,aAAa,KAAG,OAAO,CAAC,IAAI,CAsC9B,CAAC"}
|
package/dist/Messaging/index.js
CHANGED
|
@@ -69,9 +69,12 @@ const sendTextMessage = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
69
69
|
// Beri timeout yang lebih pendek untuk grup untuk mencegah hanging
|
|
70
70
|
const timeoutMs = isDestinationGroup ? 15000 : 30000;
|
|
71
71
|
// Gunakan withTimeout untuk membatasi waktu operasi
|
|
72
|
-
|
|
72
|
+
const result = yield session.sendMessage(jid, {
|
|
73
73
|
text: text,
|
|
74
|
-
}, messageOptions)
|
|
74
|
+
}, messageOptions);
|
|
75
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
76
|
+
result.toJSON = () => ({});
|
|
77
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(result), timeoutMs, `Pengiriman pesan ke ${jid} melebihi batas waktu ${timeoutMs / 1000} detik`);
|
|
75
78
|
}
|
|
76
79
|
catch (error) {
|
|
77
80
|
console.error(`Error saat mengirim pesan (percobaan ${retryCount + 1}/${maxRetries}): ${(error === null || error === void 0 ? void 0 : error.message) || 'Unknown error'}`);
|
|
@@ -96,11 +99,14 @@ const sendTextMessage = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
96
99
|
yield (0, Socket_1.reconnect)(sessionId);
|
|
97
100
|
yield (0, create_delay_1.createDelay)(3000); // Beri waktu untuk reconnect sepenuhnya
|
|
98
101
|
// Coba kirim lagi setelah reconnect
|
|
99
|
-
|
|
102
|
+
const reconnectResult = yield session.sendMessage(jid, {
|
|
100
103
|
text: text,
|
|
101
104
|
}, {
|
|
102
105
|
quoted: props.answering,
|
|
103
|
-
})
|
|
106
|
+
});
|
|
107
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
108
|
+
reconnectResult.toJSON = () => ({});
|
|
109
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(reconnectResult), 30000, `Pengiriman pesan setelah reconnect melebihi batas waktu`);
|
|
104
110
|
}
|
|
105
111
|
catch (reconnectError) {
|
|
106
112
|
console.error(`Gagal reconnect: ${(reconnectError === null || reconnectError === void 0 ? void 0 : reconnectError.message) || 'Unknown error'}`);
|
|
@@ -111,11 +117,14 @@ const sendTextMessage = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
111
117
|
try {
|
|
112
118
|
yield (0, create_delay_1.createDelay)(2000);
|
|
113
119
|
// Untuk percobaan kedua, gunakan timeout yang lebih lama
|
|
114
|
-
|
|
120
|
+
const retryResult = yield session.sendMessage(jid, {
|
|
115
121
|
text: text,
|
|
116
122
|
}, {
|
|
117
123
|
quoted: props.answering,
|
|
118
|
-
})
|
|
124
|
+
});
|
|
125
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
126
|
+
retryResult.toJSON = () => ({});
|
|
127
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(retryResult), 20000, `Percobaan kedua pengiriman pesan melebihi batas waktu`);
|
|
119
128
|
}
|
|
120
129
|
catch (retryError) {
|
|
121
130
|
console.error(`Gagal pada percobaan kedua: ${(retryError === null || retryError === void 0 ? void 0 : retryError.message) || 'Unknown error'}`);
|
|
@@ -182,7 +191,10 @@ const sendTextMessageWithMention = (_a) => __awaiter(void 0, void 0, void 0, fun
|
|
|
182
191
|
messageContent.mentions = mentions;
|
|
183
192
|
}
|
|
184
193
|
// Gunakan withTimeout untuk membatasi waktu operasi
|
|
185
|
-
|
|
194
|
+
const result = yield session.sendMessage(jid, messageContent, messageOptions);
|
|
195
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
196
|
+
result.toJSON = () => ({});
|
|
197
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(result), timeoutMs, `Pengiriman pesan dengan mention ke ${jid} melebihi batas waktu ${timeoutMs / 1000} detik`);
|
|
186
198
|
}
|
|
187
199
|
catch (error) {
|
|
188
200
|
console.error(`Error saat mengirim pesan dengan mention (percobaan ${retryCount + 1}/${maxRetries}): ${(error === null || error === void 0 ? void 0 : error.message) || 'Unknown error'}`);
|
|
@@ -214,9 +226,12 @@ const sendTextMessageWithMention = (_a) => __awaiter(void 0, void 0, void 0, fun
|
|
|
214
226
|
messageContent.mentions = mentions;
|
|
215
227
|
}
|
|
216
228
|
// Coba kirim lagi setelah reconnect
|
|
217
|
-
|
|
229
|
+
const reconnectResult = yield session.sendMessage(jid, messageContent, {
|
|
218
230
|
quoted: props.answering,
|
|
219
|
-
})
|
|
231
|
+
});
|
|
232
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
233
|
+
reconnectResult.toJSON = () => ({});
|
|
234
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(reconnectResult), 30000, `Pengiriman pesan dengan mention setelah reconnect melebihi batas waktu`);
|
|
220
235
|
}
|
|
221
236
|
catch (reconnectError) {
|
|
222
237
|
console.error(`Gagal reconnect: ${(reconnectError === null || reconnectError === void 0 ? void 0 : reconnectError.message) || 'Unknown error'}`);
|
|
@@ -234,9 +249,12 @@ const sendTextMessageWithMention = (_a) => __awaiter(void 0, void 0, void 0, fun
|
|
|
234
249
|
messageContent.mentions = mentions;
|
|
235
250
|
}
|
|
236
251
|
// Untuk percobaan kedua, gunakan timeout yang lebih lama
|
|
237
|
-
|
|
252
|
+
const retryResult = yield session.sendMessage(jid, messageContent, {
|
|
238
253
|
quoted: props.answering,
|
|
239
|
-
})
|
|
254
|
+
});
|
|
255
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
256
|
+
retryResult.toJSON = () => ({});
|
|
257
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(retryResult), 20000, `Percobaan kedua pengiriman pesan dengan mention melebihi batas waktu`);
|
|
240
258
|
}
|
|
241
259
|
catch (retryError) {
|
|
242
260
|
console.error(`Gagal pada percobaan kedua: ${(retryError === null || retryError === void 0 ? void 0 : retryError.message) || 'Unknown error'}`);
|
|
@@ -354,7 +372,10 @@ const sendMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionId
|
|
|
354
372
|
}
|
|
355
373
|
// Timeout lebih lama untuk media karena ukuran file
|
|
356
374
|
const timeoutMs = isDestinationGroup ? 60000 : 120000;
|
|
357
|
-
|
|
375
|
+
const result = yield session.sendMessage(jid, messageContent, options);
|
|
376
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
377
|
+
result.toJSON = () => ({});
|
|
378
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(result), timeoutMs, `Pengiriman media melebihi batas waktu ${timeoutMs / 1000} detik`);
|
|
358
379
|
}
|
|
359
380
|
catch (error) {
|
|
360
381
|
console.error(`Error saat mengirim media (percobaan ${retryCount + 1}/${maxRetries}): ${(error === null || error === void 0 ? void 0 : error.message) || 'Unknown error'}`);
|
|
@@ -381,7 +402,11 @@ const sendMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionId
|
|
|
381
402
|
// Siapkan content media untuk percobaan ulang
|
|
382
403
|
const retryContent = getMessageContent();
|
|
383
404
|
// Coba kirim lagi setelah reconnect
|
|
384
|
-
|
|
405
|
+
const reconnectOptions = answering ? { quoted: answering } : {};
|
|
406
|
+
const reconnectResult = yield session.sendMessage(jid, retryContent, reconnectOptions);
|
|
407
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
408
|
+
reconnectResult.toJSON = () => ({});
|
|
409
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(reconnectResult), 180000, // 3 menit untuk percobaan setelah reconnect
|
|
385
410
|
`Pengiriman media setelah reconnect melebihi batas waktu`);
|
|
386
411
|
}
|
|
387
412
|
catch (reconnectError) {
|
|
@@ -395,7 +420,11 @@ const sendMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionId
|
|
|
395
420
|
// Siapkan content media untuk percobaan ulang
|
|
396
421
|
const retryContent = getMessageContent();
|
|
397
422
|
// Untuk percobaan kedua, gunakan timeout yang lebih lama
|
|
398
|
-
|
|
423
|
+
const retryOptions = answering ? { quoted: answering } : {};
|
|
424
|
+
const retryResult = yield session.sendMessage(jid, retryContent, retryOptions);
|
|
425
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
426
|
+
retryResult.toJSON = () => ({});
|
|
427
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(retryResult), 180000, // 3 menit untuk percobaan kedua
|
|
399
428
|
`Percobaan kedua pengiriman media melebihi batas waktu`);
|
|
400
429
|
}
|
|
401
430
|
catch (retryError) {
|
|
@@ -438,16 +467,20 @@ const sendVoiceNote = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
438
467
|
var _a, _b, _c;
|
|
439
468
|
try {
|
|
440
469
|
// Gunakan timeout untuk mencegah hanging
|
|
441
|
-
|
|
470
|
+
const voiceOptions = {
|
|
471
|
+
quoted: props.answering,
|
|
472
|
+
};
|
|
473
|
+
const result = yield session.sendMessage(jid, {
|
|
442
474
|
audio: typeof media == "string"
|
|
443
475
|
? {
|
|
444
476
|
url: media,
|
|
445
477
|
}
|
|
446
478
|
: media,
|
|
447
479
|
ptt: true,
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
|
|
480
|
+
}, voiceOptions);
|
|
481
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
482
|
+
result.toJSON = () => ({});
|
|
483
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(result), 60000, `Pengiriman voice note melebihi batas waktu`);
|
|
451
484
|
}
|
|
452
485
|
catch (error) {
|
|
453
486
|
console.error(`Error saat mengirim voice note (percobaan ${retryCount + 1}/${maxRetries}): ${(error === null || error === void 0 ? void 0 : error.message) || 'Unknown error'}`);
|
|
@@ -472,16 +505,20 @@ const sendVoiceNote = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
472
505
|
yield (0, Socket_1.reconnect)(sessionId);
|
|
473
506
|
yield (0, create_delay_1.createDelay)(3000); // Beri waktu untuk reconnect sepenuhnya
|
|
474
507
|
// Coba kirim lagi setelah reconnect
|
|
475
|
-
|
|
508
|
+
const reconnectVoiceOptions = {
|
|
509
|
+
quoted: props.answering,
|
|
510
|
+
};
|
|
511
|
+
const reconnectResult = yield session.sendMessage(jid, {
|
|
476
512
|
audio: typeof media == "string"
|
|
477
513
|
? {
|
|
478
514
|
url: media,
|
|
479
515
|
}
|
|
480
516
|
: media,
|
|
481
517
|
ptt: true,
|
|
482
|
-
},
|
|
483
|
-
|
|
484
|
-
|
|
518
|
+
}, reconnectVoiceOptions);
|
|
519
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
520
|
+
reconnectResult.toJSON = () => ({});
|
|
521
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(reconnectResult), 60000, `Pengiriman voice note setelah reconnect melebihi batas waktu`);
|
|
485
522
|
}
|
|
486
523
|
catch (reconnectError) {
|
|
487
524
|
console.error(`Gagal reconnect: ${(reconnectError === null || reconnectError === void 0 ? void 0 : reconnectError.message) || 'Unknown error'}`);
|
|
@@ -526,15 +563,19 @@ const sendSticker = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
526
563
|
var _a, _b, _c;
|
|
527
564
|
try {
|
|
528
565
|
// Gunakan timeout untuk mencegah hanging
|
|
529
|
-
|
|
566
|
+
const stickerOptions = {
|
|
567
|
+
quoted: props.answering,
|
|
568
|
+
};
|
|
569
|
+
const result = yield session.sendMessage(jid, {
|
|
530
570
|
sticker: typeof media == "string"
|
|
531
571
|
? {
|
|
532
572
|
url: media,
|
|
533
573
|
}
|
|
534
574
|
: media,
|
|
535
|
-
},
|
|
536
|
-
|
|
537
|
-
|
|
575
|
+
}, stickerOptions);
|
|
576
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
577
|
+
result.toJSON = () => ({});
|
|
578
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(result), 60000, `Pengiriman sticker melebihi batas waktu`);
|
|
538
579
|
}
|
|
539
580
|
catch (error) {
|
|
540
581
|
console.error(`Error saat mengirim sticker (percobaan ${retryCount + 1}/${maxRetries}): ${(error === null || error === void 0 ? void 0 : error.message) || 'Unknown error'}`);
|
|
@@ -559,15 +600,19 @@ const sendSticker = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
559
600
|
yield (0, Socket_1.reconnect)(sessionId);
|
|
560
601
|
yield (0, create_delay_1.createDelay)(3000); // Beri waktu untuk reconnect sepenuhnya
|
|
561
602
|
// Coba kirim lagi setelah reconnect
|
|
562
|
-
|
|
603
|
+
const reconnectStickerOptions = {
|
|
604
|
+
quoted: props.answering,
|
|
605
|
+
};
|
|
606
|
+
const reconnectResult = yield session.sendMessage(jid, {
|
|
563
607
|
sticker: typeof media == "string"
|
|
564
608
|
? {
|
|
565
609
|
url: media,
|
|
566
610
|
}
|
|
567
611
|
: media,
|
|
568
|
-
},
|
|
569
|
-
|
|
570
|
-
|
|
612
|
+
}, reconnectStickerOptions);
|
|
613
|
+
// Tambahkan method toJSON untuk compatibility dengan WebMessageInfo
|
|
614
|
+
reconnectResult.toJSON = () => ({});
|
|
615
|
+
return yield (0, create_delay_1.withTimeout)(Promise.resolve(reconnectResult), 60000, `Pengiriman sticker setelah reconnect melebihi batas waktu`);
|
|
571
616
|
}
|
|
572
617
|
catch (reconnectError) {
|
|
573
618
|
console.error(`Gagal reconnect: ${(reconnectError === null || reconnectError === void 0 ? void 0 : reconnectError.message) || 'Unknown error'}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wa-multi-mongodb",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Multi Session Whatsapp Library with MongoDB Integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@types/node-cache": "^4.1.3",
|
|
21
21
|
"@types/qrcode": "^1.5.5",
|
|
22
22
|
"aws4": "^1.13.2",
|
|
23
|
-
"baileys": "^
|
|
23
|
+
"baileys": "^7.0.0-rc.6",
|
|
24
24
|
"dotenv": "^16.5.0",
|
|
25
25
|
"link-preview-js": "^3.0.14",
|
|
26
26
|
"mime": "^3.0.0",
|