@skyzopedia/baileys-mod 5.0.3 → 5.0.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/lib/Socket/socket.js +22 -1
- package/package.json +1 -1
package/lib/Socket/socket.js
CHANGED
|
@@ -210,6 +210,25 @@ export const makeSocket = (config) => {
|
|
|
210
210
|
const { creds } = authState;
|
|
211
211
|
const keys = addTransactionCapability(authState.keys, logger, transactionOpts);
|
|
212
212
|
const signalRepository = makeSignalRepository({ creds, keys }, logger, pnFromLIDUSync);
|
|
213
|
+
const toLid = async (pn) => {
|
|
214
|
+
if (pn.includes("@lid")) return pn
|
|
215
|
+
try {
|
|
216
|
+
return signalRepository.lidMapping.getLIDForPN(pn)
|
|
217
|
+
} catch (err) {
|
|
218
|
+
logger.error({ err }, "error jid unknown");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const toPn = async (pn) => {
|
|
222
|
+
if (pn.includes("@s.whatsapp.net") || pn.includes("@g.us") || pn.includes("@newsletter")) return pn
|
|
223
|
+
try {
|
|
224
|
+
const jid = await signalRepository.lidMapping.getPNForLID(pn)
|
|
225
|
+
const server = "@" + jid.split("@")[1]
|
|
226
|
+
const pN = jid.split(":")[0] + server
|
|
227
|
+
return pN.toString()
|
|
228
|
+
} catch (err) {
|
|
229
|
+
logger.error({ err }, "error lid unknown");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
213
232
|
let lastDateRecv;
|
|
214
233
|
let epoch = 1;
|
|
215
234
|
let keepAliveReq;
|
|
@@ -769,7 +788,9 @@ export const makeSocket = (config) => {
|
|
|
769
788
|
waitForConnectionUpdate: bindWaitForConnectionUpdate(ev),
|
|
770
789
|
sendWAMBuffer,
|
|
771
790
|
executeUSyncQuery,
|
|
772
|
-
onWhatsApp
|
|
791
|
+
onWhatsApp,
|
|
792
|
+
toLid,
|
|
793
|
+
toPn
|
|
773
794
|
};
|
|
774
795
|
};
|
|
775
796
|
//=======================================================//
|