feat: botones

This commit is contained in:
2023-03-01 01:15:06 -06:00
parent d99ab88836
commit f191fbf1fe
6 changed files with 247 additions and 777 deletions

View File

@@ -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)
}

View File

@@ -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)

753
package-lock.json generated
View File

@@ -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",

View File

@@ -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": {

View File

@@ -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

View File

@@ -47,6 +47,9 @@
color: green;
font-weight: bold;
}
::placeholder {
text-align: center;
}
</style>
</head>
@@ -59,20 +62,84 @@
<div id="divQRPage" style="display:none;"></div>
<div id="countdown" style="margin-top:-25px"></div>
<div id="postman" style="display:flex;justify-content:center;">
<table>
<tr>
<td>Número:</td>
<td><input type="text" id="number" value="5215554192439"></td>
</tr>
<tr>
<td>Mensaje:</td>
<td><input type="text" id="message" value="test1"></td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="button" id="btnMessage" value="Enviar Mensaje"></td>
</tr>
</table>
<div>
<select id="tipoMensaje">
<option>Mensaje</option>
<!-- <option>Imagen</option> -->
<option>Botones</option>
</select>
</div>
<div id="postMsg">
<table>
<tr>
<td>Número:</td>
<td><input type="text" id="number" value="5215554192439"></td>
</tr>
<tr>
<td>Mensaje:</td>
<td><input type="text" id="message" value="test1"></td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="button" id="btnMessage" value="Enviar Mensaje"></td>
</tr>
</table>
</div>
<div id="postBtn" style="display:none;">
<table>
<tr>
<td>Número:</td>
<td><input type="text" id="btnnumber" value="5215554192439"></td>
</tr>
<tr>
<td>Titulo:</td>
<td><input type="text" id="btntitle" placeholder="El título"></td>
</tr>
<tr>
<td>Mensaje:</td>
<td><input type="text" id="btnmsg" placeholder="El mensaje"></td>
</tr>
<tr>
<td>Boton 1:</td>
<td><input type="text" id="btn1" placeholder="Texto del botón 1"></td>
</tr>
<tr>
<td>Boton 2:</td>
<td><input type="text" id="btn2" placeholder="Texto del botón 1"></td>
</tr>
<tr>
<td>Boton 3:</td>
<td><input type="text" id="btn3" placeholder="Texto del botón 1"></td>
</tr> <tr>
<td>Footer:</td>
<td><input type="text" id="btnfooter" placeholder="Texto del footer"></td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="button" id="btnBtn" value="Enviar Botones"></td>
</tr>
</table>
</div>
<!-- <div id="postImg">
<table>
<tr>
<td>Número:</td>
<td><input type="text" id="number" value="5215554192439"></td>
</tr>
<tr>
<td>Imagen:</td>
<td><input type="text" id="image" value="test1"></td>
</tr>
<tr>
<td>Texto:</td>
<td><input type="text" id="caption" placeholder="El texto aquí"></td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="button" id="btnImg" value="Enviar Mensaje"></td>
</tr>
</table>
</div> -->
</div>
</div>
<!-- <input type="button" id="chkConn" value="QR"> -->
@@ -80,7 +147,7 @@
<h3>Logs:</h3>
<ul class="logs"></ul>
</div>
<div id="div_wa_msg" style="display: none;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>
<script src="/socket.io/socket.io.js" crossorigin="anonymous"></script>
<script>
@@ -89,21 +156,32 @@
let waReady = false
let IOSTATUS = "NONE"
$(document).ready( function(){
if (waReady == false && IOSTATUS == "wa_ready") { $("#btnMessage").attr("disabled", true) }
$("#postBtn").hide(); $("#postImg").hide();
if (waReady == false && IOSTATUS == "wa_ready") { $("#btnMessage").attr("disabled", true); $("#btnBtn").attr("disabled", true); }
var socket = io();
socket.on('ioStatus', function ( msg ){
IOSTATUS = msg;
console.log("IOSTATUS="+msg);
console.log("XXXXXXXXXXXXX " + IOSTATUS)
if(msg == 'wa_msg') { IOSTATUS = "wa_ready" }
if (IOSTATUS == 'wa_ready') { $("#postman").show(); $("#divQRPage").hide() }
else if (IOSTATUS == 'wa_qr') { $("#divQRPage").show(); loadQR(); $("#postman").hide(); console.log("mostramos QRPage") }
else { $("#divQRPage").hide(); $("#postman").hide(); }
})
socket.on('wa_msg', function( msg ){
$("#div_wa_msg").fadeIn()
$("#div_wa_msg").html(msg)
setTimeout(() => {
$("#div_wa_msg").fadeOut("slow")
}, 1500);
})
socket.on('message', function (msg) {
$('.logs').prepend($('<li>').text(msg));
console.log("|" + msg + "|");
if (msg == 'Connecting...' && IOSTATUS == "wa_ready") { $('#divQRPage').hide(); $('#postman').show(); waReady = false, $("#btnMessage").attr("disabled", true) }
if (msg == 'Whatsapp is ready!') { $("#btnMessage").attr("disabled", false) }
console.log("MENSAJES = " + $(".logs li").length)
if($(".logs li").length >= 15){ $('.logs li').last().remove(); }
if (msg == 'Conectando...' && IOSTATUS == "wa_ready") { $('#divQRPage').hide(); $('#postman').show(); waReady = false, $("#btnMessage").attr("disabled", true); $("#btnBtn").attr("disabled", true); }
if (msg == 'Whatsapp esta listo!') { $("#btnMessage").attr("disabled", false); $("#btnBtn").attr("disabled", false); }
})
socket.on('qr', function (src) {
var extra = Date.now();
@@ -113,7 +191,8 @@
$('#postman').hide();
$('#divQRPage').show();
waReady = false;
$("#btnMessage").attr("disabled", true)
$("#btnMessage").attr("disabled", true);
$("#btnBtn").attr("disabled", true);
startImer()
})
socket.on('ready', function (data) {
@@ -126,25 +205,34 @@
$('#postman').show();
})
socket.on("connect_error", (err) => {
$("#btnMessage").attr("disabled", true);
$("#btnBtn").attr("disabled", true);
$('.logs').prepend($('<li>').text("¡Error de conexión!"));
if ($(".logs li").length >= 15) { $('.logs li').last().remove(); }
console.log("MENSAJES = " + $(".logs li").length)
waReady = false
$("#btnMessage").attr("disabled", true)
console.log(`connect_error due to ${err.message}`);
})
socket.on('incomming', function () {
if (waReady == false) {
$('.logs').prepend($('<li>').text('Whatsapp is ready!'));
$('.logs').prepend($('<li>').text('Whatsapp está listo!'));
if ($(".logs li").length >= 15) { $('.logs li').last().remove(); }
console.log("MENSAJES = " + $(".logs li").length)
console.log("incomming")
$("#btnMessage").attr("disabled", false)
$("#btnMessage").attr("disabled", false);
$("#btnBtn").attr("disabled", false);
waReady = true
}
})
socket.on('connOk', function () {
console.log("connOk")
if (waReady == false) {
$('.logs').prepend($('<li>').text('Whatsapp is ready!'));
if (waReady == false && IOSTATUS == "wa_ready") {
$('.logs').prepend($('<li>').text('Whatsapp está listo!'));
if ($(".logs li").length >= 15) { $('.logs li').last().remove(); }
console.log("MENSAJES = " + $(".logs li").length)
console.log("incomming")
$("#btnMessage").attr("disabled", false)
$("#btnMessage").attr("disabled", false);
$("#btnBtn").attr("disabled", false);
waReady = true
}
})
@@ -195,7 +283,32 @@
if (data.status == true) { alert("¡Mensaje enviado!") }
});
})
$('#btnBtn').on('click', function () {
console.log("btn clicked")
if($("#btnnumber").val() != "" && $("#btnmsg").val() != "" && $("#btn1").val() != ""){
let data = {}
data.number = $("#btnnumber").val()
data.title = $("#btntitle").val()
data.btnmsg = $("#btnmsg").val()
if($("#btn1").val() != "") {data.btn1 = $("#btn1").val()}
if ($("#btn2").val() != "") {data.btn2 = $("#btn2").val()}
if ($("#btn3").val() != "") {data.btn3 = $("#btn3").val()}
if ($("#btnfooter").val() != "") {data.footer = $("#btnfooter").val()}
$.post("http://localhost:3005/send-buttons/", data)
.done(function (data) {
console.log(data.status);
if (data.status == true) { alert("¡Mensaje enviado!") }
});
}
else{alert("Es necesario llenar por lo menos el número, mensaje y boton1.")}
})
$("#tipoMensaje").change(function () {
let sel = $("select option:selected").val()
console.log(sel)
if(sel == 'Mensaje'){ $("#postMsg").show(); $("#postBtn").hide(); $("#postImg").hide(); }
else if(sel == 'Imagen') { $("#postMsg").hide(); $("#postBtn").hide(); $("#postImg").show(); }
else if (sel == 'Botones') { $("#postMsg").hide(); $("#postBtn").show(); $("#postImg").hide(); }
})
});
</script>