wa-multi-mongodb 3.10.0 → 3.10.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/Messaging/index.d.ts.map +1 -1
- package/dist/Messaging/index.js +25 -5
- package/dist/Utils/index.d.ts +1 -0
- package/dist/Utils/index.d.ts.map +1 -1
- package/dist/Utils/index.js +1 -0
- package/dist/Utils/lid-utils.d.ts +26 -0
- package/dist/Utils/lid-utils.d.ts.map +1 -0
- package/dist/Utils/lid-utils.js +79 -0
- package/dist/Utils/phone-to-jid.d.ts +12 -0
- package/dist/Utils/phone-to-jid.d.ts.map +1 -1
- package/dist/Utils/phone-to-jid.js +23 -2
- package/package.json +1 -1
- package/readme.md +16 -1
|
@@ -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;
|
|
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;AAQlB,eAAO,MAAM,eAAe,GAAU,4CAMnC,gBAAgB,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CA8I7D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAU,sDAO9C,2BAA2B,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAoKxE,CAAC;AAaF,eAAO,MAAM,SAAS,GAAU,wEAS7B,cAAc,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CAqM3D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,6CAMjC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CA6HzE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,6CAM/B,cAAc,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,SAAS,CA2H3D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GAAU,uCAK9B,eAAe,KAAG,OAAO,CAAC,IAAI,CA4EhC,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
|
@@ -27,6 +27,7 @@ exports.deleteMessage = exports.readMessage = exports.sendTyping = exports.sendS
|
|
|
27
27
|
const Defaults_1 = require("../Defaults");
|
|
28
28
|
const Socket_1 = require("../Socket");
|
|
29
29
|
const Utils_1 = require("../Utils");
|
|
30
|
+
const Utils_2 = require("../Utils");
|
|
30
31
|
const create_delay_1 = require("../Utils/create-delay");
|
|
31
32
|
const is_exist_1 = require("../Utils/is-exist");
|
|
32
33
|
const mime_1 = __importDefault(require("mime"));
|
|
@@ -53,6 +54,10 @@ const sendTextMessage = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
53
54
|
else {
|
|
54
55
|
jid = (0, Utils_1.phoneToJid)({ to, isGroup: isGroup || isGroupChat });
|
|
55
56
|
}
|
|
57
|
+
// Validasi JID untuk memastikan format yang didukung
|
|
58
|
+
if (!(0, Utils_2.isValidJid)(jid)) {
|
|
59
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}. Supported formats: @s.whatsapp.net, @lid, @g.us`);
|
|
60
|
+
}
|
|
56
61
|
let retryCount = 0;
|
|
57
62
|
const maxRetries = 3;
|
|
58
63
|
const attemptSend = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -85,7 +90,6 @@ const sendTextMessage = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
85
90
|
retryCount++;
|
|
86
91
|
// Tambahkan delay lebih lama antara percobaan
|
|
87
92
|
yield (0, create_delay_1.createDelay)(2000 * retryCount);
|
|
88
|
-
console.log(`Mencoba kembali pengiriman pesan (${retryCount}/${maxRetries})...`);
|
|
89
93
|
return attemptSend();
|
|
90
94
|
}
|
|
91
95
|
else {
|
|
@@ -167,6 +171,10 @@ const sendTextMessageWithMention = (_a) => __awaiter(void 0, void 0, void 0, fun
|
|
|
167
171
|
else {
|
|
168
172
|
jid = (0, Utils_1.phoneToJid)({ to, isGroup: isGroup || isGroupChat });
|
|
169
173
|
}
|
|
174
|
+
// Validasi JID untuk memastikan format yang didukung
|
|
175
|
+
if (!(0, Utils_2.isValidJid)(jid)) {
|
|
176
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}. Supported formats: @s.whatsapp.net, @lid, @g.us`);
|
|
177
|
+
}
|
|
170
178
|
let retryCount = 0;
|
|
171
179
|
const maxRetries = 3;
|
|
172
180
|
const attemptSend = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -205,7 +213,6 @@ const sendTextMessageWithMention = (_a) => __awaiter(void 0, void 0, void 0, fun
|
|
|
205
213
|
retryCount++;
|
|
206
214
|
// Tambahkan delay lebih lama antara percobaan
|
|
207
215
|
yield (0, create_delay_1.createDelay)(2000 * retryCount);
|
|
208
|
-
console.log(`Mencoba kembali pengiriman pesan dengan mention (${retryCount}/${maxRetries})...`);
|
|
209
216
|
return attemptSend();
|
|
210
217
|
}
|
|
211
218
|
else {
|
|
@@ -286,6 +293,10 @@ const sendMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionId
|
|
|
286
293
|
else {
|
|
287
294
|
jid = (0, Utils_1.phoneToJid)({ to, isGroup: isGroup || isGroupChat });
|
|
288
295
|
}
|
|
296
|
+
// Validasi JID untuk memastikan format yang didukung
|
|
297
|
+
if (!(0, Utils_2.isValidJid)(jid)) {
|
|
298
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}. Supported formats: @s.whatsapp.net, @lid, @g.us`);
|
|
299
|
+
}
|
|
289
300
|
let retryCount = 0;
|
|
290
301
|
const maxRetries = 3;
|
|
291
302
|
// Helper function untuk mendapatkan message content berdasarkan tipe
|
|
@@ -386,7 +397,6 @@ const sendMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionId
|
|
|
386
397
|
retryCount++;
|
|
387
398
|
// Tambahkan delay lebih lama antara percobaan
|
|
388
399
|
yield (0, create_delay_1.createDelay)(2000 * retryCount);
|
|
389
|
-
console.log(`Mencoba kembali pengiriman media (${retryCount}/${maxRetries})...`);
|
|
390
400
|
return attemptSend();
|
|
391
401
|
}
|
|
392
402
|
else {
|
|
@@ -458,6 +468,10 @@ const sendVoiceNote = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
458
468
|
else {
|
|
459
469
|
jid = (0, Utils_1.phoneToJid)({ to, isGroup: isGroup || isGroupChat });
|
|
460
470
|
}
|
|
471
|
+
// Validasi JID untuk memastikan format yang didukung
|
|
472
|
+
if (!(0, Utils_2.isValidJid)(jid)) {
|
|
473
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}. Supported formats: @s.whatsapp.net, @lid, @g.us`);
|
|
474
|
+
}
|
|
461
475
|
if (!media) {
|
|
462
476
|
throw new Error_1.WhatsappError(`Invalid Media`);
|
|
463
477
|
}
|
|
@@ -491,7 +505,6 @@ const sendVoiceNote = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
491
505
|
retryCount++;
|
|
492
506
|
// Tambahkan delay lebih lama antara percobaan
|
|
493
507
|
yield (0, create_delay_1.createDelay)(2000 * retryCount);
|
|
494
|
-
console.log(`Mencoba kembali pengiriman voice note (${retryCount}/${maxRetries})...`);
|
|
495
508
|
return attemptSend();
|
|
496
509
|
}
|
|
497
510
|
else {
|
|
@@ -554,6 +567,10 @@ const sendSticker = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
554
567
|
else {
|
|
555
568
|
jid = (0, Utils_1.phoneToJid)({ to, isGroup: isGroup || isGroupChat });
|
|
556
569
|
}
|
|
570
|
+
// Validasi JID untuk memastikan format yang didukung
|
|
571
|
+
if (!(0, Utils_2.isValidJid)(jid)) {
|
|
572
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}. Supported formats: @s.whatsapp.net, @lid, @g.us`);
|
|
573
|
+
}
|
|
557
574
|
if (!media) {
|
|
558
575
|
throw new Error_1.WhatsappError(`Invalid Media`);
|
|
559
576
|
}
|
|
@@ -586,7 +603,6 @@ const sendSticker = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
586
603
|
retryCount++;
|
|
587
604
|
// Tambahkan delay lebih lama antara percobaan
|
|
588
605
|
yield (0, create_delay_1.createDelay)(2000 * retryCount);
|
|
589
|
-
console.log(`Mencoba kembali pengiriman sticker (${retryCount}/${maxRetries})...`);
|
|
590
606
|
return attemptSend();
|
|
591
607
|
}
|
|
592
608
|
else {
|
|
@@ -658,6 +674,10 @@ const sendTyping = (_a) => __awaiter(void 0, [_a], void 0, function* ({ sessionI
|
|
|
658
674
|
else {
|
|
659
675
|
jid = (0, Utils_1.phoneToJid)({ to, isGroup: isGroup || isGroupChat });
|
|
660
676
|
}
|
|
677
|
+
// Validasi JID untuk memastikan format yang didukung
|
|
678
|
+
if (!(0, Utils_2.isValidJid)(jid)) {
|
|
679
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}. Supported formats: @s.whatsapp.net, @lid, @g.us`);
|
|
680
|
+
}
|
|
661
681
|
try {
|
|
662
682
|
// Deteksi apakah ini grup
|
|
663
683
|
const isDestinationGroup = jid.endsWith('@g.us');
|
package/dist/Utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
package/dist/Utils/index.js
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./phone-to-jid"), exports);
|
|
|
18
18
|
__exportStar(require("./is-exist"), exports);
|
|
19
19
|
__exportStar(require("./create-delay"), exports);
|
|
20
20
|
__exportStar(require("./group-cache"), exports);
|
|
21
|
+
__exportStar(require("./lid-utils"), exports);
|
|
21
22
|
// Note: setCredentialsDir & setMongoDBNames have been moved to src/Socket/index.ts
|
|
22
23
|
// Please import them directly from there instead
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fungsi untuk mendeteksi apakah sebuah JID menggunakan format PN (@s.whatsapp.net)
|
|
3
|
+
* @param jid JID yang akan dicek
|
|
4
|
+
* @returns true jika JID menggunakan format PN
|
|
5
|
+
*/
|
|
6
|
+
export declare const isPnJid: (jid: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Fungsi untuk mengekstrak nomor telepon dari JID (baik format @s.whatsapp.net atau @lid)
|
|
9
|
+
* @param jid JID yang akan diekstrak
|
|
10
|
+
* @returns nomor telepon tanpa suffix
|
|
11
|
+
*/
|
|
12
|
+
export declare const extractPhoneNumber: (jid: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Fungsi untuk konversi JID dari format LID ke format PN jika diperlukan
|
|
15
|
+
* Catatan: Fungsi ini hanya untuk kompatibilitas, karena WhatsApp sekarang mendukung kedua format
|
|
16
|
+
* @param jid JID yang akan dikonversi
|
|
17
|
+
* @returns JID dalam format yang sesuai
|
|
18
|
+
*/
|
|
19
|
+
export declare const normalizeJid: (jid: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Fungsi untuk memvalidasi format JID
|
|
22
|
+
* @param jid JID yang akan divalidasi
|
|
23
|
+
* @returns true jika JID valid
|
|
24
|
+
*/
|
|
25
|
+
export declare const isValidJid: (jid: string) => boolean;
|
|
26
|
+
//# sourceMappingURL=lid-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lid-utils.d.ts","sourceRoot":"","sources":["../../src/Utils/lid-utils.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,OAErC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,MAAM,KAAG,MAQhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAe1C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OA2BxC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidJid = exports.normalizeJid = exports.extractPhoneNumber = exports.isPnJid = void 0;
|
|
4
|
+
const Error_1 = require("../Error");
|
|
5
|
+
const phone_to_jid_1 = require("./phone-to-jid");
|
|
6
|
+
/**
|
|
7
|
+
* Fungsi untuk mendeteksi apakah sebuah JID menggunakan format PN (@s.whatsapp.net)
|
|
8
|
+
* @param jid JID yang akan dicek
|
|
9
|
+
* @returns true jika JID menggunakan format PN
|
|
10
|
+
*/
|
|
11
|
+
const isPnJid = (jid) => {
|
|
12
|
+
return jid.includes("@s.whatsapp.net");
|
|
13
|
+
};
|
|
14
|
+
exports.isPnJid = isPnJid;
|
|
15
|
+
/**
|
|
16
|
+
* Fungsi untuk mengekstrak nomor telepon dari JID (baik format @s.whatsapp.net atau @lid)
|
|
17
|
+
* @param jid JID yang akan diekstrak
|
|
18
|
+
* @returns nomor telepon tanpa suffix
|
|
19
|
+
*/
|
|
20
|
+
const extractPhoneNumber = (jid) => {
|
|
21
|
+
if (!jid)
|
|
22
|
+
throw new Error_1.WhatsappError('parameter "jid" is required');
|
|
23
|
+
// Hapus suffix @s.whatsapp.net atau @lid
|
|
24
|
+
const phoneNumber = jid.replace(/@(s\.whatsapp\.net|lid)$/, '');
|
|
25
|
+
// Hapus karakter non-digit
|
|
26
|
+
return phoneNumber.replace(/\D/g, '');
|
|
27
|
+
};
|
|
28
|
+
exports.extractPhoneNumber = extractPhoneNumber;
|
|
29
|
+
/**
|
|
30
|
+
* Fungsi untuk konversi JID dari format LID ke format PN jika diperlukan
|
|
31
|
+
* Catatan: Fungsi ini hanya untuk kompatibilitas, karena WhatsApp sekarang mendukung kedua format
|
|
32
|
+
* @param jid JID yang akan dikonversi
|
|
33
|
+
* @returns JID dalam format yang sesuai
|
|
34
|
+
*/
|
|
35
|
+
const normalizeJid = (jid) => {
|
|
36
|
+
if (!jid)
|
|
37
|
+
throw new Error_1.WhatsappError('parameter "jid" is required');
|
|
38
|
+
// Jika sudah dalam format yang valid, kembalikan apa adanya
|
|
39
|
+
if ((0, phone_to_jid_1.isLidJid)(jid) || (0, exports.isPnJid)(jid) || jid.includes('@g.us') || jid.includes('@broadcast')) {
|
|
40
|
+
return jid;
|
|
41
|
+
}
|
|
42
|
+
// Jika hanya nomor telepon, tambahkan suffix default
|
|
43
|
+
const phoneNumber = jid.replace(/\D/g, '');
|
|
44
|
+
if (phoneNumber.length > 0) {
|
|
45
|
+
return `${phoneNumber}@s.whatsapp.net`;
|
|
46
|
+
}
|
|
47
|
+
throw new Error_1.WhatsappError(`Invalid JID format: ${jid}`);
|
|
48
|
+
};
|
|
49
|
+
exports.normalizeJid = normalizeJid;
|
|
50
|
+
/**
|
|
51
|
+
* Fungsi untuk memvalidasi format JID
|
|
52
|
+
* @param jid JID yang akan divalidasi
|
|
53
|
+
* @returns true jika JID valid
|
|
54
|
+
*/
|
|
55
|
+
const isValidJid = (jid) => {
|
|
56
|
+
if (!jid)
|
|
57
|
+
return false;
|
|
58
|
+
// Validasi format @s.whatsapp.net
|
|
59
|
+
if ((0, exports.isPnJid)(jid)) {
|
|
60
|
+
const phoneNumber = (0, exports.extractPhoneNumber)(jid);
|
|
61
|
+
return phoneNumber.length >= 10 && phoneNumber.length <= 15;
|
|
62
|
+
}
|
|
63
|
+
// Validasi format @lid
|
|
64
|
+
if ((0, phone_to_jid_1.isLidJid)(jid)) {
|
|
65
|
+
const lidPart = jid.split('@')[0];
|
|
66
|
+
return lidPart.length > 0;
|
|
67
|
+
}
|
|
68
|
+
// Validasi format grup
|
|
69
|
+
if (jid.includes('@g.us')) {
|
|
70
|
+
const groupPart = jid.split('@')[0];
|
|
71
|
+
return groupPart.length > 0 && groupPart.includes('-');
|
|
72
|
+
}
|
|
73
|
+
// Validasi format broadcast
|
|
74
|
+
if (jid.includes('@broadcast')) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
79
|
+
exports.isValidJid = isValidJid;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fungsi untuk mendeteksi apakah sebuah JID menggunakan format LID (@lid)
|
|
3
|
+
* @param jid JID yang akan dicek
|
|
4
|
+
* @returns true jika JID menggunakan format LID
|
|
5
|
+
*/
|
|
6
|
+
export declare const isLidJid: (jid: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Fungsi untuk normalisasi JID, mendukung format @s.whatsapp.net dan @lid
|
|
9
|
+
* @param to Nomor telepon atau JID tujuan
|
|
10
|
+
* @param isGroup Apakah ini adalah grup
|
|
11
|
+
* @returns JID yang sudah dinormalisasi
|
|
12
|
+
*/
|
|
1
13
|
export declare const phoneToJid: ({ to, isGroup, }: {
|
|
2
14
|
to: string | number;
|
|
3
15
|
isGroup?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone-to-jid.d.ts","sourceRoot":"","sources":["../../src/Utils/phone-to-jid.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,UAAU,GAAI,kBAGxB;IACD,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,KAAG,
|
|
1
|
+
{"version":3,"file":"phone-to-jid.d.ts","sourceRoot":"","sources":["../../src/Utils/phone-to-jid.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,KAAG,OAEtC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,kBAGxB;IACD,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,KAAG,MAoBH,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.phoneToJid = void 0;
|
|
6
|
+
exports.phoneToJid = exports.isLidJid = void 0;
|
|
7
7
|
const Error_1 = require("../Error");
|
|
8
8
|
const baileys_1 = __importDefault(require("baileys"));
|
|
9
9
|
const isPhoneNumberValidCountry = (phone) => {
|
|
@@ -11,6 +11,21 @@ const isPhoneNumberValidCountry = (phone) => {
|
|
|
11
11
|
return phone.startsWith(key);
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Fungsi untuk mendeteksi apakah sebuah JID menggunakan format LID (@lid)
|
|
16
|
+
* @param jid JID yang akan dicek
|
|
17
|
+
* @returns true jika JID menggunakan format LID
|
|
18
|
+
*/
|
|
19
|
+
const isLidJid = (jid) => {
|
|
20
|
+
return jid.includes("@lid");
|
|
21
|
+
};
|
|
22
|
+
exports.isLidJid = isLidJid;
|
|
23
|
+
/**
|
|
24
|
+
* Fungsi untuk normalisasi JID, mendukung format @s.whatsapp.net dan @lid
|
|
25
|
+
* @param to Nomor telepon atau JID tujuan
|
|
26
|
+
* @param isGroup Apakah ini adalah grup
|
|
27
|
+
* @returns JID yang sudah dinormalisasi
|
|
28
|
+
*/
|
|
14
29
|
const phoneToJid = ({ to, isGroup = false, }) => {
|
|
15
30
|
if (!to)
|
|
16
31
|
throw new Error_1.WhatsappError('parameter "to" is required');
|
|
@@ -22,8 +37,14 @@ const phoneToJid = ({ to, isGroup = false, }) => {
|
|
|
22
37
|
}
|
|
23
38
|
else {
|
|
24
39
|
number = number.replace(/\s|[+]|[-]/gim, "");
|
|
25
|
-
|
|
40
|
+
// Jika sudah dalam format @lid atau @s.whatsapp.net, gunakan apa adanya
|
|
41
|
+
if (number.includes("@lid") || number.includes("@s.whatsapp.net")) {
|
|
42
|
+
// Jangan tambahkan suffix lagi
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Default ke format @s.whatsapp.net untuk kompatibilitas
|
|
26
46
|
number = number + "@s.whatsapp.net";
|
|
47
|
+
}
|
|
27
48
|
}
|
|
28
49
|
return number;
|
|
29
50
|
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -816,7 +816,22 @@ export default WhatsAppQRComponent;
|
|
|
816
816
|
|
|
817
817
|
## Changelog
|
|
818
818
|
|
|
819
|
-
### v3.
|
|
819
|
+
### v3.10.1 (latest)
|
|
820
|
+
- **Using Baileys New Version (7.x.x)**: Update & support function with latest baileys version
|
|
821
|
+
- **Added @lid Format Support**: Full support for WhatsApp's new @lid identifier format
|
|
822
|
+
- Updated `phoneToJid()` function to handle both @s.whatsapp.net and @lid formats
|
|
823
|
+
- Enhanced all message sending functions with JID validation:
|
|
824
|
+
- `sendTextMessage()`
|
|
825
|
+
- `sendTextMessageWithMention()`
|
|
826
|
+
- `sendMedia()`
|
|
827
|
+
- `sendVoiceNote()`
|
|
828
|
+
- `sendSticker()`
|
|
829
|
+
- `sendTyping()`
|
|
830
|
+
- No breaking changes - existing @s.whatsapp.net format continues to work
|
|
831
|
+
- Automatic detection and handling of @lid format to prevent 404 errors
|
|
832
|
+
- Added comprehensive error handling for invalid JID formats
|
|
833
|
+
|
|
834
|
+
### v3.9.8
|
|
820
835
|
### Added
|
|
821
836
|
- **New `sendTextMessageWithMention` Function**: Comprehensive mention functionality for WhatsApp messages
|
|
822
837
|
- Support for mentioning single or multiple users in group chats
|