diff --git a/controllers/send.js b/controllers/send.js
index 81299ba..99a8e5e 100644
--- a/controllers/send.js
+++ b/controllers/send.js
@@ -73,7 +73,7 @@ const sendMessage = async (client, number = null, text = null, regla) => { //MOD
else{wwebjs.sendMessage(client, number, text, regla)}
// client.sendMessage(number, message);
// console.log(number, message, regla)
- await readChat(number, message, regla) //MOD by CHV - Agregamos el parametro "regla"
+ await readChat(number, text, regla) //MOD by CHV - Agregamos el parametro "regla"
console.log(`⚡⚡⚡ Enviando mensajes....`);
// console.log("********************* SEND MESSAGE **************************************");
},DELAY_TIME)
@@ -88,7 +88,7 @@ const sendMessageButton = async (client, number = null, text = null, actionButto
if(provider === 'baileys'){baileys.sendMessageButton(client, number, text, actionButtons)}
else{wwebjs.sendMessageButton(client, number, text, actionButtons)}
// number = cleanNumber(number)
- // const { title = null, message = null, footer = null, buttons = [] } = actionButtons;
+ const { title = null, message = null, footer = null, buttons = [] } = actionButtons;
// let button = new Buttons(remplazos(message, client),[...buttons], remplazos(title, client), remplazos(footer, client));
await readChat(number, message)
// client.sendMessage(number, button);
@@ -111,7 +111,7 @@ const sendMessageList = async (client, number = null, text = null, actionList) =
if(provider === 'baileys'){baileys.sendMessageList(client, number, text, actionList)}
else{wwebjs.sendMessageList(client, number, text, actionList)}
// client.sendMessage(number, aList);
- await readChat(number, message)
+ await readChat(number, text)
// console.log('⚡⚡⚡ Enviando lista a '+number+' ....');
}, DELAY_TIME)
}
diff --git a/controllers/send_wwebjs.js b/controllers/send_wwebjs.js
index 59b226a..11d520b 100644
--- a/controllers/send_wwebjs.js
+++ b/controllers/send_wwebjs.js
@@ -105,8 +105,8 @@ const sendMessageButton = async (client, number, text = null, actionButtons) =>
[...buttons],
remplazos(title, client),
remplazos(footer, client));
- console.log("sendMessageButton:", button)
- console.log(buttons)
+ console.log("sendMessageButton wwebjs:", button)
+ console.log(button.buttons)
client.sendMessage(number, button);
await readChat(number, message)
}, DELAY_TIME)
diff --git a/package-lock.json b/package-lock.json
index faecd8f..84060cb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -30,7 +30,7 @@
"socket.io": "^4.5.1",
"stormdb": "^0.6.0",
"util-tiempo": "^1.0.41",
- "whatsapp-web.js": "^1.19.4",
+ "whatsapp-web.js": "github:cheveguerra/whatsapp-web.js#WaWJS2",
"xlsx": "^0.18.5"
},
"devDependencies": {
@@ -100,19 +100,6 @@
"node": ">=6.0.0"
}
},
- "node_modules/@babel/runtime": {
- "version": "7.21.0",
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz",
- "integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "regenerator-runtime": "^0.13.11"
- },
- "engines": {
- "node": ">=6.9.0"
- }
- },
"node_modules/@fast-csv/format": {
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/@fast-csv/format/-/format-4.3.5.tgz",
@@ -222,574 +209,10 @@
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz",
"integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ=="
},
- "node_modules/@jimp/bmp": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/bmp/-/bmp-0.16.13.tgz",
- "integrity": "sha512-9edAxu7N2FX7vzkdl5Jo1BbACfycUtBQX+XBMcHA2bk62P8R0otgkHg798frgAk/WxQIzwxqOH6wMiCwrlAzdQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "bmp-js": "^0.1.0"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/core": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/core/-/core-0.16.13.tgz",
- "integrity": "sha512-qXpA1tzTnlkTku9yqtuRtS/wVntvE6f3m3GNxdTdtmc+O+Wcg9Xo2ABPMh7Nc0AHbMKzwvwgB2JnjZmlmJEObg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "any-base": "^1.1.0",
- "buffer": "^5.2.0",
- "exif-parser": "^0.1.12",
- "file-type": "^16.5.4",
- "load-bmfont": "^1.3.1",
- "mkdirp": "^0.5.1",
- "phin": "^2.9.1",
- "pixelmatch": "^4.0.2",
- "tinycolor2": "^1.4.1"
- }
- },
- "node_modules/@jimp/core/node_modules/file-type": {
- "version": "16.5.4",
- "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz",
- "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "readable-web-to-node-stream": "^3.0.0",
- "strtok3": "^6.2.4",
- "token-types": "^4.1.1"
- },
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "url": "https://github.com/sindresorhus/file-type?sponsor=1"
- }
- },
- "node_modules/@jimp/core/node_modules/mkdirp": {
- "version": "0.5.6",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
- "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "minimist": "^1.2.6"
- },
- "bin": {
- "mkdirp": "bin/cmd.js"
- }
- },
- "node_modules/@jimp/core/node_modules/peek-readable": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz",
- "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==",
- "optional": true,
- "peer": true,
- "engines": {
- "node": ">=8"
- },
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/Borewit"
- }
- },
- "node_modules/@jimp/core/node_modules/strtok3": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz",
- "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@tokenizer/token": "^0.3.0",
- "peek-readable": "^4.1.0"
- },
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/Borewit"
- }
- },
- "node_modules/@jimp/core/node_modules/token-types": {
- "version": "4.2.1",
- "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz",
- "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@tokenizer/token": "^0.3.0",
- "ieee754": "^1.2.1"
- },
- "engines": {
- "node": ">=10"
- },
- "funding": {
- "type": "github",
- "url": "https://github.com/sponsors/Borewit"
- }
- },
- "node_modules/@jimp/custom": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/custom/-/custom-0.16.13.tgz",
- "integrity": "sha512-LTATglVUPGkPf15zX1wTMlZ0+AU7cGEGF6ekVF1crA8eHUWsGjrYTB+Ht4E3HTrCok8weQG+K01rJndCp/l4XA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/core": "^0.16.13"
- }
- },
- "node_modules/@jimp/gif": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/gif/-/gif-0.16.13.tgz",
- "integrity": "sha512-yFAMZGv3o+YcjXilMWWwS/bv1iSqykFahFMSO169uVMtfQVfa90kt4/kDwrXNR6Q9i6VHpFiGZMlF2UnHClBvg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "gifwrap": "^0.9.2",
- "omggif": "^1.0.9"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/jpeg": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/jpeg/-/jpeg-0.16.13.tgz",
- "integrity": "sha512-BJHlDxzTlCqP2ThqP8J0eDrbBfod7npWCbJAcfkKqdQuFk0zBPaZ6KKaQKyKxmWJ87Z6ohANZoMKEbtvrwz1AA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "jpeg-js": "^0.4.2"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-blit": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-blit/-/plugin-blit-0.16.13.tgz",
- "integrity": "sha512-8Z1k96ZFxlhK2bgrY1JNWNwvaBeI/bciLM0yDOni2+aZwfIIiC7Y6PeWHTAvjHNjphz+XCt01WQmOYWCn0ML6g==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-blur": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-blur/-/plugin-blur-0.16.13.tgz",
- "integrity": "sha512-PvLrfa8vkej3qinlebyhLpksJgCF5aiysDMSVhOZqwH5nQLLtDE9WYbnsofGw4r0VVpyw3H/ANCIzYTyCtP9Cg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-circle": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-circle/-/plugin-circle-0.16.13.tgz",
- "integrity": "sha512-RNave7EFgZrb5V5EpdvJGAEHMnDAJuwv05hKscNfIYxf0kR3KhViBTDy+MoTnMlIvaKFULfwIgaZWzyhuINMzA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-color": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-color/-/plugin-color-0.16.13.tgz",
- "integrity": "sha512-xW+9BtEvoIkkH/Wde9ql4nAFbYLkVINhpgAE7VcBUsuuB34WUbcBl/taOuUYQrPEFQJ4jfXiAJZ2H/rvKjCVnQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "tinycolor2": "^1.4.1"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-contain": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-contain/-/plugin-contain-0.16.13.tgz",
- "integrity": "sha512-QayTXw4tXMwU6q6acNTQrTTFTXpNRBe+MgTGMDU0lk+23PjlFCO/9sacflelG8lsp7vNHhAxFeHptDMAksEYzg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-blit": ">=0.3.5",
- "@jimp/plugin-resize": ">=0.3.5",
- "@jimp/plugin-scale": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-cover": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-cover/-/plugin-cover-0.16.13.tgz",
- "integrity": "sha512-BSsP71GTNaqWRcvkbWuIVH+zK7b3TSNebbhDkFK0fVaUTzHuKMS/mgY4hDZIEVt7Rf5FjadAYtsujHN9w0iSYA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-crop": ">=0.3.5",
- "@jimp/plugin-resize": ">=0.3.5",
- "@jimp/plugin-scale": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-crop": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-crop/-/plugin-crop-0.16.13.tgz",
- "integrity": "sha512-WEl2tPVYwzYL8OKme6Go2xqiWgKsgxlMwyHabdAU4tXaRwOCnOI7v4021gCcBb9zn/oWwguHuKHmK30Fw2Z/PA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-displace": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-displace/-/plugin-displace-0.16.13.tgz",
- "integrity": "sha512-qt9WKq8vWrcjySa9DyQ0x/RBMHQeiVjdVSY1SJsMjssPUf0pS74qorcuAkGi89biN3YoGUgPkpqECnAWnYwgGA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-dither": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-dither/-/plugin-dither-0.16.13.tgz",
- "integrity": "sha512-5/N3yJggbWQTlGZHQYJPmQXEwR52qaXjEzkp1yRBbtdaekXE3BG/suo0fqeoV/csf8ooI78sJzYmIrxNoWVtgQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-fisheye": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-fisheye/-/plugin-fisheye-0.16.13.tgz",
- "integrity": "sha512-2rZmTdFbT/cF9lEZIkXCYO0TsT114Q27AX5IAo0Sju6jVQbvIk1dFUTnwLDadTo8wkJlFzGqMQ24Cs8cHWOliA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-flip": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-flip/-/plugin-flip-0.16.13.tgz",
- "integrity": "sha512-EmcgAA74FTc5u7Z+hUO/sRjWwfPPLuOQP5O64x5g4j0T12Bd29IgsYZxoutZo/rb3579+JNa/3wsSEmyVv1EpA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-rotate": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-gaussian": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-gaussian/-/plugin-gaussian-0.16.13.tgz",
- "integrity": "sha512-A1XKfGQD0iDdIiKqFYi8nZMv4dDVYdxbrmgR7y/CzUHhSYdcmoljLIIsZZM3Iks/Wa353W3vtvkWLuDbQbch1w==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-invert": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-invert/-/plugin-invert-0.16.13.tgz",
- "integrity": "sha512-xFMrIn7czEZbdbMzZWuaZFnlLGJDVJ82y5vlsKsXRTG2kcxRsMPXvZRWHV57nSs1YFsNqXSbrC8B98n0E32njQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-mask": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-mask/-/plugin-mask-0.16.13.tgz",
- "integrity": "sha512-wLRYKVBXql2GAYgt6FkTnCfE+q5NomM7Dlh0oIPGAoMBWDyTx0eYutRK6PlUrRK2yMHuroAJCglICTbxqGzowQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-normalize": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-normalize/-/plugin-normalize-0.16.13.tgz",
- "integrity": "sha512-3tfad0n9soRna4IfW9NzQdQ2Z3ijkmo21DREHbE6CGcMIxOSvfRdSvf1qQPApxjTSo8LTU4MCi/fidx/NZ0GqQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-print": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-print/-/plugin-print-0.16.13.tgz",
- "integrity": "sha512-0m6i3p01PGRkGAK9r53hDYrkyMq+tlhLOIbsSTmZyh6HLshUKlTB7eXskF5OpVd5ZUHoltlNc6R+ggvKIzxRFw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "load-bmfont": "^1.4.0"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-blit": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-resize": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-0.16.13.tgz",
- "integrity": "sha512-qoqtN8LDknm3fJm9nuPygJv30O3vGhSBD2TxrsCnhtOsxKAqVPJtFVdGd/qVuZ8nqQANQmTlfqTiK9mVWQ7MiQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-rotate": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-rotate/-/plugin-rotate-0.16.13.tgz",
- "integrity": "sha512-Ev+Jjmj1nHYw897z9C3R9dYsPv7S2/nxdgfFb/h8hOwK0Ovd1k/+yYS46A0uj/JCKK0pQk8wOslYBkPwdnLorw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-blit": ">=0.3.5",
- "@jimp/plugin-crop": ">=0.3.5",
- "@jimp/plugin-resize": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-scale": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-scale/-/plugin-scale-0.16.13.tgz",
- "integrity": "sha512-05POQaEJVucjTiSGMoH68ZiELc7QqpIpuQlZ2JBbhCV+WCbPFUBcGSmE7w4Jd0E2GvCho/NoMODLwgcVGQA97A==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-resize": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-shadow": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-shadow/-/plugin-shadow-0.16.13.tgz",
- "integrity": "sha512-nmu5VSZ9hsB1JchTKhnnCY+paRBnwzSyK5fhkhtQHHoFD5ArBQ/5wU8y6tCr7k/GQhhGq1OrixsECeMjPoc8Zw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-blur": ">=0.3.5",
- "@jimp/plugin-resize": ">=0.3.5"
- }
- },
- "node_modules/@jimp/plugin-threshold": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugin-threshold/-/plugin-threshold-0.16.13.tgz",
- "integrity": "sha512-+3zArBH0OE3Rhjm4HyAokMsZlIq5gpQec33CncyoSwxtRBM2WAhUVmCUKuBo+Lr/2/4ISoY4BWpHKhMLDix6cA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5",
- "@jimp/plugin-color": ">=0.8.0",
- "@jimp/plugin-resize": ">=0.8.0"
- }
- },
- "node_modules/@jimp/plugins": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/plugins/-/plugins-0.16.13.tgz",
- "integrity": "sha512-CJLdqODEhEVs4MgWCxpWL5l95sCBlkuSLz65cxEm56X5akIsn4LOlwnKoSEZioYcZUBvHhCheH67AyPTudfnQQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/plugin-blit": "^0.16.13",
- "@jimp/plugin-blur": "^0.16.13",
- "@jimp/plugin-circle": "^0.16.13",
- "@jimp/plugin-color": "^0.16.13",
- "@jimp/plugin-contain": "^0.16.13",
- "@jimp/plugin-cover": "^0.16.13",
- "@jimp/plugin-crop": "^0.16.13",
- "@jimp/plugin-displace": "^0.16.13",
- "@jimp/plugin-dither": "^0.16.13",
- "@jimp/plugin-fisheye": "^0.16.13",
- "@jimp/plugin-flip": "^0.16.13",
- "@jimp/plugin-gaussian": "^0.16.13",
- "@jimp/plugin-invert": "^0.16.13",
- "@jimp/plugin-mask": "^0.16.13",
- "@jimp/plugin-normalize": "^0.16.13",
- "@jimp/plugin-print": "^0.16.13",
- "@jimp/plugin-resize": "^0.16.13",
- "@jimp/plugin-rotate": "^0.16.13",
- "@jimp/plugin-scale": "^0.16.13",
- "@jimp/plugin-shadow": "^0.16.13",
- "@jimp/plugin-threshold": "^0.16.13",
- "timm": "^1.6.1"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/png": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/png/-/png-0.16.13.tgz",
- "integrity": "sha512-8cGqINvbWJf1G0Her9zbq9I80roEX0A+U45xFby3tDWfzn+Zz8XKDF1Nv9VUwVx0N3zpcG1RPs9hfheG4Cq2kg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/utils": "^0.16.13",
- "pngjs": "^3.3.3"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/tiff": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/tiff/-/tiff-0.16.13.tgz",
- "integrity": "sha512-oJY8d9u95SwW00VPHuCNxPap6Q1+E/xM5QThb9Hu+P6EGuu6lIeLaNBMmFZyblwFbwrH+WBOZlvIzDhi4Dm/6Q==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "utif": "^2.0.1"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/types": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/types/-/types-0.16.13.tgz",
- "integrity": "sha512-mC0yVNUobFDjoYLg4hoUwzMKgNlxynzwt3cDXzumGvRJ7Kb8qQGOWJQjQFo5OxmGExqzPphkirdbBF88RVLBCg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/bmp": "^0.16.13",
- "@jimp/gif": "^0.16.13",
- "@jimp/jpeg": "^0.16.13",
- "@jimp/png": "^0.16.13",
- "@jimp/tiff": "^0.16.13",
- "timm": "^1.6.1"
- },
- "peerDependencies": {
- "@jimp/custom": ">=0.3.5"
- }
- },
- "node_modules/@jimp/utils": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/@jimp/utils/-/utils-0.16.13.tgz",
- "integrity": "sha512-VyCpkZzFTHXtKgVO35iKN0sYR10psGpV6SkcSeV4oF7eSYlR8Bl6aQLCzVeFjvESF7mxTmIiI3/XrMobVrtxDA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@babel/runtime": "^7.7.2",
- "regenerator-runtime": "^0.13.3"
- }
- },
"node_modules/@jsdoc/salty": {
- "version": "0.2.3",
- "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.3.tgz",
- "integrity": "sha512-bbtCxCkxcnWhi50I+4Lj6mdz9w3pOXOgEQrID8TCZ/DF51fW7M9GCQW2y45SpBDdHd1Eirm1X/Cf6CkAAe8HPg==",
+ "version": "0.2.4",
+ "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.4.tgz",
+ "integrity": "sha512-HRBmslXHM6kpZOfGf0o41NUlGYGER0NoUBcT2Sik4rxzAN7f7+si7ad57SFSFpftvaMVnUaY7YlJuv3v5G80ZA==",
"dependencies": {
"lodash": "^4.17.21"
},
@@ -1451,13 +874,6 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
- "node_modules/any-base": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/any-base/-/any-base-1.1.0.tgz",
- "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==",
- "optional": true,
- "peer": true
- },
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
@@ -1764,11 +1180,9 @@
"integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA=="
},
"node_modules/bmp-js": {
- "version": "0.1.0",
- "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
- "integrity": "sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==",
- "optional": true,
- "peer": true
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.0.1.tgz",
+ "integrity": "sha512-OS74Rlt0Aynu2mTPmY9RZOUOXlqWecFIILFXr70vv16/xCZnFxvri9IKkF1IGxQ8r9dOE62qGNpKxXx8Lko8bg=="
},
"node_modules/bodec": {
"version": "0.1.0",
@@ -2062,46 +1476,6 @@
"node": ">= 6"
}
},
- "node_modules/combine-image/node_modules/bmp-js": {
- "version": "0.0.1",
- "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.0.1.tgz",
- "integrity": "sha512-OS74Rlt0Aynu2mTPmY9RZOUOXlqWecFIILFXr70vv16/xCZnFxvri9IKkF1IGxQ8r9dOE62qGNpKxXx8Lko8bg=="
- },
- "node_modules/combine-image/node_modules/file-type": {
- "version": "3.9.0",
- "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
- "integrity": "sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==",
- "engines": {
- "node": ">=0.10.0"
- }
- },
- "node_modules/combine-image/node_modules/jimp": {
- "version": "0.2.27",
- "resolved": "https://registry.npmjs.org/jimp/-/jimp-0.2.27.tgz",
- "integrity": "sha512-KP08kEe5pDY+AFg00vuqKP0zgUmeQXJXpzQ+w9+0pQA27GCF9RoWzOpf3AONHgf5h8raMrXaF18y4ug9Rw2xEw==",
- "dependencies": {
- "bignumber.js": "^2.1.0",
- "bmp-js": "0.0.1",
- "es6-promise": "^3.0.2",
- "exif-parser": "^0.1.9",
- "file-type": "^3.1.0",
- "jpeg-js": "^0.2.0",
- "load-bmfont": "^1.2.3",
- "mime": "^1.3.4",
- "pixelmatch": "^4.0.0",
- "pngjs": "^3.0.0",
- "read-chunk": "^1.0.1",
- "request": "^2.65.0",
- "stream-to-buffer": "^0.1.0",
- "tinycolor2": "^1.1.2",
- "url-regex": "^3.0.0"
- }
- },
- "node_modules/combine-image/node_modules/jpeg-js": {
- "version": "0.2.0",
- "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.2.0.tgz",
- "integrity": "sha512-Ni9PffhJtYtdD7VwxH6V2MnievekGfUefosGCHadog0/jAevRu6HPjYeMHbUemn0IPE8d4wGa8UsOGsX+iKy2g=="
- },
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
@@ -3245,17 +2619,6 @@
"assert-plus": "^1.0.0"
}
},
- "node_modules/gifwrap": {
- "version": "0.9.4",
- "resolved": "https://registry.npmjs.org/gifwrap/-/gifwrap-0.9.4.tgz",
- "integrity": "sha512-MDMwbhASQuVeD4JKd1fKgNgCRL3fGqMM4WaqpNhWO0JiMOAjbQdumbs4BbBZEy9/M00EHEjKN3HieVhCUlwjeQ==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "image-q": "^4.0.0",
- "omggif": "^1.0.10"
- }
- },
"node_modules/git-node-fs": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/git-node-fs/-/git-node-fs-1.0.0.tgz",
@@ -3813,23 +3176,6 @@
}
]
},
- "node_modules/image-q": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/image-q/-/image-q-4.0.0.tgz",
- "integrity": "sha512-PfJGVgIfKQJuq3s0tTDOKtztksibuUEbJQIYT3by6wctQo+Rdlh7ef4evJ5NCdxY4CfMbvFkocEwbl4BF8RlJw==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "@types/node": "16.9.1"
- }
- },
- "node_modules/image-q/node_modules/@types/node": {
- "version": "16.9.1",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz",
- "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==",
- "optional": true,
- "peer": true
- },
"node_modules/immediate": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
@@ -3989,25 +3335,39 @@
"integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g=="
},
"node_modules/jimp": {
- "version": "0.16.13",
- "resolved": "https://registry.npmjs.org/jimp/-/jimp-0.16.13.tgz",
- "integrity": "sha512-Bxz8q7V4rnCky9A0ktTNGA9SkNFVWRHodddI/DaAWZJzF7sVUlFYKQ60y9JGqrKpi48ECA/TnfMzzc5C70VByA==",
- "optional": true,
- "peer": true,
+ "version": "0.2.27",
+ "resolved": "https://registry.npmjs.org/jimp/-/jimp-0.2.27.tgz",
+ "integrity": "sha512-KP08kEe5pDY+AFg00vuqKP0zgUmeQXJXpzQ+w9+0pQA27GCF9RoWzOpf3AONHgf5h8raMrXaF18y4ug9Rw2xEw==",
"dependencies": {
- "@babel/runtime": "^7.7.2",
- "@jimp/custom": "^0.16.13",
- "@jimp/plugins": "^0.16.13",
- "@jimp/types": "^0.16.13",
- "regenerator-runtime": "^0.13.3"
+ "bignumber.js": "^2.1.0",
+ "bmp-js": "0.0.1",
+ "es6-promise": "^3.0.2",
+ "exif-parser": "^0.1.9",
+ "file-type": "^3.1.0",
+ "jpeg-js": "^0.2.0",
+ "load-bmfont": "^1.2.3",
+ "mime": "^1.3.4",
+ "pixelmatch": "^4.0.0",
+ "pngjs": "^3.0.0",
+ "read-chunk": "^1.0.1",
+ "request": "^2.65.0",
+ "stream-to-buffer": "^0.1.0",
+ "tinycolor2": "^1.1.2",
+ "url-regex": "^3.0.0"
+ }
+ },
+ "node_modules/jimp/node_modules/file-type": {
+ "version": "3.9.0",
+ "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
+ "integrity": "sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==",
+ "engines": {
+ "node": ">=0.10.0"
}
},
"node_modules/jpeg-js": {
- "version": "0.4.4",
- "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.4.tgz",
- "integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==",
- "optional": true,
- "peer": true
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.2.0.tgz",
+ "integrity": "sha512-Ni9PffhJtYtdD7VwxH6V2MnievekGfUefosGCHadog0/jAevRu6HPjYeMHbUemn0IPE8d4wGa8UsOGsX+iKy2g=="
},
"node_modules/js-git": {
"version": "0.7.8",
@@ -4916,13 +4276,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/omggif": {
- "version": "1.0.10",
- "resolved": "https://registry.npmjs.org/omggif/-/omggif-1.0.10.tgz",
- "integrity": "sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==",
- "optional": true,
- "peer": true
- },
"node_modules/on-exit-leak-free": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz",
@@ -5889,13 +5242,6 @@
"node": ">= 12.13.0"
}
},
- "node_modules/regenerator-runtime": {
- "version": "0.13.11",
- "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
- "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
- "optional": true,
- "peer": true
- },
"node_modules/request": {
"version": "2.88.2",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
@@ -6603,9 +5949,9 @@
}
},
"node_modules/systeminformation": {
- "version": "5.17.10",
- "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.17.10.tgz",
- "integrity": "sha512-FUm264baeDpruTw4P50BRRmYHD39D3jkOQ0VpNIkp8CdNejQbsp4Me18jacGBc/mWSVxKdQw4wSHmcL7ERxrNg==",
+ "version": "5.17.12",
+ "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.17.12.tgz",
+ "integrity": "sha512-I3pfMW2vue53u+X08BNxaJieaHkRoMMKjWetY9lbYJeWFaeWPO6P4FkNc4XOCX8F9vbQ0HqQ25RJoz3U/B7liw==",
"dev": true,
"optional": true,
"os": [
@@ -6668,13 +6014,6 @@
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg=="
},
- "node_modules/timm": {
- "version": "1.7.1",
- "resolved": "https://registry.npmjs.org/timm/-/timm-1.7.1.tgz",
- "integrity": "sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==",
- "optional": true,
- "peer": true
- },
"node_modules/tinycolor2": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz",
@@ -6939,16 +6278,6 @@
"resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz",
"integrity": "sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw=="
},
- "node_modules/utif": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/utif/-/utif-2.0.1.tgz",
- "integrity": "sha512-Z/S1fNKCicQTf375lIP9G8Sa1H/phcysstNrrSdZKj1f9g58J4NMgb5IgiEZN9/nLMPDwF0W7hdOe9Qq2IYoLg==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "pako": "^1.0.5"
- }
- },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -7051,8 +6380,8 @@
},
"node_modules/whatsapp-web.js": {
"version": "1.19.4",
- "resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.19.4.tgz",
- "integrity": "sha512-qwfdauW3rKsI2gzRexFU5y+SumXjuZTidyZXFIXaWfPzMe4ejxAkVoj/u27wyNZDqK3Z8tI/Ac3ZJFG60VgA6w==",
+ "resolved": "git+ssh://git@github.com/cheveguerra/whatsapp-web.js.git#14f7854bb8e19ac64c82e37c7c081337682cd4e7",
+ "license": "Apache-2.0",
"dependencies": {
"@pedroslopez/moduleraid": "^5.0.2",
"fluent-ffmpeg": "^2.1.2",
diff --git a/package.json b/package.json
index 7265f00..56a633c 100644
--- a/package.json
+++ b/package.json
@@ -32,7 +32,7 @@
"socket.io": "^4.5.1",
"stormdb": "^0.6.0",
"util-tiempo": "^1.0.41",
- "whatsapp-web.js": "^1.19.4",
+ "whatsapp-web.js": "github:cheveguerra/whatsapp-web.js#WaWJS2",
"xlsx": "^0.18.5"
},
"devDependencies": {
diff --git a/provider/wwebjs.js b/provider/wwebjs.js
index b4b822f..4c55b6f 100644
--- a/provider/wwebjs.js
+++ b/provider/wwebjs.js
@@ -1,4 +1,5 @@
const { Client, LocalAuth, Buttons, List } = require('whatsapp-web.js');
+const { sendMedia, sendMessage, sendMessageButton, sendMessageList, readChat } = require(`../controllers/send`);
require('dotenv').config()
const express = require('express');
const bodyParser = require("body-parser");
@@ -24,30 +25,27 @@ app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
let socks
+let client
initBot = async () => {
- console.log("WaWebJS Init")
- const client = new Client({
+ console.log("Iniciamos WaWebJS")
+ client = new Client({
authStrategy: new LocalAuth(),
puppeteer: { headless: true, args: ['--no-sandbox','--disable-setuid-sandbox'] }
});
-
client.on('ready', (a) => {
connectionReady()
// listenMessage(client)
// listenMessageFromBot()
// socketEvents.sendStatus(client)
});
-
client.on('auth_failure', (e) => {
// console.log(e)
// connectionLost()
});
-
client.on('authenticated', () => {
console.log('AUTHENTICATED');
});
-
client.initialize();
/**
@@ -58,23 +56,22 @@ initBot = async () => {
mysqlConnection.connect()
}
let waReady = false
- // Socket IO
+ // Socket IO
io.on('connection', async function (socket) {
- console.log("Connecting ...")
+ console.log("Conectando ...")
socket.emit('ioStatus', socketioStatus);
socks = socket
-
- await socket.emit('message', 'Connecting...');
-
+ await socket.emit('message', 'Conectando...');
socket.on('checkConn', async function () { // Si recibe mensaje, regresa "connOk"
console.log("checking conn")
await socket.emit('connOk', 'Connected');
})
try {
- client.on('message', () => {
+ client.on('message', msg => {
+ // console.log(msg)
console.log(waReady)
- socketioStatus = "wa_msg"; socket.emit('ioStatus', socketioStatus);
+ socketioStatus = "wa_msg"; socket.emit('ioStatus', socketioStatus); socket.emit('wa_msg', msg.body);
socket.emit('incomming', 'Message In')
waReady = true
})
@@ -88,8 +85,8 @@ initBot = async () => {
client.on('ready', async () => {
socketioStatus = "wa_ready"
- await socket.emit('ready', 'Whatsapp is ready!');
- await socket.emit('message', 'Whatsapp is ready!');
+ await socket.emit('ready', 'Whatsapp esta listo!');
+ await socket.emit('message', 'Whatsapp esta listo!');
waReady = true
});
@@ -116,20 +113,17 @@ initBot = async () => {
catch (e) {waReady = false }
});
-
server.listen(port, () => {
- console.log(`El server esta listo en el puerto ${port}`);
+ console.log(`El servidor web esta listo en el puerto ${port} - http://localhost:${port}`);
})
-
const phoneNumberFormatter = function (number) {
- // 1. Menghilangkan karakter selain angka
+ // 1. Eliminar caracteres que no sean números
let formatted = number.replace(/\D/g, '');
- // 2. Menghilangkan angka 0 di depan (prefix)
- // Kemudian diganti dengan 62
- if (formatted.startsWith('0')) {
- formatted = '62' + formatted.substr(1);
- }
+ // 2. Eliminar el número 0 del prefijo y reemplazarlo con 62
+ // if (formatted.startsWith('0')) {
+ // formatted = '62' + formatted.substr(1);
+ // }
if (!formatted.endsWith('@c.us')) {
formatted += '@c.us';
@@ -137,35 +131,28 @@ initBot = async () => {
return formatted;
}
-
const checkRegisteredNumber = async function (number) {
const isRegistered = await client.isRegisteredUser(number);
return isRegistered;
}
-
// Send message
app.post('/send-message', [
body('number').notEmpty(),
body('message').notEmpty(),
], async (req, res) => {
-
- console.log("xxxxxxxx", req.body)
-
+ console.log("REQUEST=", req.body)
socks.emit('incomming', 'Message In')
-
const errors = validationResult(req).formatWith(({
msg
}) => {
return msg;
});
-
if (!errors.isEmpty()) {
return res.status(422).json({
status: false,
message: errors.mapped()
});
}
-
const number = phoneNumberFormatter(req.body.number);
const message = req.body.message;
const isRegisteredNumber = await checkRegisteredNumber(number);
@@ -175,7 +162,6 @@ initBot = async () => {
message: 'The number is not registered'
});
}
-
client.sendMessage(number, message).then(response => {
res.status(200).json({
status: true,
@@ -188,7 +174,49 @@ initBot = async () => {
});
});
});
+ // Send buttons
+ app.post('/send-buttons', async (req, res) => {
+ console.log("REQUEST=", req.body)
+ socks.emit('incomming', 'Button In')
+ if (client.theMsg === undefined) {
+ client.theMsg = {}
+ client.theMsg.from = "WEB"
+ client.theMsg.body = "WEB"
+ client.theMsg.name = "WEB"
+ }
+
+ const number = phoneNumberFormatter(req.body.number);
+ const title = req.body.title || null;
+ const btnmsg = req.body.btnmsg;
+ const btn1 = req.body.btn1;
+ const btn2 = req.body.btn2 || null;
+ const btn3 = req.body.btn3 || null;
+ const footer = req.body.footer || null;
+ const isRegisteredNumber = await checkRegisteredNumber(number);
+ if (!isRegisteredNumber) {
+ return res.status(422).json({
+ status: false,
+ message: 'The number is not registered'
+ });
+ }
+ let botones = []
+ botones.push({ body: btn1 })
+ if (btn2 != null) { botones.push({ body: btn2 }) }
+ if (btn3 != null) { botones.push({body: btn3}) }
+ let losBotones = new Buttons(btnmsg, botones, title, footer);
+ client.sendMessage(number, losBotones).then(response => {
+ res.status(200).json({
+ status: true,
+ response: response
+ });
+ }).catch(err => {
+ res.status(500).json({
+ status: false,
+ response: err
+ });
+ });
+ });
checkEnvFile();
return client
diff --git a/public/index.html b/public/index.html
index 71768d7..919ef6d 100644
--- a/public/index.html
+++ b/public/index.html
@@ -47,6 +47,9 @@
color: green;
font-weight: bold;
}
+ ::placeholder {
+ text-align: center;
+ }
@@ -59,20 +62,84 @@
-
+
+
+
+
+
+
@@ -80,7 +147,7 @@
Logs:
-
+