@builderbot/provider-baileys 1.3.5-alpha.8 → 1.3.5
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/bailey.d.ts +11 -0
- package/dist/bailey.d.ts.map +1 -1
- package/dist/index.cjs +79 -16
- package/dist/index.mjs +79 -16
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/bailey.d.ts
CHANGED
|
@@ -206,6 +206,17 @@ declare class BaileysProvider extends ProviderClass<WASocket> {
|
|
|
206
206
|
* @returns Object with identifier (preferring LID per official guidance), type, and isLID flag
|
|
207
207
|
*/
|
|
208
208
|
private extractSenderWithAltFields;
|
|
209
|
+
/**
|
|
210
|
+
* CRITICAL FIX for Baileys v7.0.0+ LID sync issues
|
|
211
|
+
* Resolves LID to PN for outgoing messages to ensure they appear in WhatsApp app
|
|
212
|
+
*
|
|
213
|
+
* Issue: Messages sent to LIDs from linked devices don't sync to main WhatsApp app
|
|
214
|
+
* Solution: Convert LIDs to PNs when sending messages (keep LIDs for receiving)
|
|
215
|
+
*
|
|
216
|
+
* @param identifier The identifier to resolve (LID or PN)
|
|
217
|
+
* @returns PN format for reliable message sending
|
|
218
|
+
*/
|
|
219
|
+
private resolveLIDToPNForSending;
|
|
209
220
|
private shouldReconnect;
|
|
210
221
|
private delayedReconnect;
|
|
211
222
|
/**
|
package/dist/bailey.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bailey.d.ts","sourceRoot":"","sources":["../src/bailey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAIjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,IAAI,CAAA;AAI9C,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,OAAO,KAAK,KAAK,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try {
|
|
31132
31132
|
const sock = baileys.makeWASocket({
|
|
31133
31133
|
logger: loggerBaileys,
|
|
31134
|
-
version: [2, 3000,
|
|
31134
|
+
version: [2, 3000, 1025190524],
|
|
31135
31135
|
printQRInTerminal: false,
|
|
31136
31136
|
auth: {
|
|
31137
31137
|
creds: state.creds,
|
|
@@ -31536,17 +31536,19 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31536
31536
|
* @example await sendMessage('+XXXXXXXXXXX', 'https://dominio.com/imagen.jpg' | 'img/imagen.jpg')
|
|
31537
31537
|
*/
|
|
31538
31538
|
this.sendMedia = async (number, imageUrl, text) => {
|
|
31539
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages
|
|
31540
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31539
31541
|
const fileDownloaded = await bot.utils.generalDownload(imageUrl);
|
|
31540
31542
|
const mimeType = mime.lookup(fileDownloaded);
|
|
31541
31543
|
if (`${mimeType}`.includes('image'))
|
|
31542
|
-
return this.sendImage(
|
|
31544
|
+
return this.sendImage(resolvedNumber, fileDownloaded, text);
|
|
31543
31545
|
if (`${mimeType}`.includes('video'))
|
|
31544
|
-
return this.sendVideo(
|
|
31546
|
+
return this.sendVideo(resolvedNumber, fileDownloaded, text);
|
|
31545
31547
|
if (`${mimeType}`.includes('audio')) {
|
|
31546
31548
|
const fileOpus = await bot.utils.convertAudio(fileDownloaded);
|
|
31547
|
-
return this.sendAudio(
|
|
31549
|
+
return this.sendAudio(resolvedNumber, fileOpus);
|
|
31548
31550
|
}
|
|
31549
|
-
return this.sendFile(
|
|
31551
|
+
return this.sendFile(resolvedNumber, fileDownloaded, text);
|
|
31550
31552
|
};
|
|
31551
31553
|
/**
|
|
31552
31554
|
* Enviar imagen
|
|
@@ -31586,11 +31588,14 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31586
31588
|
* @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
|
|
31587
31589
|
*/
|
|
31588
31590
|
this.sendAudio = async (number, audioUrl) => {
|
|
31591
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages
|
|
31592
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31589
31593
|
const payload = {
|
|
31590
31594
|
audio: { url: audioUrl },
|
|
31591
31595
|
ptt: true,
|
|
31592
31596
|
};
|
|
31593
|
-
|
|
31597
|
+
this.logger.log(`[${new Date().toISOString()}] Sending audio to: ${resolvedNumber} (original: ${number})`);
|
|
31598
|
+
return this.vendor.sendMessage(resolvedNumber, payload);
|
|
31594
31599
|
};
|
|
31595
31600
|
/**
|
|
31596
31601
|
*
|
|
@@ -31599,8 +31604,11 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31599
31604
|
* @returns
|
|
31600
31605
|
*/
|
|
31601
31606
|
this.sendText = async (number, message) => {
|
|
31607
|
+
// CRITICAL FIX: Ensure we use PN for outgoing messages to prevent sync issues
|
|
31608
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31602
31609
|
const payload = { text: message };
|
|
31603
|
-
|
|
31610
|
+
this.logger.log(`[${new Date().toISOString()}] Sending message to: ${resolvedNumber} (original: ${number})`);
|
|
31611
|
+
return this.vendor.sendMessage(resolvedNumber, payload);
|
|
31604
31612
|
};
|
|
31605
31613
|
/**
|
|
31606
31614
|
*
|
|
@@ -31609,6 +31617,8 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31609
31617
|
* @example await sendMessage('+XXXXXXXXXXX', './document/file.pdf')
|
|
31610
31618
|
*/
|
|
31611
31619
|
this.sendFile = async (number, filePath, text) => {
|
|
31620
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages
|
|
31621
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31612
31622
|
const mimeType = mime.lookup(filePath);
|
|
31613
31623
|
const fileName = require$$1$1.basename(filePath);
|
|
31614
31624
|
const payload = {
|
|
@@ -31617,7 +31627,8 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31617
31627
|
fileName: fileName,
|
|
31618
31628
|
caption: text,
|
|
31619
31629
|
};
|
|
31620
|
-
|
|
31630
|
+
this.logger.log(`[${new Date().toISOString()}] Sending file to: ${resolvedNumber} (original: ${number})`);
|
|
31631
|
+
return this.vendor.sendMessage(resolvedNumber, payload);
|
|
31621
31632
|
};
|
|
31622
31633
|
/**
|
|
31623
31634
|
* @deprecated Buttons are not available in this provider, please use sendButtons instead
|
|
@@ -31680,7 +31691,8 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31680
31691
|
*/
|
|
31681
31692
|
this.sendMessage = async (numberIn, message, options) => {
|
|
31682
31693
|
options = { ...options, ...options['options'] };
|
|
31683
|
-
|
|
31694
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages to ensure WhatsApp sync
|
|
31695
|
+
const number = await this.resolveLIDToPNForSending(baileyCleanNumber(`${numberIn}`));
|
|
31684
31696
|
if (options.buttons?.length)
|
|
31685
31697
|
return this.sendButtons(number, message, options.buttons);
|
|
31686
31698
|
if (options.media)
|
|
@@ -31980,7 +31992,7 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
31980
31992
|
rawIdentifier = key.participantAlt || key.participant || '';
|
|
31981
31993
|
isOriginallyLID = rawIdentifier.includes('@lid');
|
|
31982
31994
|
}
|
|
31983
|
-
// For DMs: prioritize remoteJidAlt over remoteJid
|
|
31995
|
+
// For DMs: prioritize remoteJidAlt over remoteJid
|
|
31984
31996
|
else if (key?.remoteJid || key?.remoteJidAlt) {
|
|
31985
31997
|
rawIdentifier = key.remoteJidAlt || key.remoteJid || '';
|
|
31986
31998
|
isOriginallyLID = rawIdentifier.includes('@lid');
|
|
@@ -32038,6 +32050,61 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
32038
32050
|
};
|
|
32039
32051
|
}
|
|
32040
32052
|
}
|
|
32053
|
+
/**
|
|
32054
|
+
* CRITICAL FIX for Baileys v7.0.0+ LID sync issues
|
|
32055
|
+
* Resolves LID to PN for outgoing messages to ensure they appear in WhatsApp app
|
|
32056
|
+
*
|
|
32057
|
+
* Issue: Messages sent to LIDs from linked devices don't sync to main WhatsApp app
|
|
32058
|
+
* Solution: Convert LIDs to PNs when sending messages (keep LIDs for receiving)
|
|
32059
|
+
*
|
|
32060
|
+
* @param identifier The identifier to resolve (LID or PN)
|
|
32061
|
+
* @returns PN format for reliable message sending
|
|
32062
|
+
*/
|
|
32063
|
+
async resolveLIDToPNForSending(identifier) {
|
|
32064
|
+
try {
|
|
32065
|
+
// If it's already a PN, return as-is
|
|
32066
|
+
if (identifier.includes('@s.whatsapp.net')) {
|
|
32067
|
+
return identifier;
|
|
32068
|
+
}
|
|
32069
|
+
// If it's a LID, try to resolve to PN using LID store
|
|
32070
|
+
if (identifier.includes('@lid')) {
|
|
32071
|
+
const lidStore = this.getLIDMappingStore();
|
|
32072
|
+
if (lidStore) {
|
|
32073
|
+
try {
|
|
32074
|
+
const pn = await this.getPNFromLID(identifier);
|
|
32075
|
+
if (pn) {
|
|
32076
|
+
this.logger.log(`[${new Date().toISOString()}] 🔄 Resolved LID ${identifier} to PN ${pn} for sending (sync fix)`);
|
|
32077
|
+
return pn;
|
|
32078
|
+
}
|
|
32079
|
+
else {
|
|
32080
|
+
this.logger.log(`[${new Date().toISOString()}] ⚠️ No PN mapping found for LID ${identifier}, using LID (may not sync)`);
|
|
32081
|
+
}
|
|
32082
|
+
}
|
|
32083
|
+
catch (error) {
|
|
32084
|
+
this.logger.log(`[${new Date().toISOString()}] ❌ Error resolving LID to PN:`, error);
|
|
32085
|
+
}
|
|
32086
|
+
}
|
|
32087
|
+
}
|
|
32088
|
+
// If it's a group, return as-is
|
|
32089
|
+
if (identifier.includes('@g.us')) {
|
|
32090
|
+
return identifier;
|
|
32091
|
+
}
|
|
32092
|
+
// For raw numbers, format as PN
|
|
32093
|
+
const cleaned = identifier.replace(/[^\d]/g, '');
|
|
32094
|
+
if (cleaned.length >= 10) {
|
|
32095
|
+
const pn = `${cleaned}@s.whatsapp.net`;
|
|
32096
|
+
this.logger.log(`[${new Date().toISOString()}] 📞 Formatted raw number ${identifier} as PN ${pn}`);
|
|
32097
|
+
return pn;
|
|
32098
|
+
}
|
|
32099
|
+
// Fallback: return original identifier
|
|
32100
|
+
this.logger.log(`[${new Date().toISOString()}] ⚠️ Using original identifier ${identifier} for sending`);
|
|
32101
|
+
return identifier;
|
|
32102
|
+
}
|
|
32103
|
+
catch (error) {
|
|
32104
|
+
this.logger.log(`[${new Date().toISOString()}] ❌ Error in resolveLIDToPNForSending:`, error);
|
|
32105
|
+
return identifier;
|
|
32106
|
+
}
|
|
32107
|
+
}
|
|
32041
32108
|
shouldReconnect(statusCode) {
|
|
32042
32109
|
// Lista de códigos donde SÍ debemos reconectar
|
|
32043
32110
|
const reconnectableCodes = [
|
|
@@ -32091,12 +32158,8 @@ class BaileysProvider extends bot.ProviderClass {
|
|
|
32091
32158
|
let hasDeviceIndexKey = false;
|
|
32092
32159
|
if (state.keys && typeof state.keys === 'object') {
|
|
32093
32160
|
const keyNames = Object.keys(state.keys);
|
|
32094
|
-
hasLidMappingKey = keyNames.some(key => key === 'lid-mapping' ||
|
|
32095
|
-
|
|
32096
|
-
key.includes('lid-map'));
|
|
32097
|
-
hasDeviceIndexKey = keyNames.some(key => key === 'device-index' ||
|
|
32098
|
-
key === 'deviceIndex' ||
|
|
32099
|
-
key.includes('device-index'));
|
|
32161
|
+
hasLidMappingKey = keyNames.some((key) => key === 'lid-mapping' || key === 'lidMapping' || key.includes('lid-map'));
|
|
32162
|
+
hasDeviceIndexKey = keyNames.some((key) => key === 'device-index' || key === 'deviceIndex' || key.includes('device-index'));
|
|
32100
32163
|
}
|
|
32101
32164
|
// Critical validation as per official docs
|
|
32102
32165
|
if (!hasLidMappingKey) {
|
package/dist/index.mjs
CHANGED
|
@@ -31129,7 +31129,7 @@ class BaileysProvider extends ProviderClass {
|
|
|
31129
31129
|
try {
|
|
31130
31130
|
const sock = makeWASocket({
|
|
31131
31131
|
logger: loggerBaileys,
|
|
31132
|
-
version: [2, 3000,
|
|
31132
|
+
version: [2, 3000, 1025190524],
|
|
31133
31133
|
printQRInTerminal: false,
|
|
31134
31134
|
auth: {
|
|
31135
31135
|
creds: state.creds,
|
|
@@ -31534,17 +31534,19 @@ class BaileysProvider extends ProviderClass {
|
|
|
31534
31534
|
* @example await sendMessage('+XXXXXXXXXXX', 'https://dominio.com/imagen.jpg' | 'img/imagen.jpg')
|
|
31535
31535
|
*/
|
|
31536
31536
|
this.sendMedia = async (number, imageUrl, text) => {
|
|
31537
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages
|
|
31538
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31537
31539
|
const fileDownloaded = await utils$d.generalDownload(imageUrl);
|
|
31538
31540
|
const mimeType = mime.lookup(fileDownloaded);
|
|
31539
31541
|
if (`${mimeType}`.includes('image'))
|
|
31540
|
-
return this.sendImage(
|
|
31542
|
+
return this.sendImage(resolvedNumber, fileDownloaded, text);
|
|
31541
31543
|
if (`${mimeType}`.includes('video'))
|
|
31542
|
-
return this.sendVideo(
|
|
31544
|
+
return this.sendVideo(resolvedNumber, fileDownloaded, text);
|
|
31543
31545
|
if (`${mimeType}`.includes('audio')) {
|
|
31544
31546
|
const fileOpus = await utils$d.convertAudio(fileDownloaded);
|
|
31545
|
-
return this.sendAudio(
|
|
31547
|
+
return this.sendAudio(resolvedNumber, fileOpus);
|
|
31546
31548
|
}
|
|
31547
|
-
return this.sendFile(
|
|
31549
|
+
return this.sendFile(resolvedNumber, fileDownloaded, text);
|
|
31548
31550
|
};
|
|
31549
31551
|
/**
|
|
31550
31552
|
* Enviar imagen
|
|
@@ -31584,11 +31586,14 @@ class BaileysProvider extends ProviderClass {
|
|
|
31584
31586
|
* @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
|
|
31585
31587
|
*/
|
|
31586
31588
|
this.sendAudio = async (number, audioUrl) => {
|
|
31589
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages
|
|
31590
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31587
31591
|
const payload = {
|
|
31588
31592
|
audio: { url: audioUrl },
|
|
31589
31593
|
ptt: true,
|
|
31590
31594
|
};
|
|
31591
|
-
|
|
31595
|
+
this.logger.log(`[${new Date().toISOString()}] Sending audio to: ${resolvedNumber} (original: ${number})`);
|
|
31596
|
+
return this.vendor.sendMessage(resolvedNumber, payload);
|
|
31592
31597
|
};
|
|
31593
31598
|
/**
|
|
31594
31599
|
*
|
|
@@ -31597,8 +31602,11 @@ class BaileysProvider extends ProviderClass {
|
|
|
31597
31602
|
* @returns
|
|
31598
31603
|
*/
|
|
31599
31604
|
this.sendText = async (number, message) => {
|
|
31605
|
+
// CRITICAL FIX: Ensure we use PN for outgoing messages to prevent sync issues
|
|
31606
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31600
31607
|
const payload = { text: message };
|
|
31601
|
-
|
|
31608
|
+
this.logger.log(`[${new Date().toISOString()}] Sending message to: ${resolvedNumber} (original: ${number})`);
|
|
31609
|
+
return this.vendor.sendMessage(resolvedNumber, payload);
|
|
31602
31610
|
};
|
|
31603
31611
|
/**
|
|
31604
31612
|
*
|
|
@@ -31607,6 +31615,8 @@ class BaileysProvider extends ProviderClass {
|
|
|
31607
31615
|
* @example await sendMessage('+XXXXXXXXXXX', './document/file.pdf')
|
|
31608
31616
|
*/
|
|
31609
31617
|
this.sendFile = async (number, filePath, text) => {
|
|
31618
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages
|
|
31619
|
+
const resolvedNumber = await this.resolveLIDToPNForSending(number);
|
|
31610
31620
|
const mimeType = mime.lookup(filePath);
|
|
31611
31621
|
const fileName = basename(filePath);
|
|
31612
31622
|
const payload = {
|
|
@@ -31615,7 +31625,8 @@ class BaileysProvider extends ProviderClass {
|
|
|
31615
31625
|
fileName: fileName,
|
|
31616
31626
|
caption: text,
|
|
31617
31627
|
};
|
|
31618
|
-
|
|
31628
|
+
this.logger.log(`[${new Date().toISOString()}] Sending file to: ${resolvedNumber} (original: ${number})`);
|
|
31629
|
+
return this.vendor.sendMessage(resolvedNumber, payload);
|
|
31619
31630
|
};
|
|
31620
31631
|
/**
|
|
31621
31632
|
* @deprecated Buttons are not available in this provider, please use sendButtons instead
|
|
@@ -31678,7 +31689,8 @@ class BaileysProvider extends ProviderClass {
|
|
|
31678
31689
|
*/
|
|
31679
31690
|
this.sendMessage = async (numberIn, message, options) => {
|
|
31680
31691
|
options = { ...options, ...options['options'] };
|
|
31681
|
-
|
|
31692
|
+
// CRITICAL FIX: Resolve LID to PN for outgoing messages to ensure WhatsApp sync
|
|
31693
|
+
const number = await this.resolveLIDToPNForSending(baileyCleanNumber(`${numberIn}`));
|
|
31682
31694
|
if (options.buttons?.length)
|
|
31683
31695
|
return this.sendButtons(number, message, options.buttons);
|
|
31684
31696
|
if (options.media)
|
|
@@ -31978,7 +31990,7 @@ class BaileysProvider extends ProviderClass {
|
|
|
31978
31990
|
rawIdentifier = key.participantAlt || key.participant || '';
|
|
31979
31991
|
isOriginallyLID = rawIdentifier.includes('@lid');
|
|
31980
31992
|
}
|
|
31981
|
-
// For DMs: prioritize remoteJidAlt over remoteJid
|
|
31993
|
+
// For DMs: prioritize remoteJidAlt over remoteJid
|
|
31982
31994
|
else if (key?.remoteJid || key?.remoteJidAlt) {
|
|
31983
31995
|
rawIdentifier = key.remoteJidAlt || key.remoteJid || '';
|
|
31984
31996
|
isOriginallyLID = rawIdentifier.includes('@lid');
|
|
@@ -32036,6 +32048,61 @@ class BaileysProvider extends ProviderClass {
|
|
|
32036
32048
|
};
|
|
32037
32049
|
}
|
|
32038
32050
|
}
|
|
32051
|
+
/**
|
|
32052
|
+
* CRITICAL FIX for Baileys v7.0.0+ LID sync issues
|
|
32053
|
+
* Resolves LID to PN for outgoing messages to ensure they appear in WhatsApp app
|
|
32054
|
+
*
|
|
32055
|
+
* Issue: Messages sent to LIDs from linked devices don't sync to main WhatsApp app
|
|
32056
|
+
* Solution: Convert LIDs to PNs when sending messages (keep LIDs for receiving)
|
|
32057
|
+
*
|
|
32058
|
+
* @param identifier The identifier to resolve (LID or PN)
|
|
32059
|
+
* @returns PN format for reliable message sending
|
|
32060
|
+
*/
|
|
32061
|
+
async resolveLIDToPNForSending(identifier) {
|
|
32062
|
+
try {
|
|
32063
|
+
// If it's already a PN, return as-is
|
|
32064
|
+
if (identifier.includes('@s.whatsapp.net')) {
|
|
32065
|
+
return identifier;
|
|
32066
|
+
}
|
|
32067
|
+
// If it's a LID, try to resolve to PN using LID store
|
|
32068
|
+
if (identifier.includes('@lid')) {
|
|
32069
|
+
const lidStore = this.getLIDMappingStore();
|
|
32070
|
+
if (lidStore) {
|
|
32071
|
+
try {
|
|
32072
|
+
const pn = await this.getPNFromLID(identifier);
|
|
32073
|
+
if (pn) {
|
|
32074
|
+
this.logger.log(`[${new Date().toISOString()}] 🔄 Resolved LID ${identifier} to PN ${pn} for sending (sync fix)`);
|
|
32075
|
+
return pn;
|
|
32076
|
+
}
|
|
32077
|
+
else {
|
|
32078
|
+
this.logger.log(`[${new Date().toISOString()}] ⚠️ No PN mapping found for LID ${identifier}, using LID (may not sync)`);
|
|
32079
|
+
}
|
|
32080
|
+
}
|
|
32081
|
+
catch (error) {
|
|
32082
|
+
this.logger.log(`[${new Date().toISOString()}] ❌ Error resolving LID to PN:`, error);
|
|
32083
|
+
}
|
|
32084
|
+
}
|
|
32085
|
+
}
|
|
32086
|
+
// If it's a group, return as-is
|
|
32087
|
+
if (identifier.includes('@g.us')) {
|
|
32088
|
+
return identifier;
|
|
32089
|
+
}
|
|
32090
|
+
// For raw numbers, format as PN
|
|
32091
|
+
const cleaned = identifier.replace(/[^\d]/g, '');
|
|
32092
|
+
if (cleaned.length >= 10) {
|
|
32093
|
+
const pn = `${cleaned}@s.whatsapp.net`;
|
|
32094
|
+
this.logger.log(`[${new Date().toISOString()}] 📞 Formatted raw number ${identifier} as PN ${pn}`);
|
|
32095
|
+
return pn;
|
|
32096
|
+
}
|
|
32097
|
+
// Fallback: return original identifier
|
|
32098
|
+
this.logger.log(`[${new Date().toISOString()}] ⚠️ Using original identifier ${identifier} for sending`);
|
|
32099
|
+
return identifier;
|
|
32100
|
+
}
|
|
32101
|
+
catch (error) {
|
|
32102
|
+
this.logger.log(`[${new Date().toISOString()}] ❌ Error in resolveLIDToPNForSending:`, error);
|
|
32103
|
+
return identifier;
|
|
32104
|
+
}
|
|
32105
|
+
}
|
|
32039
32106
|
shouldReconnect(statusCode) {
|
|
32040
32107
|
// Lista de códigos donde SÍ debemos reconectar
|
|
32041
32108
|
const reconnectableCodes = [
|
|
@@ -32089,12 +32156,8 @@ class BaileysProvider extends ProviderClass {
|
|
|
32089
32156
|
let hasDeviceIndexKey = false;
|
|
32090
32157
|
if (state.keys && typeof state.keys === 'object') {
|
|
32091
32158
|
const keyNames = Object.keys(state.keys);
|
|
32092
|
-
hasLidMappingKey = keyNames.some(key => key === 'lid-mapping' ||
|
|
32093
|
-
|
|
32094
|
-
key.includes('lid-map'));
|
|
32095
|
-
hasDeviceIndexKey = keyNames.some(key => key === 'device-index' ||
|
|
32096
|
-
key === 'deviceIndex' ||
|
|
32097
|
-
key.includes('device-index'));
|
|
32159
|
+
hasLidMappingKey = keyNames.some((key) => key === 'lid-mapping' || key === 'lidMapping' || key.includes('lid-map'));
|
|
32160
|
+
hasDeviceIndexKey = keyNames.some((key) => key === 'device-index' || key === 'deviceIndex' || key.includes('device-index'));
|
|
32098
32161
|
}
|
|
32099
32162
|
// Critical validation as per official docs
|
|
32100
32163
|
if (!hasLidMappingKey) {
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,gBAAgB,GAAU,UAAU,MAAM,qBAM1C,CAAA;AAEN;;;;;;;GAOG;AACH,iBAAS,wBAAwB,CAAC,GAAG,EAAE;IACn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AAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYzG,CAAA;AAED;;;;;;GAMG;AACH,QAAA,MAAM,uBAAuB,GAAU,UAAU,GAAG,EAAE,KAAK,MAAM,EAAE,aAAa,MAAM,KAAG,OAAO,CAAC,IAAI,CAUpG,CAAA;AAED;;;;;GAKG;AACH,QAAA,MAAM,wBAAwB,GAAU,UAAU,GAAG,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,OAAO,CAAC,IAAI,CAUrG,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,OAElC,CAAA;AAED;;;;GAIG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,OAEjC,CAAA;AAED,OAAO,EACH,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,WAAW,EACX,UAAU,GACb,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builderbot/provider-baileys",
|
|
3
|
-
"version": "1.3.5
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Now I'm the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin' letters to relatives / Embellishin' my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Leifer Mendez <leifer33@gmail.com>",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"node-cache": "^5.1.2",
|
|
78
78
|
"sharp": "0.33.3"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "4c74df38a91308e9d8eb1efed8842fb9fdfcfb79"
|
|
81
81
|
}
|