From b7859461e0dd71cb22f0c4fcfa6cd22d860adab6 Mon Sep 17 00:00:00 2001 From: Wilmer ofc <134551880+Wilsmac@users.noreply.github.com> Date: Sun, 27 Oct 2024 09:28:21 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9D=91=BE=F0=9D=92=8A=F0=9D=92=8D?= =?UTF-8?q?=F0=9D=92=8E=F0=9D=92=86=F0=9D=92=93=20=F0=9D=92=90=F0=9D=92=87?= =?UTF-8?q?=F0=9D=92=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 807b11e..8e71c92 100644 --- a/main.js +++ b/main.js @@ -190,7 +190,7 @@ keys: makeCacheableSignalKeyStore(state.keys, Pino({ level: "fatal" }).child({ l }, markOnlineOnConnect: true, generateHighQualityLinkPreview: true, -syncFullHistory: true, +syncFullHistory: false, getMessage: async (clave) => { let jid = jidNormalizedUser(clave.remoteJid) let msg = await store.loadMessage(jid, clave.id) @@ -199,7 +199,7 @@ return msg?.message || "" msgRetryCounterCache, // Resolver mensajes en espera msgRetryCounterMap, // Determinar si se debe volver a intentar enviar un mensaje o no defaultQueryTimeoutMs: undefined, -version: [2, 2513, 1], +version: [2, 3000, 1015901307], } global.conn = makeWASocket(connectionOptions) if (!fs.existsSync(`./${authFile}/creds.json`)) { @@ -213,7 +213,10 @@ addNumber = phoneNumber.replace(/[^0-9]/g, '') do { phoneNumber = await question(chalk.bgBlack(chalk.bold.greenBright(mid.phNumber2(chalk)))) phoneNumber = phoneNumber.replace(/\D/g,'') -} while (!Object.keys(PHONENUMBER_MCC).some(v => phoneNumber.startsWith(v))) +if (!phoneNumber.startsWith('+')) { +phoneNumber = `+${phoneNumber}` +} +} while (!await isValidPhoneNumber(phoneNumber)) rl.close() addNumber = phoneNumber.replace(/\D/g, '') setTimeout(async () => { @@ -545,3 +548,18 @@ unwatchFile(file) console.log(chalk.bold.greenBright(lenguajeCD['smsMainBot']().trim())) import(`${file}?update=${Date.now()}`) }) + +async function isValidPhoneNumber(number) { +try { +number = number.replace(/\s+/g, '') +// Si el nĂºmero empieza con '+521' o '+52 1', quitar el '1' +if (number.startsWith('+521')) { +number = number.replace('+521', '+52'); // Cambiar +521 a +52 +} else if (number.startsWith('+52') && number[4] === '1') { +number = number.replace('+52 1', '+52'); // Cambiar +52 1 a +52 +} +const parsedNumber = phoneUtil.parseAndKeepRawInput(number) +return phoneUtil.isValidNumber(parsedNumber) +} catch (error) { +return false +}}