mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
update
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -7,5 +7,5 @@ media/*
|
|||||||
!media/.gitkeep
|
!media/.gitkeep
|
||||||
mediaSend/*
|
mediaSend/*
|
||||||
!mediaSend/.gitkeep
|
!mediaSend/.gitkeep
|
||||||
!mediaSend/PTT-20220223-WA0000.opus
|
!mediaSend/nota-de-voz.mp3
|
||||||
.env
|
.env
|
||||||
1
app.js
1
app.js
@@ -55,7 +55,6 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
const number = cleanNumber(from)
|
const number = cleanNumber(from)
|
||||||
await readChat(number, message)
|
await readChat(number, message)
|
||||||
|
|
||||||
await sendMediaVoiceNote(client, from, 'PTT-20220223-WA0000.opus')
|
|
||||||
/**
|
/**
|
||||||
* Guardamos el archivo multimedia que envia
|
* Guardamos el archivo multimedia que envia
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const {get, reply, getIA} = require('../adapter')
|
const {get, reply, getIA} = require('../adapter')
|
||||||
const {saveExternalFile} = require('./handle')
|
const {saveExternalFile, checkIsUrl} = require('./handle')
|
||||||
|
|
||||||
const getMessages = async (message) => {
|
const getMessages = async (message) => {
|
||||||
const data = await get(message)
|
const data = await get(message)
|
||||||
@@ -9,7 +9,7 @@ const getMessages = async (message) => {
|
|||||||
const responseMessages = async (step) => {
|
const responseMessages = async (step) => {
|
||||||
const data = await reply(step)
|
const data = await reply(step)
|
||||||
if(data && data.media){
|
if(data && data.media){
|
||||||
const file = await saveExternalFile(data.media)
|
const file = checkIsUrl(data.media) ? await saveExternalFile(data.media) : data.media;
|
||||||
return {...data,...{media:file}}
|
return {...data,...{media:file}}
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ const saveExternalFile = (url) => new Promise((resolve, reject) => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const checkIsUrl = (path) => {
|
||||||
|
try{
|
||||||
|
regex = /^(http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/i;
|
||||||
|
match = path.match(regex);
|
||||||
|
return match[0]
|
||||||
|
}catch(e){
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const generateImage = (base64, cb = () => {}) => {
|
const generateImage = (base64, cb = () => {}) => {
|
||||||
let qr_svg = qr.image(base64, { type: 'svg', margin: 4 });
|
let qr_svg = qr.image(base64, { type: 'svg', margin: 4 });
|
||||||
qr_svg.pipe(require('fs').createWriteStream('./mediaSend/qr-code.svg'));
|
qr_svg.pipe(require('fs').createWriteStream('./mediaSend/qr-code.svg'));
|
||||||
@@ -39,4 +49,4 @@ const generateImage = (base64, cb = () => {}) => {
|
|||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {cleanNumber, saveExternalFile, generateImage}
|
module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl}
|
||||||
@@ -18,7 +18,7 @@ const sendMedia = (client, number, fileName) => {
|
|||||||
const file = `${DIR_MEDIA}/${fileName}`;
|
const file = `${DIR_MEDIA}/${fileName}`;
|
||||||
if (fs.existsSync(file)) {
|
if (fs.existsSync(file)) {
|
||||||
const media = MessageMedia.fromFilePath(file);
|
const media = MessageMedia.fromFilePath(file);
|
||||||
client.sendMessage(number, media);
|
client.sendMessage(number, media, { sendAudioAsVoice: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"cursos",
|
"cursos",
|
||||||
"info",
|
"info",
|
||||||
"curso"
|
"curso" ],
|
||||||
],
|
|
||||||
"key": "STEP_2"
|
"key": "STEP_2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -69,20 +68,26 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"👉 Youtube"
|
"youtube"
|
||||||
],
|
],
|
||||||
"key": "STEP_5"
|
"key": "STEP_5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"😎 Cursos"
|
"VER_CURSOS"
|
||||||
],
|
],
|
||||||
"key": "STEP_6"
|
"key": "STEP_6"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"😁 Telegram"
|
"telegram"
|
||||||
],
|
],
|
||||||
"key": "STEP_7"
|
"key": "STEP_7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"audio"
|
||||||
|
],
|
||||||
|
"key": "STEP_8"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,21 +1,15 @@
|
|||||||
{
|
{
|
||||||
"DEFAULT":{
|
"DEFAULT":{
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
"🆗 Bienvenido a este 🤖 CHATBOT de Whatsapp, lo primero \n",
|
"*Esta respuesta es un respuesta default* cuando no se consigue una palabra clave \n",
|
||||||
"decirte que mi nombre es *Leifer Mendez*😎 y te dejo opciones rapidas \n"
|
"la puedes desactivar en tu archivo .env DEFAULT_MESSAGE=false \n",
|
||||||
|
"tambien te quiero recordar que si presentas algun error pasarte por el repositorio \n",
|
||||||
|
"https://github.com/leifermendez/bot-whatsapp#chatbot-whatsapp-opensource \n",
|
||||||
|
"y recuerda tener la ultima versión del proyecto \n\n",
|
||||||
|
"Prueba escribiendo *hola* \n"
|
||||||
],
|
],
|
||||||
"media":null,
|
"media":null,
|
||||||
"trigger":null,
|
"trigger":null
|
||||||
"actions":{
|
|
||||||
"title":"¿Que te interesa ver?",
|
|
||||||
"message":"Recuerda todo este contenido es gratis y estaria genial que me siguas!",
|
|
||||||
"footer":"Gracias",
|
|
||||||
"buttons":[
|
|
||||||
{"body":"😎 Cursos"},
|
|
||||||
{"body":"👉 Youtube"},
|
|
||||||
{"body":"😁 Telegram"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"STEP_0":{
|
"STEP_0":{
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
@@ -28,10 +22,10 @@
|
|||||||
},
|
},
|
||||||
"STEP_1":{
|
"STEP_1":{
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
"✌️ Bienvenido a este 🤖 CHATBOT de Whatsapp, lo primero \n",
|
"Hola! y✌️ Bienvenido a este 🤖 CHATBOT de Whatsapp, lo primero \n",
|
||||||
"decirte que mi nombre es *Leifer Mendez*😎 \n",
|
"decirte que mi nombre es *Leifer Mendez*😎 \n",
|
||||||
"\n Si necesitas ver más info sobre las capacitacion tecnicas ",
|
"\n Si necesitas ver más info sobre las capacitacion tecnicas ",
|
||||||
"escribe *cursos* o *info*"
|
"escribe *cursos* o *info* o escribe *audio*"
|
||||||
],
|
],
|
||||||
"media":null,
|
"media":null,
|
||||||
"trigger":null,
|
"trigger":null,
|
||||||
@@ -40,9 +34,9 @@
|
|||||||
"message":"Recuerda todo este contenido es gratis y estaria genial que me siguas!",
|
"message":"Recuerda todo este contenido es gratis y estaria genial que me siguas!",
|
||||||
"footer":"Gracias",
|
"footer":"Gracias",
|
||||||
"buttons":[
|
"buttons":[
|
||||||
{"body":"😎 Cursos"},
|
{"body":"Cursos"},
|
||||||
{"body":"👉 Youtube"},
|
{"body":"Youtube"},
|
||||||
{"body":"😁 Telegram"}
|
{"body":"Telegram"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -116,9 +110,10 @@
|
|||||||
},
|
},
|
||||||
"STEP_5":{
|
"STEP_5":{
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
"Muy bien te comparto el canal de Youtube \n"
|
"Muy bien te comparto el canal de Youtube \n",
|
||||||
|
"https://youtube.com/leifermendez \n"
|
||||||
],
|
],
|
||||||
"media":"https://youtube.com/leifermendez",
|
"media":null,
|
||||||
"trigger":null
|
"trigger":null
|
||||||
},
|
},
|
||||||
"STEP_6":{
|
"STEP_6":{
|
||||||
@@ -137,9 +132,17 @@
|
|||||||
},
|
},
|
||||||
"STEP_7":{
|
"STEP_7":{
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
"Vente al telegram \n"
|
"Vente al telegram \n",
|
||||||
|
"https://t.me/leifermendez \n"
|
||||||
],
|
],
|
||||||
"media":"https://t.me/leifermendez",
|
"media":null,
|
||||||
|
"trigger":null
|
||||||
|
},
|
||||||
|
"STEP_8":{
|
||||||
|
"replyMessage":[
|
||||||
|
"Esto es una nota de voz \n"
|
||||||
|
],
|
||||||
|
"media":"nota-de-voz.mp3",
|
||||||
"trigger":null
|
"trigger":null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
mediaSend/nota-de-voz.mp3
Normal file
BIN
mediaSend/nota-de-voz.mp3
Normal file
Binary file not shown.
12
package-lock.json
generated
12
package-lock.json
generated
@@ -2977,9 +2977,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"puppeteer": {
|
"puppeteer": {
|
||||||
"version": "13.3.2",
|
"version": "13.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-13.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-13.4.0.tgz",
|
||||||
"integrity": "sha512-TIt8/R0eaUwY1c0/O0sCJpSglvGEWVoWFfGZ2dNtxX3eHuBo1ln9abaWfxTjZfsrkYATLSs8oqEdRZpMNnCsvg==",
|
"integrity": "sha512-WrHtFF2WpYC6KWFP4OCPOHWCjW4f8tFk+FkYZeNQ8/lHn+asjXBEXiIWauune8CY2xIHBVExGas+WI6Ay8/MgQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"cross-fetch": "3.1.5",
|
"cross-fetch": "3.1.5",
|
||||||
"debug": "4.3.3",
|
"debug": "4.3.3",
|
||||||
@@ -3696,9 +3696,9 @@
|
|||||||
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
|
||||||
},
|
},
|
||||||
"whatsapp-web.js": {
|
"whatsapp-web.js": {
|
||||||
"version": "1.15.6",
|
"version": "1.15.8",
|
||||||
"resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.15.6.tgz",
|
"resolved": "https://registry.npmjs.org/whatsapp-web.js/-/whatsapp-web.js-1.15.8.tgz",
|
||||||
"integrity": "sha512-o5iKWd6KDMMxxL0VHM8Uk380D6elFY5d0THpgLN60IcCknyM4IXWtpbFHdrbDUXylnn8lFHiMf9w0hQSEhvfeQ==",
|
"integrity": "sha512-xbNKZb/7QhORU9I2iZ4acSxuhNAUx5riLckTLU+echc8XZan7cWbQuAr0Nzlrt2RKIpCyBfeH3vI6ZlMMApBRA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pedroslopez/moduleraid": "^5.0.2",
|
"@pedroslopez/moduleraid": "^5.0.2",
|
||||||
"fluent-ffmpeg": "^2.1.2",
|
"fluent-ffmpeg": "^2.1.2",
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
"qr-image": "^3.2.0",
|
"qr-image": "^3.2.0",
|
||||||
"qrcode-terminal": "^0.12.0",
|
"qrcode-terminal": "^0.12.0",
|
||||||
"socket.io": "^4.4.1",
|
"socket.io": "^4.4.1",
|
||||||
"whatsapp-web.js": "^1.15.6",
|
"whatsapp-web.js": "^1.15.8",
|
||||||
"xlsx": "^0.16.9"
|
"xlsx": "^0.16.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user