mirror of
https://github.com/cheveguerra/botGuna.git
synced 2026-04-17 19:37:07 +00:00
Compare commits
29 Commits
bot-whatsa
...
BotPruebas
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e3e02c50b | |||
| 0bd297ec94 | |||
| e35147bb90 | |||
| 26932ccefc | |||
| 693de00db8 | |||
| 9d293d3d6d | |||
| 652515adb9 | |||
| ce9d82fcf7 | |||
| 3b2106fef8 | |||
| ff05e96cc6 | |||
| ab474b5728 | |||
| 5916ba6615 | |||
| 4b5aabf09a | |||
| 487ba83f7c | |||
| 7591feb598 | |||
| 554d9b2f4f | |||
| ee4c00cb46 | |||
| c31fc1d201 | |||
| dfd2c7d97d | |||
| 44921e7b78 | |||
| 55012a9d88 | |||
| 1660cf46c3 | |||
| ef9917e954 | |||
| 7febd90e56 | |||
| e8847800f6 | |||
| ee79cd9dab | |||
| b8bf6d1107 | |||
| 4cc92a1d80 | |||
| 828030e424 |
16
.env
Normal file
16
.env
Normal file
@@ -0,0 +1,16 @@
|
||||
######DATABASE: none, mysql, dialogflow
|
||||
|
||||
DEFAULT_MESSAGE=false
|
||||
SAVE_MEDIA=true
|
||||
PORT=3005
|
||||
DATABASE=none
|
||||
LANGUAGE=es
|
||||
SQL_HOST=
|
||||
SQL_USER=
|
||||
SQL_PASS=
|
||||
SQL_DATABASE=
|
||||
KEEP_DIALOG_FLOW=false
|
||||
MULTI_DEVICE=true
|
||||
DIALOGFLOW_MEDIA_FOR_SLOT_FILLING=false
|
||||
GDRIVE_FOLDER_ID=
|
||||
PROVIDER=baileys
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -8,7 +8,7 @@ media/*
|
||||
mediaSend/*
|
||||
!mediaSend/.gitkeep
|
||||
!mediaSend/nota-de-voz.mp3
|
||||
.env
|
||||
.wwebjs_auth
|
||||
backup
|
||||
backup/*
|
||||
backup/*
|
||||
/implementaciones/credenciales.json
|
||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
||||
FROM node:18-alpine as node
|
||||
|
||||
# Installs latest Chromium (92) package.
|
||||
RUN apk add --no-cache \
|
||||
chromium \
|
||||
nss \
|
||||
freetype \
|
||||
harfbuzz \
|
||||
ca-certificates \
|
||||
ttf-freefont \
|
||||
nodejs \
|
||||
yarn
|
||||
|
||||
# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
||||
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
|
||||
|
||||
# Puppeteer v10.0.0 works with Chromium 92.
|
||||
COPY . .
|
||||
RUN npm install puppeteer@10.0.0
|
||||
RUN npm install
|
||||
|
||||
CMD ["npm", "start"]
|
||||
57
Excel.js
Normal file
57
Excel.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const ExcelJS = require('exceljs');
|
||||
const fs = require('fs')
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
|
||||
const guardaXLSDatos = async (nombre, edad, sexo) => {
|
||||
// read from a file
|
||||
await workbook.xlsx.readFile('./bot.xlsx');
|
||||
// fetch sheet by name
|
||||
const worksheet = workbook.getWorksheet('Bot');
|
||||
const rowValues = [];
|
||||
rowValues[1] = nombre;
|
||||
rowValues[2] = edad;
|
||||
rowValues[3] = sexo;
|
||||
worksheet.addRow(rowValues);
|
||||
await workbook.xlsx.writeFile('./bot.xlsx');
|
||||
console.log(rowValues)
|
||||
console.log("Guardamos XLS")
|
||||
}
|
||||
|
||||
const leeXLSDatos = async (srchStr) => {
|
||||
// read from a file
|
||||
await workbook.xlsx.readFile('./bot.xlsx');
|
||||
// fetch sheet by name
|
||||
const worksheet = workbook.getWorksheet('Bot');
|
||||
console.log(worksheet.rowCount)
|
||||
let colNombre = worksheet.getColumn(1).values
|
||||
let cont = 0
|
||||
let encontrado = 0
|
||||
let row
|
||||
let res = []
|
||||
// while (cont <= worksheet.rowCount && encontrado == 0) { // Ocupamos while en lugar de forEach para que deje de buscar en cuanto encuentre el resultado.
|
||||
// console.log(cont, colNombre[cont], srchStr)
|
||||
// if(colNombre[cont] === srchStr) {
|
||||
// row = worksheet.getRow(cont);
|
||||
// res['nombre'] = row.getCell(1).value
|
||||
// res['edad'] = row.getCell(2).value
|
||||
// res['sexo'] = row.getCell(3).value
|
||||
// encontrado = colNombre[cont]
|
||||
// }
|
||||
// cont++;
|
||||
// }
|
||||
// console.log("RES=", res)
|
||||
// for (let index = 0; index < worksheet.rowCount; index++) {
|
||||
|
||||
|
||||
|
||||
// }
|
||||
let rows = []
|
||||
worksheet.eachRow(function(row, rowNumber) {
|
||||
// console.log('Row ' + rowNumber + ' = ' + JSON.stringify(row.values));
|
||||
rows[rowNumber-1]={'nombre':row.getCell(1).value, 'carnet':row.getCell(4).value, 'factura':row.getCell(5).value, 'prefijo':row.getCell(6).value}
|
||||
});
|
||||
// console.log(rows)
|
||||
return rows
|
||||
}
|
||||
|
||||
module.exports = {guardaXLSDatos, leeXLSDatos};
|
||||
53
README.md
53
README.md
@@ -4,19 +4,29 @@
|
||||
Este proyecto es un clon de la **version 1** (legacy) de [Leifer Mendez](https://github.com/leifermendez/bot-whatsapp) y tiene las siguientes modificaciones:
|
||||
|
||||
- Permite **submenus**.
|
||||
- Un submenú es una regla que **sólo se dispara** cuando la regla anterior es la especificada, los submenus se definen agregando el parametro "```pasoRequerido```" en el **response.json**.
|
||||
- Un submenú es un paso que **sólo se dispara** cuando el paso anterior es el especificado, los submenus se definen agregando el parametro "```pasoRequerido```" en el **response.json**, entonces si queremos que el paso **zapatos** solo se muestre cuando antes pasamos por el **menú inicial**, agregamos el parámetro "pasoRequerido" a la regla "zapatos", de esta forma si alguien pone el número **1** sin estar en el menú principal, **no** los va a mandar a **zapatos**.
|
||||
|
||||
```json
|
||||
"menu":{
|
||||
"replyMessage":[
|
||||
"%saludo%\nHoy es %dia_semana%.\n"
|
||||
"%saludo%",
|
||||
"Escribe 1 para zapatos.",
|
||||
"Escribe 2 para bolsos."
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null
|
||||
},
|
||||
"submenu":{
|
||||
"zapatos":{
|
||||
"replyMessage":[
|
||||
"Este submenu solo se dispara si **ANTES** se disparó la regla 'menu'"
|
||||
"Esta es la lista de nuestros zapatos."
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu"
|
||||
},
|
||||
"bolsos":{
|
||||
"replyMessage":[
|
||||
"Esta es la lista de nuestros bolsos."
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
@@ -47,11 +57,38 @@ Este proyecto es un clon de la **version 1** (legacy) de [Leifer Mendez](https:/
|
||||
}
|
||||
```
|
||||
- Permite **remplazos** en el texto de los mensajes por ejemplo:
|
||||
- __%saludo%__ para que aparezca "Buenos días, tardes o noches" dependiendo de la hora.
|
||||
- __%primer_nombre%__ para que aparezca el nombre (hasta el primer espacio) del remitente.
|
||||
- __%dia_semana%__ para que aparezca "lunes, martes, miercoles, etc" dependiendo del día de la semana.
|
||||
- __%msjant_XX%__ para que aparezca el mensaje xx anterior, es decir, si quieres mostrar el texto de 2 mensajes anteriores se pone %msjant_2%.
|
||||
- Ponemos __%saludo%__ para que aparezca "Buenos días, tardes o noches" dependiendo de la hora.
|
||||
- Ponemos __%primer_nombre%__ para que aparezca el nombre (hasta el primer espacio) del remitente.
|
||||
- Ponemos __%dia_semana%__ para que aparezca "lunes, martes, miercoles, etc" dependiendo del día de la semana.
|
||||
- Ponemos __%msjant_XX%__ para que aparezca el mensaje xx anterior, es decir, si quieres mostrar el texto de 2 mensajes anteriores se pone %msjant_2%.
|
||||
- etc, etc, se pueden agregar mas remplazos en la funcion "remplazos" en el archivo "adapter\index.js".
|
||||
- Permite el envío de **multiples mensajes** definidos en la **misma respuesta** del **response.json**. (Esta modificación se la robe por completo a [KJoaquin](https://github.com/KJoaquin), el lo solucionó [aquí](https://github.com/codigoencasa/bot-whatsapp/issues/111#issuecomment-1353504575) 🙌🏽 y yo solo lo adapté a mi repo!)
|
||||
|
||||
Antes:
|
||||
```json
|
||||
{
|
||||
"ejemploViejo":{
|
||||
"replyMessage":["¿Hola como estas?"],
|
||||
"media":null,
|
||||
"trigger":null
|
||||
}
|
||||
}
|
||||
```
|
||||
Ahora **replyMessage** debe de contener un arreglo con los mensajes que se van a enviar:
|
||||
```json
|
||||
{
|
||||
"ejemploNuevo":{
|
||||
"replyMessage":[
|
||||
{ "mensaje":["¿Hola como estas?"]},
|
||||
{ "mensaje":["Este es el *segundo* mensaje.","Contiene dos lineas 🤪"]},
|
||||
{ "mensaje":["Este es el *tercer* mensaje"]}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- Las modificaciones están enfocadas al uso de los archivos __initial.json__ y __response.json__, yo no uso MySQL o DialogFlow, así que no sé si las modificaciones funcionen con esos modulos, en particular el __remplazo %msjant_XX%__ depende de los archivos __JSON__ que se crean en el directorio "chats".
|
||||
- Tiene agregado el parche de **botones y listas**, así que funcionan sin problema (las listas no funcionan si el bot esta ligado a un número que use **Whatsapp Business**).
|
||||
- Tiene los ultimos parches de **DialogFlow** (27-dic-2022) (When Dialogflow asks for an Image, then **Upload it to Google Drive** and then generate Shared Link)
|
||||
|
||||
383
adapter/index.js
383
adapter/index.js
@@ -1,26 +1,48 @@
|
||||
const { getData, getReply, saveMessageMysql } = require('./mysql')
|
||||
const { saveMessageJson } = require('./jsonDb')
|
||||
const { getDataIa } = require('./diaglogflow')
|
||||
const stepsInitial = require('../flow/initial.json')
|
||||
// const stepsInitial = require('../flow/initial.json')
|
||||
const stepsReponse = require('../flow/response.json')
|
||||
const { isUndefined } = require('util');
|
||||
var msjsRecibidos = [];
|
||||
// const { isUndefined } = require('util');
|
||||
var ultimoStep; //MOD by CHV -
|
||||
var pasoAnterior = []; //MOD by CHV - Para guardar el paso anterior de cada número.
|
||||
var pasoRequerido; //MOD by CHV -
|
||||
var vamosA = ""; //MOD by CHV -
|
||||
var _vamosA = ""; //MOD by CHV -
|
||||
var VA = ""; //MOD by CHV -
|
||||
var elNum; //MOD by CHV -
|
||||
var cumplePasoPrevio; //MOD by CHV -
|
||||
var cumplePasoPrevio = []; //MOD by CHV -
|
||||
const resps = require('../flow/response.json'); //MOD by CHV - Agregamos para traer las respuestas.
|
||||
const { appendFile } = require('fs')
|
||||
// const { appendFile, existsSync } = require('fs')
|
||||
// const { traeVariables } = require(`../provider/${provider}.js`)
|
||||
|
||||
/**
|
||||
* Regresa un arreglo de objetos como el stepsInitial original, que se generaba desde "initial.json".
|
||||
* Contiene el nombre del paso (key) y las palabras clave correspondientes (keywords).
|
||||
*/
|
||||
const getStepsInitial = () => {
|
||||
let contSI = 0
|
||||
let stepsInitial0 = []
|
||||
for (const resp in stepsReponse) {
|
||||
// console.log(`${resp}: ${stepsReponse[resp]['keywords']}`);
|
||||
if(stepsReponse[resp]['keywords'] !== undefined){
|
||||
stepsInitial0[contSI]= {"keywords":stepsReponse[resp]['keywords'], "key":resp}
|
||||
contSI++
|
||||
}
|
||||
}
|
||||
return stepsInitial0
|
||||
}
|
||||
const stepsInitial = getStepsInitial()
|
||||
|
||||
/**
|
||||
* Revisa si el texto del mensaje dispara alguna regla (body == keyword)
|
||||
* @param {*} message
|
||||
* @param {*} num
|
||||
* @returns
|
||||
*/
|
||||
const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV - Agregamos parametro "num" para recibir el número de "app.js"
|
||||
// console.log(num)
|
||||
elNum = num //MOD by CHV -
|
||||
if(siguientePaso.find(k => k.numero.includes(elNum))){
|
||||
console.log("siguientePaso="+siguientePaso.find(k => k.numero.includes(elNum))["numero"], siguientePaso.find(k => k.numero.includes(elNum))["va"])
|
||||
// ultimoStep = siguientePaso.find(k => k.numero.includes(elNum))["va"]
|
||||
pasoAnterior[elNum] = siguientePaso.find(k => k.numero.includes(elNum))["va"] //Asignamos pasoAnterior al número.
|
||||
siguientePaso.splice(siguientePaso.indexOf(elNum), 1)
|
||||
console.log("******************** "+siguientePaso.find(k => k.numero.includes(elNum)))
|
||||
@@ -28,11 +50,43 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
||||
if(siguientePaso.length>1){console.log(siguientePaso[1]["numero"], siguientePaso[1]["va"])}
|
||||
|
||||
/**
|
||||
* Si no estas usando un gesto de base de datos
|
||||
* Si no estas usando una base de datos
|
||||
*/
|
||||
|
||||
if (process.env.DATABASE === 'none') {
|
||||
var { key } = stepsInitial.find(k => k.keywords.includes(message)) || { key: null }
|
||||
//******************************************************************************** */
|
||||
var logKeysArray = false // Poner en verdadero para ver logs de esta seccion.
|
||||
//******************************************************************************** */
|
||||
key = null
|
||||
let q = 0;
|
||||
if(logKeysArray) console.log(stepsInitial.length)
|
||||
while (key == null && q < stepsInitial.length) {
|
||||
if(Array.isArray(stepsInitial[q].keywords)){
|
||||
let r = 0
|
||||
let rFound = false
|
||||
while(!rFound && r<stepsInitial[q].keywords.length){
|
||||
if(logKeysArray) console.log(q, "keyword=", stepsInitial[q].keywords[r], "msj=", message)
|
||||
if(logKeysArray) console.log(q, "req=", resps[stepsInitial[q].key.toString()].pasoRequerido, "ant=", pasoAnterior[elNum])
|
||||
if( message.toLowerCase() == stepsInitial[q].keywords[r].toLowerCase() && ( // Si el mensaje coincide con la palabra clave Y pasoRequerido es igual a pasoAnterior ...
|
||||
resps[stepsInitial[q].key.toString()].pasoRequerido == undefined ||
|
||||
resps[stepsInitial[q].key.toString()].pasoRequerido == pasoAnterior[elNum]
|
||||
)
|
||||
){
|
||||
key = stepsInitial[q].key
|
||||
if(logKeysArray) console.log(key, " SI COINCIDE")
|
||||
rFound = true
|
||||
}
|
||||
else
|
||||
{
|
||||
// key = null
|
||||
if(logKeysArray) console.log("No coincide")
|
||||
}
|
||||
r++
|
||||
}
|
||||
}
|
||||
q++
|
||||
}
|
||||
if(logKeysArray) console.log("KEY = ", key)
|
||||
// var { key } = stepsInitial.find(k => k.keywords.includes(message)) || { key: null }
|
||||
|
||||
/* ############################################### * REGEXP * ####################################################
|
||||
Si queremos usar RegExp, en los "keywords" de inital.json, en lugar de un arreglo usamos un string (quitamos los [])
|
||||
@@ -52,63 +106,63 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
||||
var {keywords} = stepsInitial.find(k => k.key.includes(key)) || { keywords: null }
|
||||
if(!Array.isArray(keywords)){key=null;}//Si "keywords" no es arreglo entonces ponemos "key" en null y usamos REGEXP para buscar reglas.
|
||||
if(key == null && message.length > 0){
|
||||
console.log("======= KEY ES NULO USAMOS REGEXP =======");
|
||||
for (i=0; i<stepsInitial.length;i++){
|
||||
// console.log(i, stepsInitial[i].keywords, message.match(stepsInitial[i].keywords.toString().replaceAll("*",".*")));
|
||||
if(!Array.isArray(stepsInitial[i].keywords)){// Si "Keywords" NO es arreglo entonces ...
|
||||
x = null;
|
||||
console.log("KEY=|" + stepsInitial[i].key.toString() + "|" )
|
||||
// if(resps[stepsInitial[i].key.toString()].pasoRequerido != undefined){pr = resps[stepsInitial[i].key].pasoRequerido};
|
||||
// console.log(resps[stepsInitial[i].key.toString()].pasoRequerido== ultimoStep)
|
||||
console.log("Esta Key=" + stepsInitial[i].key.toString() + " - pasoReq=" + resps[stepsInitial[i].key.toString()].pasoRequerido + " - PasoAnt=" + ultimoStep+"|"+pasoAnterior[elNum])
|
||||
if(resps[stepsInitial[i].key.toString()].pasoRequerido == undefined || resps[stepsInitial[i].key.toString()].pasoRequerido == pasoAnterior[elNum]){
|
||||
//******************************************************************************** */
|
||||
var logRegEx = false
|
||||
//******************************************************************************** */
|
||||
console.log("======= KEY ES NULO, USAMOS REGEXP =======");
|
||||
for (si=0; si<stepsInitial.length;si++){
|
||||
if(!Array.isArray(stepsInitial[si].keywords)){// Si "Keywords" NO es arreglo entonces ...
|
||||
var coincideKeyword = null;
|
||||
if(logRegEx) console.log("*** PASO=" + stepsInitial[si].key.toString() + " - REQUERIDO=" + resps[stepsInitial[si].key.toString()].pasoRequerido + " - ANTERIOR=" + pasoAnterior[elNum])
|
||||
//Si NO hay paso requerido, o el paso requerido es IGUAL al paso anterior, entonces ...
|
||||
if(resps[stepsInitial[si].key.toString()].pasoRequerido == undefined || resps[stepsInitial[si].key.toString()].pasoRequerido == pasoAnterior[elNum]){
|
||||
var tempKeyword = "";
|
||||
if (stepsInitial[i].keywords == "%solo_correos%"){
|
||||
console.log("solo_correos")
|
||||
if(logRegEx) console.log(" - El paso requerido COINCIDE con el anterior, o NO hay paso requerido.")
|
||||
if (stepsInitial[si].keywords == "%solo_correos%"){
|
||||
if(logRegEx) console.log("solo_correos")
|
||||
tempKeyword = "[a-zA-Z0-9]+[_a-zA-Z0-9\.-]*[a-zA-Z0-9]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+[\.][a-zA-Z]{2,12})"}
|
||||
else{tempKeyword = stepsInitial[i].keywords.toString().replaceAll("*",".*")}
|
||||
x = message.match(tempKeyword);
|
||||
// console.log("Keywords="+stepsInitial[i].keywords + " - key=" + stepsInitial[i].key + " - pasoReq=" + resps[stepsInitial[i].key].pasoRequerido + " - PasoAnt=" + ultimoStep)
|
||||
// console.log("x:"+x+" - ultimoStep="+ultimoStep+" - pasoReq="+resps[stepsInitial[i].key].pasoRequerido);
|
||||
// console.log(resps[stepsInitial[i].key].replyMessage.toString())
|
||||
if (x != null){
|
||||
key = stepsInitial[i].key;
|
||||
if(resps[stepsInitial[i].key].pasoRequerido != null && resps[stepsInitial[i].key].pasoRequerido != pasoAnterior[elNum]){key=null;}
|
||||
// console.log("KEY="+key+" - X="+x);
|
||||
if(resps[stepsInitial[i].key].replyMessage.toString().search("/URL") > -1){
|
||||
console.log("**************** HAY URL ****************")
|
||||
else {
|
||||
tempKeyword = stepsInitial[si].keywords.toString().replaceAll("*",".*")
|
||||
}
|
||||
coincideKeyword = message.match(tempKeyword); // Verdadero cuando el mensaje COINCIDE con la palabre clave.
|
||||
if (coincideKeyword != null){ //Si el mensaje COINCIDE con la palabra clave.
|
||||
if(logRegEx) console.log(" - - El mensaje COINCIDE con el keyword")
|
||||
key = stepsInitial[si].key;
|
||||
//Si HAY paso requerido, y el paso requerido es DIFERENTE del paso anterior, entonces ...
|
||||
if(resps[stepsInitial[si].key].pasoRequerido != null && resps[stepsInitial[si].key].pasoRequerido != pasoAnterior[elNum]){
|
||||
key=null
|
||||
if(logRegEx) console.log(" - - - Hay paso requerido y NO COINCIDE con en paso anterior")
|
||||
}
|
||||
if(resps[stepsInitial[si].key].replyMessage.toString().search("/URL") > -1){
|
||||
if(logRegEx) console.log("**************** HAY URL ****************")
|
||||
}
|
||||
break;
|
||||
}
|
||||
else{x = null;}
|
||||
} else
|
||||
{ console.log("NO CUMPLE PASO REQ");
|
||||
// console.log("pasoReq=" + resps[stepsInitial[i].key.toString()].pasoRequerido + " - PasoAnt=" + ultimoStep)
|
||||
else {
|
||||
coincideKeyword = null
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(logRegEx) console.log("--- NO CUMPLE PASO REQ");
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log("<<<<<<<<< "+key);
|
||||
// console.log("<<<<<<<<< " + key);
|
||||
// cumplePasoRequerido(key)
|
||||
// ultimoPaso = pasoRequerido;
|
||||
// ultimoStep = key;
|
||||
}
|
||||
const response = key || null
|
||||
// if(key != null){remplazos(resps[key].replyMessage.join(''));}
|
||||
if(resps[key]!=undefined){VA = resps[key].goto}else{VA=null}
|
||||
cumplePasoRequerido(key);
|
||||
vamosA = VA;
|
||||
// console.log(elNum)
|
||||
|
||||
if(vamosA != "" && vamosA != undefined && cumplePasoPrevio == true){
|
||||
console.log("ASIGNAMOS VAMOSA = " + vamosA);
|
||||
pasoAnterior[elNum] = vamosA;
|
||||
_vamosA = VA;
|
||||
if(logRegEx) console.log("cumplePasoPrevio[elNum]=", cumplePasoPrevio[elNum], "_vamosA=", _vamosA)
|
||||
if(_vamosA != "" && _vamosA != undefined && cumplePasoPrevio[elNum] == true){
|
||||
if(logRegEx) console.log("ASIGNAMOS _VAMOSA = " + _vamosA);
|
||||
pasoAnterior[elNum] = _vamosA;
|
||||
}
|
||||
// console.log("ULTIMOSTEP="+ultimoStep)
|
||||
vamosA = "";
|
||||
// console.log("MESSAGE: "+message);
|
||||
// console.log("KEY: "+key);
|
||||
// console.log("RESPONSE: "+response);
|
||||
if(cumplePasoPrevio) {resolve(response);}
|
||||
_vamosA = "";
|
||||
if(cumplePasoPrevio[elNum]) {resolve(response);}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,20 +173,20 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
||||
resolve(dt)
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
const reply = (step) => new Promise((resolve, reject) => {
|
||||
/**
|
||||
* Si no estas usando un gesto de base de datos
|
||||
* Si no estas usando una base de datos
|
||||
*/
|
||||
if (process.env.DATABASE === 'none') {
|
||||
let resData = { replyMessage: '', media: null, trigger: null }
|
||||
const responseFind = stepsReponse[step] || {};
|
||||
resData = {
|
||||
...resData,
|
||||
...responseFind,
|
||||
replyMessage:responseFind.replyMessage.join('')}
|
||||
...responseFind
|
||||
// replyMessage:responseFind.replyMessage.join('')
|
||||
}
|
||||
resolve(resData);
|
||||
return
|
||||
}
|
||||
@@ -175,8 +229,8 @@ const saveMessage = ( message, trigger, number, regla ) => new Promise( async (r
|
||||
resolve( await saveMessageMysql( message, trigger, number ) )
|
||||
break;
|
||||
case 'none':
|
||||
resolve( await saveMessageJson( message, trigger, number, regla) ) //MOD by CHV - Agregamos el paranetro "regla"
|
||||
// console.log("REGLA DESDE APP.JS="+regla)
|
||||
resolve( await saveMessageJson( message, trigger, number, regla) ) //MOD by CHV - Agregamos el parametro "regla"
|
||||
console.log("Guardamos mensaje JSON=", message)
|
||||
break;
|
||||
default:
|
||||
resolve(true)
|
||||
@@ -184,156 +238,48 @@ const saveMessage = ( message, trigger, number, regla ) => new Promise( async (r
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = { get, reply, getIA, saveMessage, remplazos, stepsInitial } //MOD by CHV - Agregamos "remplazos" y "stepsInitial" para usarlos en "apps.js"
|
||||
|
||||
/**
|
||||
* Reemplaza texto en la respuesta con variables predefinidas.
|
||||
*/
|
||||
function remplazos(elTexto, extraInfo){
|
||||
if(elTexto == null){elTexto = '';}
|
||||
laLista = elTexto.toString().split(' ');
|
||||
// console.log(laLista);
|
||||
// console.log('============= remplazos ============');
|
||||
for (var i = 0; i < laLista.length; i++) {
|
||||
// console.log('Revisamos: '+laLista[i]);
|
||||
if (laLista[i].search('%dia_semana%')>-1){//Remplaza con el dia de hoy.
|
||||
var dia = new Date().getDay();
|
||||
if(dia==0){diaSemana='domingo';}
|
||||
else if(dia==1){diaSemana='lunes';}
|
||||
else if(dia==2){diaSemana='martes';}
|
||||
else if(dia==3){diaSemana='miercoles';}
|
||||
else if(dia==4){diaSemana='jueves';}
|
||||
else if(dia==5){diaSemana='viernes';}
|
||||
else {diaSemana='sábado';}
|
||||
elTexto = elTexto.replace('%dia_semana%', diaSemana);
|
||||
}
|
||||
if (laLista[i].search('%saludo%')>-1){//Remplaza con "Buenos dias, tardes o noches" dependiendo de la hora.
|
||||
var hora = new Date().getHours()
|
||||
if(hora>0 && hora < 12){saludo='Buenos días';}
|
||||
else if(hora>11 && hora < 19){saludo='Buenas tardes';}
|
||||
else {saludo='Buenas noches';}
|
||||
elTexto = elTexto.toString().replace('%saludo%', saludo);
|
||||
}
|
||||
if (laLista[i].search('%hora24%')>-1){//Remplaza con la hora a 24 hrs.
|
||||
var hora = new Date().getHours();
|
||||
if (hora.toString().length < 2){hora = "0" + hora;}
|
||||
elTexto = elTexto.toString().replace('%hora24%', hora);
|
||||
}
|
||||
if (laLista[i].search('%hora12%')>-1){//Remplaza con la hora a 12 hrs.
|
||||
var hora = new Date().getHours();
|
||||
var ampm = hora >= 12 ? 'pm' : 'am';
|
||||
hora = hora % 12;
|
||||
hora = hora ? hora : 12; // the hour '0' should be '12'
|
||||
if (hora.toString().length < 2){hora = "0" + hora;}
|
||||
elTexto = elTexto.toString().replace('%hora12%', hora);
|
||||
}
|
||||
if (laLista[i].search('%minutos%')>-1){//Remplaza con los minutos de la hora actual.
|
||||
var mins = new Date().getMinutes();
|
||||
if (mins.toString().length < 2){mins = "0" + mins;}
|
||||
elTexto = elTexto.toString().replace('%minutos%', mins);
|
||||
}
|
||||
if (laLista[i].search('%ampm%')>-1){//Remplaza con am o pm.
|
||||
var hours = new Date().getHours();
|
||||
var ampm = hours >= 12 ? 'pm' : 'am';
|
||||
elTexto = elTexto.toString().replace('%ampm%', ampm);
|
||||
}
|
||||
if (laLista[i].search('%rnd_')>-1){//Remplaza con opción al azar dentro de las especificadas.
|
||||
var inicio = laLista[i].search('%rnd_');
|
||||
var final = laLista[i].indexOf("%", inicio+1);
|
||||
// console.log(inicio, final);
|
||||
var subStr = laLista[i].substring(inicio, final+1);
|
||||
// console.log("El substring="+subStr);
|
||||
var partes = subStr.toString().split('_');
|
||||
if(partes.length > 1){
|
||||
var opciones = partes[1].toString().substring(0,partes[1].toString().length-1).split(",");
|
||||
var elRand = Math.floor(Math.random() * (opciones.length));
|
||||
if(elRand == opciones.length){elRand = elRand - 1;}
|
||||
// console.log(opciones.length, elRand, opciones[elRand]);
|
||||
elTexto = elTexto.toString().replace(subStr, opciones[elRand]);
|
||||
}
|
||||
else{
|
||||
elTexto = elTexto.toString().replace(subStr, "");
|
||||
}
|
||||
}
|
||||
if(laLista[i].search('%msjant_')>-1){//Remplaza con el mensaje anterior especificado.
|
||||
var histlMsjs = {};
|
||||
console.log("entramos a msjant")
|
||||
// var hayHistorial = (chkFile(`${__dirname}/chats/`+from+".json"));
|
||||
if(chkFile(`${__dirname}/../chats/`+elNum+".json")){
|
||||
let rawdata = fs.readFileSync(`./chats/${elNum}.json`);
|
||||
let elHistorial0 = JSON.parse(rawdata);
|
||||
elHistorial = elHistorial0["messages"];
|
||||
|
||||
var inicio = laLista[i].search('%msjant_');
|
||||
var final = laLista[i].indexOf("%", inicio+1);
|
||||
var subStr = laLista[i].substring(inicio, final+1);
|
||||
console.log("Substr = |" + subStr + "|");
|
||||
var partes = subStr.toString().split('_');
|
||||
if(partes.length > 1){
|
||||
console.log("Partes[1] = |" + partes[1] + "|");
|
||||
let posicion0 = partes[1].substring(0, partes[1].length-1)
|
||||
console.log("Posicion0 = |" + posicion0 + "|");
|
||||
posicion = ((posicion0*1) + 1);
|
||||
console.log("Posicion = " + posicion);
|
||||
console.log( elHistorial.length );
|
||||
console.log((elHistorial.length*1)-posicion);
|
||||
console.log("Mensaje="+elHistorial[elHistorial.length - posicion]["message"])
|
||||
elTexto = elTexto.toString().replace(subStr, elHistorial[elHistorial.length - posicion]["message"]);
|
||||
}
|
||||
// histlMsjs = elHistorial["messages"];
|
||||
// totalMsjs = histlMsjs.length-1;
|
||||
// ultimoMensaje = histlMsjs[histlMsjs.length-1];
|
||||
// let mensajeAnterior = elHistorial["messages"][totalMsjs-1];
|
||||
// console.log("Mensajes:"+totalMsjs+", Ultimo:"+JSON.stringify(ultimoMensaje));
|
||||
// console.log("Anterior:"+JSON.stringify(mensajeAnterior));
|
||||
}
|
||||
// return histlMsjs;
|
||||
}
|
||||
if (laLista[i].search('%nombre%')>-1){//Remplaza con el nombre del remitente.
|
||||
if(typeof extraInfo !== undefined){
|
||||
const {theMsg} = extraInfo;
|
||||
if(theMsg['_data']['notifyName'] !== undefined){
|
||||
elTexto = elTexto.toString().replace('%nombre%', theMsg['_data']['notifyName']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (laLista[i].search('%primer_nombre%')>-1){//Remplaza con el nombre del remitente.
|
||||
if(typeof extraInfo !== undefined){
|
||||
const {theMsg} = extraInfo;
|
||||
if(theMsg['_data']['notifyName'] !== undefined){
|
||||
elTexto = elTexto.toString().replace('%primer_nombre%', theMsg['_data']['notifyName'].split(' ')[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log("EL TEXTO="+elTexto);
|
||||
return elTexto
|
||||
}
|
||||
|
||||
* Asigna el valor especificado a la variable pasoAnterior.
|
||||
* Esta hace que el flujo se redirija al paso siguente al especificado.
|
||||
* NO EJECUTA EL PASO DADO, solo espfecifica cual es el paso anterior para cuando una regla tiene el parametro "pasoRequerido".
|
||||
* @param {elNum} string - El numero del remitente.
|
||||
* @param {elPaso} string - El paso al que se va redirigir el flujo.
|
||||
*/
|
||||
function vamosA (elNum, elPaso){
|
||||
pasoAnterior[elNum] = elPaso;
|
||||
console.log("Asignamos pasoAnterior con " + elPaso, elNum)
|
||||
}
|
||||
|
||||
/**
|
||||
* Revisa si la regla especificada depende (es submenu) de otra regla, y cambia la variable "cumplePasoPrevio" a verdadero o falso.
|
||||
*/
|
||||
function cumplePasoRequerido(step){
|
||||
*/
|
||||
function cumplePasoRequerido(step){
|
||||
//Traemos las respuestas para obtener el "pasoRequerido".
|
||||
if(resps[step]!=undefined){pasoRequerido=resps[step].pasoRequerido}else{pasoRequerido=null}
|
||||
if((pasoRequerido != null && pasoRequerido == ultimoStep)){
|
||||
// console.log("REQUIERE PASO PREVIO Y CUMPLE");
|
||||
cumplePasoPrevio = true;
|
||||
cumplePasoPrevio[elNum] = true;
|
||||
}
|
||||
else if((pasoRequerido != null && pasoRequerido != pasoAnterior[elNum])){
|
||||
// console.log("REQUIERE PASO PREVIO Y NO LO CUMPLE");
|
||||
cumplePasoPrevio = false;
|
||||
cumplePasoPrevio[elNum] = false;
|
||||
}
|
||||
else{
|
||||
// console.log("NO REQUIERE PASO PREVIO")
|
||||
cumplePasoPrevio = true;
|
||||
cumplePasoPrevio[elNum] = true;
|
||||
}
|
||||
pasoAnterior[elNum] = step
|
||||
ultimoPaso = pasoRequerido;
|
||||
// ultimoPaso = pasoRequerido;
|
||||
}
|
||||
|
||||
const fs = require('fs');
|
||||
/**
|
||||
* Revisa que exista el archivo "chats/numero.json"
|
||||
* @param {*} theFile
|
||||
* @returns
|
||||
*/
|
||||
function chkFile(theFile){ //MOD by CHV - Agregamos para revisar que exista el archivo "chats/numero.json"
|
||||
const fs = require('fs');
|
||||
if (fs.existsSync(theFile)) {
|
||||
// console.log("Si existe el archivo "+ theFile);
|
||||
var h = true;
|
||||
@@ -343,4 +289,61 @@ function chkFile(theFile){ //MOD by CHV - Agregamos para revisar que exista el a
|
||||
var h = false;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Regresa el tiempo tanscurrido en (datepart) desde la ultima visita.\n
|
||||
* datepart: 'y', 'm', 'w', 'd', 'h', 'n', 's' (default = n)
|
||||
* @param {*} file
|
||||
* @param {*} datepart
|
||||
*/
|
||||
function traeUltimaVisita(file, datepart = 'n'){
|
||||
// Node.js program to demonstrate the
|
||||
// fs.futimes() method
|
||||
let thisLog = false
|
||||
const fs = require('fs');
|
||||
let theFile = `${__dirname}/../chats/`+file+".json"
|
||||
if(thisLog) console.log("chkFile=", chkFile(theFile), datepart)
|
||||
if(chkFile(theFile)){
|
||||
// Get the file descriptor of the file
|
||||
const fd = fs.openSync(theFile);
|
||||
// console.log("Details before changing time:");
|
||||
// Get the stats object of the file
|
||||
if(thisLog) console.log(new Date())
|
||||
prevStats = fs.statSync(theFile);
|
||||
// Access the modified and access time of the file
|
||||
if(thisLog) console.log("Modification Time:", prevStats.mtime);
|
||||
if(thisLog) console.log("Access Time:", prevStats.atime);
|
||||
// Get the current time to change the timestamps
|
||||
let changedModifiedTime = new Date();
|
||||
let changedAccessTime = new Date();
|
||||
// Use the futimes() function to assign
|
||||
// the new timestamps to the file descriptor
|
||||
fs.futimes(fd, changedAccessTime, changedModifiedTime, ()=>{})
|
||||
if(thisLog) console.log("dd=", dateDiff(datepart, prevStats.atime, changedAccessTime))
|
||||
if(thisLog) console.log(new Date())
|
||||
return dateDiff(datepart, prevStats.atime, changedAccessTime)
|
||||
}
|
||||
else { return 0 }
|
||||
}
|
||||
/**
|
||||
* Regresa el tiempo transcurrido en (datepart) entre las fechas dadas.
|
||||
* datepart: 'y', 'm', 'w', 'd', 'h', 'n', 's'
|
||||
* @param {*} datepart
|
||||
* @param {*} fromdate
|
||||
* @param {*} todate
|
||||
* @returns
|
||||
*/
|
||||
function dateDiff(datepart, fromdate, todate){
|
||||
datepart = datepart.toLowerCase();
|
||||
var diff = todate - fromdate;
|
||||
var divideBy = { w:604800000,
|
||||
d:86400000,
|
||||
h:3600000,
|
||||
n:60000,
|
||||
s:1000
|
||||
};
|
||||
return Math.floor( diff/divideBy[datepart]);
|
||||
}
|
||||
|
||||
module.exports = { get, reply, getIA, saveMessage, stepsInitial, vamosA, traeUltimaVisita } //MOD by CHV - Agregamos "stepsInitial" para usarlos en "apps.js"
|
||||
394
adapter/test.js
Normal file
394
adapter/test.js
Normal file
@@ -0,0 +1,394 @@
|
||||
+++++++++++++++++++++++++++++++++++++ INICIO +++++++++++++++++++++++++++++++++++++++
|
||||
HORA:4:55:56 PM FROM:5215519561677@c.us, BODY:/Guna, HASMEDIA:false
|
||||
NUEVA RESPUESTA= Mensaje de getGunaCats
|
||||
############# Encontramos Funcion, ejecutamos funcion getGunaCats
|
||||
1 { id: 'CHOCOLATE', title: 'CHOCOLATE' }
|
||||
2 { id: 'DULCES', title: 'DULCES' }
|
||||
lasOpciones=[object Object]
|
||||
List {
|
||||
description: 'Buenas tardes, selecciona una categoría 👇🏽',
|
||||
buttonText: 'Ver las categorías',
|
||||
title: 'Categorías',
|
||||
footer: 'Selecciona',
|
||||
sections: [ { title: 'Categorías', rows: [Array] } ]
|
||||
}
|
||||
<ref *1> Client {
|
||||
_events: [Object: null prototype] {
|
||||
qr: [Function (anonymous)],
|
||||
ready: [Function (anonymous)],
|
||||
auth_failure: [Function (anonymous)],
|
||||
authenticated: [Function (anonymous)],
|
||||
message: [AsyncFunction (anonymous)],
|
||||
message_create: [AsyncFunction (anonymous)]
|
||||
},
|
||||
_eventsCount: 6,
|
||||
_maxListeners: undefined,
|
||||
options: {
|
||||
authStrategy: LocalAuth {
|
||||
dataPath: 'C:\\Users\\cheve\\Documents\\GitHub\\botDemoGuna\\.wwebjs_auth',
|
||||
clientId: undefined,
|
||||
client: [Circular *1],
|
||||
userDataDir: 'C:\\Users\\cheve\\Documents\\GitHub\\botDemoGuna\\.wwebjs_auth\\session'
|
||||
},
|
||||
puppeteer: {
|
||||
headless: true,
|
||||
args: [Array],
|
||||
defaultViewport: null,
|
||||
userDataDir: 'C:\\Users\\cheve\\Documents\\GitHub\\botDemoGuna\\.wwebjs_auth\\session'
|
||||
},
|
||||
authTimeoutMs: 0,
|
||||
qrMaxRetries: 0,
|
||||
takeoverOnConflict: false,
|
||||
takeoverTimeoutMs: 0,
|
||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36',
|
||||
ffmpegPath: 'ffmpeg',
|
||||
bypassCSP: false
|
||||
},
|
||||
authStrategy: LocalAuth {
|
||||
dataPath: 'C:\\Users\\cheve\\Documents\\GitHub\\botDemoGuna\\.wwebjs_auth',
|
||||
clientId: undefined,
|
||||
client: [Circular *1],
|
||||
userDataDir: 'C:\\Users\\cheve\\Documents\\GitHub\\botDemoGuna\\.wwebjs_auth\\session'
|
||||
},
|
||||
pupBrowser: <ref *2> Browser {
|
||||
eventsMap: Map(2) { 'targetcreated' => [], 'targetchanged' => [] },
|
||||
emitter: {
|
||||
all: [Map],
|
||||
on: [Function: on],
|
||||
off: [Function: off],
|
||||
emit: [Function: emit]
|
||||
},
|
||||
_ignoredTargets: Set(0) {},
|
||||
_ignoreHTTPSErrors: false,
|
||||
_defaultViewport: null,
|
||||
_process: ChildProcess {
|
||||
_events: [Object: null prototype],
|
||||
_eventsCount: 1,
|
||||
_maxListeners: undefined,
|
||||
_closesNeeded: 2,
|
||||
_closesGot: 0,
|
||||
connected: false,
|
||||
signalCode: null,
|
||||
exitCode: null,
|
||||
killed: false,
|
||||
spawnfile: 'C:\\Users\\cheve\\Documents\\GitHub\\botDemoGuna\\node_modules\\puppeteer\\.local-chromium\\win64-982053\\chrome-win\\chrome.exe',
|
||||
_handle: [Process],
|
||||
spawnargs: [Array],
|
||||
pid: 7188,
|
||||
stdin: [Socket],
|
||||
stdout: null,
|
||||
stderr: [Socket],
|
||||
stdio: [Array],
|
||||
[Symbol(kCapture)]: false
|
||||
},
|
||||
_screenshotTaskQueue: TaskQueue { _chain: [Promise] },
|
||||
_connection: Connection {
|
||||
eventsMap: [Map],
|
||||
emitter: [Object],
|
||||
_lastId: 372,
|
||||
_sessions: [Map],
|
||||
_closed: false,
|
||||
_callbacks: Map(0) {},
|
||||
_url: 'ws://127.0.0.1:49386/devtools/browser/8ba98a74-7751-45aa-8256-8f82b8312e65',
|
||||
_delay: 0,
|
||||
_transport: [NodeWebSocketTransport]
|
||||
},
|
||||
_closeCallback: [Function: bound close],
|
||||
_targetFilterCallback: [Function (anonymous)],
|
||||
_defaultContext: BrowserContext {
|
||||
eventsMap: Map(0) {},
|
||||
emitter: [Object],
|
||||
_connection: [Connection],
|
||||
_browser: [Circular *2],
|
||||
_id: undefined
|
||||
},
|
||||
_contexts: Map(0) {},
|
||||
_targets: Map(5) {
|
||||
'4904d96d-4dec-4069-95d8-fe7d70f62b06' => [Target],
|
||||
'71cc8c5e-8516-49de-9387-b2940074aea5' => [Target],
|
||||
'C7071524BC87DF4C8E9569AD3FBB7348' => [Target],
|
||||
'1D7791C3C62A14FB306A0ABD1CD86677' => [Target],
|
||||
'969B67293789E4A52B827E4619DF58D7' => [Target]
|
||||
}
|
||||
},
|
||||
pupPage: <ref *3> Page {
|
||||
eventsMap: Map(1) { 'framenavigated' => [Array] },
|
||||
emitter: {
|
||||
all: [Map],
|
||||
on: [Function: on],
|
||||
off: [Function: off],
|
||||
emit: [Function: emit]
|
||||
},
|
||||
_closed: false,
|
||||
_timeoutSettings: TimeoutSettings {
|
||||
_defaultTimeout: null,
|
||||
_defaultNavigationTimeout: null
|
||||
},
|
||||
_pageBindings: Map(12) {
|
||||
'loadingScreen' => [AsyncFunction (anonymous)],
|
||||
'qrChanged' => [AsyncFunction (anonymous)],
|
||||
'onAddMessageEvent' => [Function (anonymous)],
|
||||
'onChangeMessageTypeEvent' => [Function (anonymous)],
|
||||
'onChangeMessageEvent' => [Function (anonymous)],
|
||||
'onRemoveMessageEvent' => [Function (anonymous)],
|
||||
'onMessageAckEvent' => [Function (anonymous)],
|
||||
'onMessageMediaUploadedEvent' => [Function (anonymous)],
|
||||
'onAppStateChangedEvent' => [AsyncFunction (anonymous)],
|
||||
'onBatteryStateChangedEvent' => [Function (anonymous)],
|
||||
'onIncomingCall' => [Function (anonymous)],
|
||||
'onReaction' => [Function (anonymous)]
|
||||
},
|
||||
_javascriptEnabled: true,
|
||||
_workers: Map(1) { '96E97F3B444D00EB81EFEFDBC3128749' => [WebWorker] },
|
||||
_fileChooserInterceptors: Set(0) {},
|
||||
_userDragInterceptionEnabled: false,
|
||||
_handlerMap: WeakMap { <items unknown> },
|
||||
_client: CDPSession {
|
||||
eventsMap: [Map],
|
||||
emitter: [Object],
|
||||
_callbacks: Map(0) {},
|
||||
_connection: [Connection],
|
||||
_targetType: 'page',
|
||||
_sessionId: '44F15C73737F3B036CBCBE340984F10E'
|
||||
},
|
||||
_target: Target {
|
||||
_targetInfo: [Object],
|
||||
_browserContext: [BrowserContext],
|
||||
_targetId: 'C7071524BC87DF4C8E9569AD3FBB7348',
|
||||
_sessionFactory: [Function (anonymous)],
|
||||
_ignoreHTTPSErrors: false,
|
||||
_defaultViewport: null,
|
||||
_screenshotTaskQueue: [TaskQueue],
|
||||
_pagePromise: [Promise],
|
||||
_workerPromise: null,
|
||||
_initializedCallback: [Function (anonymous)],
|
||||
_initializedPromise: [Promise],
|
||||
_closedCallback: [Function (anonymous)],
|
||||
_isClosedPromise: [Promise],
|
||||
_isInitialized: true
|
||||
},
|
||||
_keyboard: Keyboard {
|
||||
_modifiers: 0,
|
||||
_pressedKeys: Set(0) {},
|
||||
_client: [CDPSession]
|
||||
},
|
||||
_mouse: Mouse {
|
||||
_x: 0,
|
||||
_y: 0,
|
||||
_button: 'none',
|
||||
_client: [CDPSession],
|
||||
_keyboard: [Keyboard]
|
||||
},
|
||||
_touchscreen: Touchscreen { _client: [CDPSession], _keyboard: [Keyboard] },
|
||||
_accessibility: Accessibility { _client: [CDPSession] },
|
||||
_frameManager: FrameManager {
|
||||
eventsMap: [Map],
|
||||
emitter: [Object],
|
||||
_frames: [Map],
|
||||
_contextIdToContext: [Map],
|
||||
_isolatedWorlds: [Set],
|
||||
_client: [CDPSession],
|
||||
_page: [Circular *3],
|
||||
_networkManager: [NetworkManager],
|
||||
_timeoutSettings: [TimeoutSettings],
|
||||
_mainFrame: [Frame]
|
||||
},
|
||||
_emulationManager: EmulationManager {
|
||||
_emulatingMobile: false,
|
||||
_hasTouch: false,
|
||||
_client: [CDPSession]
|
||||
},
|
||||
_tracing: Tracing { _recording: false, _path: '', _client: [CDPSession] },
|
||||
_coverage: Coverage { _jsCoverage: [JSCoverage], _cssCoverage: [CSSCoverage] },
|
||||
_screenshotTaskQueue: TaskQueue { _chain: [Promise] },
|
||||
_viewport: null
|
||||
},
|
||||
info: ClientInfo {
|
||||
pushname: 'Omega',
|
||||
wid: {
|
||||
server: 'c.us',
|
||||
user: '5215527026728',
|
||||
_serialized: '5215527026728@c.us'
|
||||
},
|
||||
me: {
|
||||
server: 'c.us',
|
||||
user: '5215527026728',
|
||||
_serialized: '5215527026728@c.us'
|
||||
},
|
||||
phone: undefined,
|
||||
platform: 'android'
|
||||
},
|
||||
interface: InterfaceController {
|
||||
pupPage: <ref *3> Page {
|
||||
eventsMap: [Map],
|
||||
emitter: [Object],
|
||||
_closed: false,
|
||||
_timeoutSettings: [TimeoutSettings],
|
||||
_pageBindings: [Map],
|
||||
_javascriptEnabled: true,
|
||||
_workers: [Map],
|
||||
_fileChooserInterceptors: Set(0) {},
|
||||
_userDragInterceptionEnabled: false,
|
||||
_handlerMap: [WeakMap],
|
||||
_client: [CDPSession],
|
||||
_target: [Target],
|
||||
_keyboard: [Keyboard],
|
||||
_mouse: [Mouse],
|
||||
_touchscreen: [Touchscreen],
|
||||
_accessibility: [Accessibility],
|
||||
_frameManager: [FrameManager],
|
||||
_emulationManager: [EmulationManager],
|
||||
_tracing: [Tracing],
|
||||
_coverage: [Coverage],
|
||||
_screenshotTaskQueue: [TaskQueue],
|
||||
_viewport: null
|
||||
}
|
||||
},
|
||||
theMsg: Message {
|
||||
_data: {
|
||||
id: [Object],
|
||||
body: '/Guna',
|
||||
type: 'chat',
|
||||
t: 1675378555,
|
||||
notifyName: 'Alfredo',
|
||||
from: '5215519561677@c.us',
|
||||
to: '5215527026728@c.us',
|
||||
self: 'in',
|
||||
ack: 1,
|
||||
isNewMsg: true,
|
||||
star: false,
|
||||
kicNotified: false,
|
||||
recvFresh: true,
|
||||
isFromTemplate: false,
|
||||
pollInvalidated: false,
|
||||
isSentCagPollCreation: false,
|
||||
latestEditMsgKey: null,
|
||||
latestEditSenderTimestampMs: null,
|
||||
broadcast: false,
|
||||
mentionedJidList: [],
|
||||
isVcardOverMmsDocument: false,
|
||||
isForwarded: false,
|
||||
hasReaction: false,
|
||||
productHeaderImageRejected: false,
|
||||
lastPlaybackProgress: 0,
|
||||
isDynamicReplyButtonsMsg: false,
|
||||
isMdHistoryMsg: false,
|
||||
stickerSentTs: 0,
|
||||
isAvatar: false,
|
||||
requiresDirectConnection: false,
|
||||
pttForwardedFeaturesEnabled: true,
|
||||
isEphemeral: false,
|
||||
isStatusV3: false,
|
||||
links: []
|
||||
},
|
||||
mediaKey: undefined,
|
||||
id: {
|
||||
fromMe: false,
|
||||
remote: '5215519561677@c.us',
|
||||
id: '3A98BA96F6922B404213',
|
||||
_serialized: 'false_5215519561677@c.us_3A98BA96F6922B404213'
|
||||
},
|
||||
ack: 1,
|
||||
hasMedia: false,
|
||||
body: '/Guna',
|
||||
type: 'chat',
|
||||
timestamp: 1675378555,
|
||||
from: '5215519561677@c.us',
|
||||
to: '5215527026728@c.us',
|
||||
author: undefined,
|
||||
deviceType: 'ios',
|
||||
isForwarded: false,
|
||||
forwardingScore: 0,
|
||||
isStatus: false,
|
||||
isStarred: false,
|
||||
broadcast: false,
|
||||
fromMe: false,
|
||||
hasQuotedMsg: false,
|
||||
duration: undefined,
|
||||
location: undefined,
|
||||
vCards: [],
|
||||
inviteV4: undefined,
|
||||
mentionedIds: [],
|
||||
orderId: undefined,
|
||||
token: undefined,
|
||||
isGif: false,
|
||||
isEphemeral: false,
|
||||
links: [],
|
||||
numero: '5215519561677@c.us',
|
||||
key: 'gunaCats',
|
||||
lastStep: null,
|
||||
step: 'gunaCats',
|
||||
trigger: null,
|
||||
replyMessage: 'Mensaje de getGunaCats'
|
||||
},
|
||||
[Symbol(kCapture)]: false
|
||||
}
|
||||
+++++++++++++++++++++++++++++++++++++ INICIO +++++++++++++++++++++++++++++++++++++++
|
||||
HORA:4:56:00 PM FROM:5215519561677@c.us, BODY:DULCES, HASMEDIA:false
|
||||
======= KEY ES NULO USAMOS REGEXP =======
|
||||
KEY=|doblemensaje|
|
||||
Esta Key=doblemensaje - pasoReq=menu - PasoAnt=undefined|gunaCats
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=menu - PasoAnt=undefined
|
||||
KEY=|recibenombre|
|
||||
Esta Key=recibenombre - pasoReq=opcion3 - PasoAnt=undefined|gunaCats
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=opcion3 - PasoAnt=undefined
|
||||
KEY=|gRevisaCliente|
|
||||
Esta Key=gRevisaCliente - pasoReq=gallina - PasoAnt=undefined|gunaCats
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=gallina - PasoAnt=undefined
|
||||
KEY=|gGuardainfo|
|
||||
Esta Key=gGuardainfo - pasoReq=gRevisaCliente - PasoAnt=undefined|gunaCats
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=gRevisaCliente - PasoAnt=undefined
|
||||
KEY=|paq3|
|
||||
Esta Key=paq3 - pasoReq=menu - PasoAnt=undefined|gunaCats
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=menu - PasoAnt=undefined
|
||||
KEY=|Desbloqueo|
|
||||
Esta Key=Desbloqueo - pasoReq=soporte - PasoAnt=undefined|gunaCats
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=soporte - PasoAnt=undefined
|
||||
KEY=|gunaCats2|
|
||||
Esta Key=gunaCats2 - pasoReq=gunaCats - PasoAnt=undefined|gunaCats
|
||||
NUEVA RESPUESTA= Mensaje de getGunaCats2
|
||||
############# Encontramos Funcion, ejecutamos funcion getGunaSubtipo
|
||||
1 { id: 'KINDER', title: 'KINDER' }
|
||||
2 { id: 'CHOCOLATE', title: 'CHOCOLATE' }
|
||||
lasOpciones=undefined
|
||||
+++++++++++++++++++++++++++++++++++++ INICIO +++++++++++++++++++++++++++++++++++++++
|
||||
HORA:4:56:05 PM FROM:5215519561677@c.us, BODY:CHOCOLATE, HASMEDIA:false
|
||||
======= KEY ES NULO USAMOS REGEXP =======
|
||||
KEY=|doblemensaje|
|
||||
Esta Key=doblemensaje - pasoReq=menu - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=menu - PasoAnt=undefined
|
||||
KEY=|recibenombre|
|
||||
Esta Key=recibenombre - pasoReq=opcion3 - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=opcion3 - PasoAnt=undefined
|
||||
KEY=|gRevisaCliente|
|
||||
Esta Key=gRevisaCliente - pasoReq=gallina - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=gallina - PasoAnt=undefined
|
||||
KEY=|gGuardainfo|
|
||||
Esta Key=gGuardainfo - pasoReq=gRevisaCliente - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=gRevisaCliente - PasoAnt=undefined
|
||||
KEY=|paq3|
|
||||
Esta Key=paq3 - pasoReq=menu - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=menu - PasoAnt=undefined
|
||||
KEY=|Desbloqueo|
|
||||
Esta Key=Desbloqueo - pasoReq=soporte - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=soporte - PasoAnt=undefined
|
||||
KEY=|gunaCats2|
|
||||
Esta Key=gunaCats2 - pasoReq=gunaCats - PasoAnt=undefined|gunaCats2
|
||||
NO CUMPLE PASO REQ
|
||||
pasoReq=gunaCats - PasoAnt=undefined
|
||||
KEY=|gunaProds|
|
||||
Esta Key=gunaProds - pasoReq=gunaCats2 - PasoAnt=undefined|gunaCats2
|
||||
NUEVA RESPUESTA= Mensaje de getGunaCats2
|
||||
############# Encontramos Funcion, ejecutamos funcion getGunaProds
|
||||
48
appBaileys.js
Normal file
48
appBaileys.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* ⚡⚡⚡ DECLARAMOS LAS LIBRERIAS y CONSTANTES A USAR! ⚡⚡⚡
|
||||
*/
|
||||
require('dotenv').config()
|
||||
global.provider = process.env.PROVIDER || 'wwebjs';
|
||||
const { Client } = require('whatsapp-web.js');
|
||||
const { generateImage, cleanNumber, checkEnvFile, createClient, isValidNumber } = require('./controllers/handle')
|
||||
const { initBot, traeVariables } = require('./provider/baileys')
|
||||
const { sendMedia, sendMessage, lastTrigger, sendMessageButton, sendMessageList, readChat } = require('./controllers/send_baileys');
|
||||
let enviado = false
|
||||
|
||||
function listenMessage(client){
|
||||
client.ev.on('messages.upsert', async msg => {
|
||||
let {from, body, nombre} = traeVariables(msg)
|
||||
if (from === 'status@broadcast' || msg.type !== 'notify') { return }
|
||||
client.theMsg = msg;
|
||||
console.log("######################### INICIO ############################")
|
||||
console.log("from, Body y Nombre = ", "|", from, "|", body, "|", nombre, "|", msg?.type)
|
||||
console.log("CLIENT:", client)
|
||||
// console.log('KEY=', msg.messages.key)
|
||||
// console.log('MESSAGES=', msg.messages)
|
||||
console.log('MESSAGE__=', msg.messages[0])
|
||||
// await sock.sendMessage(m.messages[0].key.remoteJid, { text: 'hola como estas' })
|
||||
if(!enviado) {
|
||||
console.log("########## Enviamos mensaje")
|
||||
sendMessage(client, "5215554192439@s.whatsapp.net", "hola")
|
||||
|
||||
const buttonMessage = [
|
||||
{"body":"boton 1"},
|
||||
{"body":"boton 2"}
|
||||
]
|
||||
|
||||
console.log("Enviamos botones = ", from, buttonMessage)
|
||||
sendMessageButton(client, "5215554192439@s.whatsapp.net", "texto", buttonMessage)
|
||||
|
||||
|
||||
enviado = true
|
||||
}
|
||||
|
||||
})
|
||||
enviado = false
|
||||
}
|
||||
|
||||
async function inicializaBot(){
|
||||
const ib = await initBot()
|
||||
listenMessage(ib)
|
||||
}
|
||||
inicializaBot()
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH+.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH+.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"rsondEJpV3MvhuJ/zwcW9+s1SZH2e4zfmajwpPFJjls=","fingerprint":{"rawId":1190470563,"currentIndex":5,"deviceIndexes":[0,1,5]},"timestamp":"1676571096503"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH0.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"5JXiTAyoJzZVyNA/fw3LWG7FF9hCMCkNQKE6a09AasQ=","fingerprint":{"rawId":1190470562,"currentIndex":19,"deviceIndexes":[0,18,19]},"timestamp":"1674539555339"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH1.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH1.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"rOVUdTS4QvcqLQW71/qTg68udlFuXkxztaOqcsJySy0=","fingerprint":{"rawId":1190470562,"currentIndex":20,"deviceIndexes":[0,19,20]},"timestamp":"0"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH2.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH2.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"qHQ/sTwK2Btx0CsHBng++3tnu343DtybQKl+da3t558=","fingerprint":{"rawId":1190470562,"currentIndex":22,"deviceIndexes":[0,20,21,22]},"timestamp":"1675534531066"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH3.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH3.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"KqrLOKmtiQK7weUQHye3XQKyd4UXpLC6PVqVQTvpx3Y=","fingerprint":{"rawId":1190470562,"currentIndex":23,"deviceIndexes":[0,21,22,23]},"timestamp":"0"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH4.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH4.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"LMy/lGpdw2jFhTTJfdE13dw5QJsSsCMEWF6XuYGzEsw=","fingerprint":{"rawId":1190470562,"currentIndex":24,"deviceIndexes":[0,22,23,24]},"timestamp":"1676511951950"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH5.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH5.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"aIuGjuRnpi56k7Vv//KrUZww+zZkty0y/+f1s4DnzfA=","fingerprint":{"rawId":1190470562,"currentIndex":24,"deviceIndexes":[0,23,24]},"timestamp":"1676511956133"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH6.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH6.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"mfbitKh113qwV9IR0cHVjOMhsDiYEedkm/eOq1JBF58=","fingerprint":{"rawId":1190470562,"currentIndex":24,"deviceIndexes":[0,24]},"timestamp":"1676511959435"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH7.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH7.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"sjYMEa8AStl+akC5QRj015xeCRJwi8iSyl9bIiTwV30=","fingerprint":{"rawId":1190470563,"currentIndex":2,"deviceIndexes":[0,1,2]},"timestamp":"1676514874744"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH8.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH8.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"dzRUXPfxEjGod+WqHV8ha9cZzMlFc5SDvG3zTQbbZWk=","fingerprint":{"rawId":1190470563,"currentIndex":3,"deviceIndexes":[0,1,3]},"timestamp":"1676515049252"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACH9.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACH9.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"xSPhDl7HIRGemipcSp81cqUC/EE5ctcVRr/h1U1+4Tg=","fingerprint":{"rawId":1190470563,"currentIndex":4,"deviceIndexes":[0,1,4]},"timestamp":"1676515218431"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHm.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHm.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"+olDypK+i1ssS7Tbg8yqOytmQd5u//pZfQ+v1O1KC60=","fingerprint":{"rawId":1190470561,"currentIndex":1,"deviceIndexes":[0,1]},"timestamp":"0"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHn.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHn.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"s9MgV4gC9Q2Yzsmu7NpD3Bw0eAjhFc2SeBggWrEHlfw=","fingerprint":{"rawId":1190470562,"currentIndex":1,"deviceIndexes":[0,1]},"timestamp":"0"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHo.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHo.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"qYCOwJ2vAPvT+MJWITPNpCJLMhKWeb74g0rPV+RpVe4=","fingerprint":{"rawId":1190470562,"currentIndex":6,"deviceIndexes":[0,2,3,5]},"timestamp":"1673921678832"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHp.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHp.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"TgbK+pOhoULH2zKbl3ePO+sfdo7vWvGOgbZNEspIyo8=","fingerprint":{"rawId":1190470562,"currentIndex":6,"deviceIndexes":[0,3,5]},"timestamp":"1673921683289"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHq.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHq.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"9NseEe1GQbmUySTlTsKBsV2TUny7F3lfrM3LAy6Qhvo=","fingerprint":{"rawId":1190470562,"currentIndex":8,"deviceIndexes":[0,3,7,8]},"timestamp":"0"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHr.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHr.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"+/WB8rIMnHAvZDuxN0I2vG/7cR1d/U4NMNqUknfADNg=","fingerprint":{"rawId":1190470562,"currentIndex":9,"deviceIndexes":[0,7,8,9]},"timestamp":"1673969921050"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHs.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHs.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"kkJjls6R2k3R889NlY2n4CDtz3d2d9XdTLYKZcKIxUk=","fingerprint":{"rawId":1190470562,"currentIndex":9,"deviceIndexes":[0,8,9]},"timestamp":"1673969923885"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHt.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHt.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"ckSGxKH9j+224QQgYZnWNjU9GGAFVEgpX7Ywpu0hdPU=","fingerprint":{"rawId":1190470562,"currentIndex":11,"deviceIndexes":[0,9,11]},"timestamp":"0"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHu.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHu.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"c3WklBNFR2GN1y+s0SijEW66Wu+dacHBveIapiUK7eQ=","fingerprint":{"rawId":1190470562,"currentIndex":12,"deviceIndexes":[0,11,12]},"timestamp":"1674088411745"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHv.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHv.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"oqUf8dDCsHlcT49L0too22+kX6TQ2uuHnytgTsBuvjg=","fingerprint":{"rawId":1190470562,"currentIndex":13,"deviceIndexes":[0,12,13]},"timestamp":"1674141267159"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHw.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHw.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"nL2p48Ft7Cpi6D2QS5c/KuKlNtOEICJEYxuRy8+PnNQ=","fingerprint":{"rawId":1190470562,"currentIndex":16,"deviceIndexes":[16,0,12,13]},"timestamp":"1674188583557"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHx.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHx.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"ZmCdM3XktvViGK8F4LYMifw61NYUXcPmUMC/HNmAGcA=","fingerprint":{"rawId":1190470562,"currentIndex":16,"deviceIndexes":[16,0,13]},"timestamp":"1674188704021"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHy.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHy.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"m/J5nu/ljgl0R1tYXRXVtmBi0kW+T2YQkhoOx1uQuhs=","fingerprint":{"rawId":1190470562,"currentIndex":17,"deviceIndexes":[0,17,13]},"timestamp":"1674188863193"}
|
||||
1
baileys_sessions/app-state-sync-key-AAAAACHz.json
Normal file
1
baileys_sessions/app-state-sync-key-AAAAACHz.json
Normal file
@@ -0,0 +1 @@
|
||||
{"keyData":"EJCgYXCA3vuDxnKtWr+PyGZMgCyI7lPpYCbGk96qH70=","fingerprint":{"rawId":1190470562,"currentIndex":17,"deviceIndexes":[0,17]},"timestamp":"0"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":24,"hash":{"type":"Buffer","data":"EKT/6t6gsECWm2VVnzrfk78205OjlmMFjOLqjKzjIxbP6Nths3wcmNiJW9/UNTvItc89Jtn+xZwlD1PUA0ZSjbIG3szOeMhyZFrfQvZgopSNfSMVIN1PwuTMqjIsM0xhEfzP1nWI6ksFpZTKkTcXtpKukgg2dDuQWJndA1fQjh4="},"indexValueMap":{"ztGh0PeVk91WtvEEcV67TeplNk9MJTjftdsLa3oCaXo=":{"valueMac":{"type":"Buffer","data":"IYNe+D0TmsEWl/ry5CUOq9jDeBEN//nvNXp1mg17Pqo="}},"uSvfEptt0Iog1tlb0D4JmdwVoIjuKj9R79BU7gyBMt0=":{"valueMac":{"type":"Buffer","data":"4HYCanalfvCZPJ0VNxEhJ0phc8kln/uoBOVBGbfTn+k="}},"TDuWokLNV6TFgHLlhJGvw9Wh7A0ygi3fzw2jEGoS5BQ=":{"valueMac":{"type":"Buffer","data":"5tf2a0Y8ATuk7dkeVhNjLeCCR+iohUGNA9wtVd/2uOI="}}}}
|
||||
File diff suppressed because one or more lines are too long
1
baileys_sessions/app-state-sync-version-regular.json
Normal file
1
baileys_sessions/app-state-sync-version-regular.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version":21,"hash":{"type":"Buffer","data":"BwYxPL53EqCaBWB39wxtRXHNJToB0eNjMCWD0vHj7vMaxVb5rBylEMEmYG7QTiIY21PySys1OAj6aGXt2g0e4gYWHQceDDsZQv/TGB8rdXlWEqN+bc+XEMG106UXzT71Tl+mp/SCHnqbF+N7zNoS0pZLhQHFgQxvP7w211977aI="},"indexValueMap":{"00JfoWdMewU/Yso0ZRBLV0lYlWNLt5bJhG6ST2yFCjg=":{"valueMac":{"type":"Buffer","data":"30hDDQKBeGn6yKiztaCE6gv8MM4OXWjEaRmxSLQMSRs="}},"69vnb+0BbE90juS144qY/EUFsA3qedfSaURsD6D6cSQ=":{"valueMac":{"type":"Buffer","data":"kXII09dN7mO8xWjqs/xi3EkUi6UgkmeomY+mQvDSF/I="}}}}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":31,"hash":{"type":"Buffer","data":"wbi2dLKTiXanJl6YqIjnEvX3qhyKmpSIzpetjmxX4IgTmesMmpU1iiNBeGpwRd+Aqt3V9uSAdnGDhtg2E89pq4tJQ7F9MIToimJ5m4sJnwB8IUVAsTy/hwGsnlyHTsoDYNBGQ0H+O3mJiSBJYfWd0VFIvPYOtDplP60C1ibWk1k="},"indexValueMap":{"oFj0S8cAEd0hMd4zRkz4OiKeaUiNj3fP1BOoIHPbpzM=":{"valueMac":{"type":"Buffer","data":"xgxtxJ1PC/oEi4R9Vd6bg46tAawy1SprrUq7GZsbJHo="}},"vC/p14cwe6PiWLJWo9+KbwnEEqDK7Q5V2/A+uBNuFeM=":{"valueMac":{"type":"Buffer","data":"V/m4870YxcZ7CoLoxe4BmndBoxzIMQHdGk9nkbt0pYU="}},"FkpTEu+rAiFOIb6liABHROC6f1QiZD5xgbajm9QRjUc=":{"valueMac":{"type":"Buffer","data":"IoXg7C8BRcFdq/DxWirJU4/SOwTyWlaZAoL4DG8UZSY="}},"T1O4dyIdAeYUiRa9yMSPK0fW3TdX9JusZlf/zHeuCQA=":{"valueMac":{"type":"Buffer","data":"zFXslQ44cELxx/AmPMg4ynDt51Qq0BUYdH5Tg62E8Cg="}},"wuPmSdD6/rM6mYGkfZKk0tVQGgGq9l9j2SyUhlrBBYM=":{"valueMac":{"type":"Buffer","data":"Yl44cJywVr17GZr/CX4zMfxS28AjEMOQynBOP2uZSHI="}}}}
|
||||
1
baileys_sessions/app-state-sync-version-regular_low.json
Normal file
1
baileys_sessions/app-state-sync-version-regular_low.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version":21,"hash":{"type":"Buffer","data":"XyYoUVwfmXz1CabrmkNpmH4cdzoa/v2KJ7zpXU/V7bIci2qZ7YANQc6GMguOQHiuFxcKOihIwC1QvsfB2APhupuJshDOYGJ36imiyZbU/kXgsWml870PBxJSIe31MwLDheSn/PD/59K4qDdHio2vhvRyjKrhkyX18e/6ozYx8+c="},"indexValueMap":{"wAbs5mgnj/26VJQwzEQv/zXsGvta5i5wXmjFxrZUoVo=":{"valueMac":{"type":"Buffer","data":"SfRHv8BCf6c/hefeDnJJu3svZJipWqr6dRwU3Z06cmw="}},"AOUpDgUj+uDEu5/8PyA2FpiKXMXezTP2ietqYfijLQ0=":{"valueMac":{"type":"Buffer","data":"Ki/ZeNUzCajmSNbPv0ySIJzTT/C7oD3hO870+BPEPdc="}},"EAd1n+y7+iE759qN63zTrMJJ9TRC+kF5amDUDm7RgXU=":{"valueMac":{"type":"Buffer","data":"sHzbkD/S55UODa/dNSTXcOb7guT/yGN6+Cocbh0yVwg="}},"/sJvVUNtLfNPIxh7yavBOfeHPSfxi5NsyRVY7zA+HkQ=":{"valueMac":{"type":"Buffer","data":"WImFEiGe18OS5TtzV980Yub8+zTTkg//U4lZpd4665U="}},"AEsdqxd/8s0GX+n2aUhKpuUacUyim9zOxa1UozY+zzM=":{"valueMac":{"type":"Buffer","data":"TcilQVRRodrIUXQb7wuMfRxApAwO/skJW6sHCKgR7T0="}},"SgY7Mf7Nbd4cEn2ynj25PbHuzPn3shugfLOCzmtuWcc=":{"valueMac":{"type":"Buffer","data":"ixBnx/wCSvG16XE0EzwivXNO5E4YTSvTrYGuo43+sXw="}}}}
|
||||
1
baileys_sessions/creds.json
Normal file
1
baileys_sessions/creds.json
Normal file
@@ -0,0 +1 @@
|
||||
{"noiseKey":{"private":{"type":"Buffer","data":"aLR//PlXylo6ZClkRpUy/+foonbY/VJiPz484xRb11c="},"public":{"type":"Buffer","data":"5zq+UGmKNzUMa37lcYYl+pr9UbO18hzylHQdc0zPt0E="}},"signedIdentityKey":{"private":{"type":"Buffer","data":"GLVjZHq8cc79bXq9yMT05fj/MByZO2uDHLBK/X05bmY="},"public":{"type":"Buffer","data":"y5q8zX5ovLD+NRqSt1SjmUtpcXuopdjKP6m2RQ0tvXE="}},"signedPreKey":{"keyPair":{"private":{"type":"Buffer","data":"WAvwaMMx0SwUk29I/2xoteClKIaNLSPh+1VVyCJDk2Q="},"public":{"type":"Buffer","data":"6ApClV65HOUNYnZ/kIY6miyYwheS6kQJqdqVB9ykREc="}},"signature":{"type":"Buffer","data":"Yht91l6/hgu506RGlXz096KNb9uIvLdm86aAS7zbJntyFNhEx24zHxELJFbyHcIAaerwTUa4sVmRs634DUFejw=="},"keyId":1},"registrationId":248,"advSecretKey":"8/CEZCeK0rKHbPW9FpIsuuLYSlA1YWHEuhTPlVA/69s=","processedHistoryMessages":[{"key":{"remoteJid":"5215516611480@s.whatsapp.net","fromMe":true,"id":"4034737D106A0EE5659D854CA827BC6F"},"messageTimestamp":1676511987},{"key":{"remoteJid":"5215516611480@s.whatsapp.net","fromMe":true,"id":"DC372AE775FC9ECF5C2FA465199B7FC5"},"messageTimestamp":1676511987},{"key":{"remoteJid":"5215516611480@s.whatsapp.net","fromMe":true,"id":"EA7D63C0FAB2843FDEC6CF41D98580EE"},"messageTimestamp":1676511998}],"nextPreKeyId":31,"firstUnuploadedPreKeyId":31,"accountSettings":{"unarchiveChats":false},"account":{"details":"CKPH1LcEEO6Vtp8GGAE=","accountSignatureKey":"PXyviDQuvIGZg5auHtiAriQFOcp+1OwJ8zsQC6Vxm0c=","accountSignature":"8LUp4vkLUdRbqcgr/qnYcQ1+Gvr/dAR4W6QlhZjp4QZlG34cyk7cI0B0WxnrMERs5xroJGbFh82wZvIwcTubBg==","deviceSignature":"iSZQzYZ1TS7kRrOc643NOHA6DsAlzyV60chLtXQstVsrJy50lueWwajCuD2eA76ubTdeuDvlqOT8EWHM9AuKiw=="},"me":{"id":"5215516611480:25@s.whatsapp.net","name":"Casa"},"signalIdentities":[{"identifier":{"name":"5215516611480:25@s.whatsapp.net","deviceId":0},"identifierKey":{"type":"Buffer","data":"BT18r4g0LryBmYOWrh7YgK4kBTnKftTsCfM7EAulcZtH"}}],"platform":"android","lastAccountSyncTimestamp":1676512040,"myAppStateKeyId":"AAAAACH+"}
|
||||
1
baileys_sessions/pre-key-1.json
Normal file
1
baileys_sessions/pre-key-1.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"YHFSzhuu0XefzXRQPj73ZgigoHhh94MDX7O3HdRF/W4="},"public":{"type":"Buffer","data":"d5B4GQi/z1Mrnvxd2Dxigx9jlgNR1vNVjcjgZGinsFI="}}
|
||||
1
baileys_sessions/pre-key-10.json
Normal file
1
baileys_sessions/pre-key-10.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"IKWmSTgzUxIOLctv0j0QBo2mrajw6WSvtPMhcLr5Fmw="},"public":{"type":"Buffer","data":"YuSp9wx5nucebdJSVLlrk4d+L0w8dzWg4uGTtFMaWR8="}}
|
||||
1
baileys_sessions/pre-key-11.json
Normal file
1
baileys_sessions/pre-key-11.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"4AxALlhqWVdtmDVgema3V4PCDWBvTZZkwCltho7400w="},"public":{"type":"Buffer","data":"8rE01+G5g/gNQOVbFxKk/u/D+YpkK4/LK3M6l62jYw4="}}
|
||||
1
baileys_sessions/pre-key-12.json
Normal file
1
baileys_sessions/pre-key-12.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"qPsfL+j/ZJplsZjavkqizGIvRz5UMRAn8ymEELmDz3s="},"public":{"type":"Buffer","data":"g2SrEgGmfia/YiD+W8fr7NQ0xNKNcJ5+jKoXqYkdcHg="}}
|
||||
1
baileys_sessions/pre-key-13.json
Normal file
1
baileys_sessions/pre-key-13.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"gHH+SvcPEzNE7rLWbBHHDxd9tmI2nk1VY8ttO/KgpW4="},"public":{"type":"Buffer","data":"RnSKAOSBZ/lXf9euTmoqdeOcWu5HVmCeZ1oF4Na+ilk="}}
|
||||
1
baileys_sessions/pre-key-14.json
Normal file
1
baileys_sessions/pre-key-14.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"8AyxHJP6PdURzBDpRX8CgM/gOMidMwiM1FU3U8QhH08="},"public":{"type":"Buffer","data":"Scb5mvIKN0s1Qme4QQhuGV6QzQAzlyqDGuRPcrmQukA="}}
|
||||
1
baileys_sessions/pre-key-15.json
Normal file
1
baileys_sessions/pre-key-15.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"yDFykzhX/9VE61ZgwHxQlrAnD7wu0OHxuokf/PjsrkU="},"public":{"type":"Buffer","data":"0OAQTqVYq4aRbNTubfBhJ9aBAVj1YNYRn9E74OOoEWs="}}
|
||||
1
baileys_sessions/pre-key-16.json
Normal file
1
baileys_sessions/pre-key-16.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"sEU6eiWeA5ir5TrKpNl3E8RL5cL7Ws13jpzNfAD3rF8="},"public":{"type":"Buffer","data":"5vflHrPu20owAiwGT0IugAeKF2L06BKUIKE3YobxtDo="}}
|
||||
1
baileys_sessions/pre-key-17.json
Normal file
1
baileys_sessions/pre-key-17.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"KOAscUHlV4+cPI+ndB4CIFUUQRzWUVydNJfcM/dtGnc="},"public":{"type":"Buffer","data":"1yHk25vY0947V2XIwj/q7qhMcOhANmq0J8dBTqqVn3I="}}
|
||||
1
baileys_sessions/pre-key-18.json
Normal file
1
baileys_sessions/pre-key-18.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"SCjx4NFzbTrmlgv8CkwWs34OrztpR5bjjeiCB6Ti00U="},"public":{"type":"Buffer","data":"U15lE2gXwBUe0EmPAyIYp+lW/6V4AR0M8X5Tek0sUTw="}}
|
||||
1
baileys_sessions/pre-key-19.json
Normal file
1
baileys_sessions/pre-key-19.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"aLzVvPBSrZXlojkWJ47ljHZ212T8c0cpmQHamGWiGk4="},"public":{"type":"Buffer","data":"I59vMCoIBW/X+qpjk5tRZt3LWKxvDldX03f5Q/088ks="}}
|
||||
1
baileys_sessions/pre-key-2.json
Normal file
1
baileys_sessions/pre-key-2.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"qGQ9IS94YzN1UlatIAx+SPmT3unkHQt7TAthEuLRLGE="},"public":{"type":"Buffer","data":"czwPIMz9Tfu67NSwmqysbg/QjXgAFzL4oVezURxp8FY="}}
|
||||
1
baileys_sessions/pre-key-20.json
Normal file
1
baileys_sessions/pre-key-20.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"mLy/JViM1IUTw7tGbmLTTQAYn9uaP/gWCU9evuqQPUc="},"public":{"type":"Buffer","data":"UPGFCK7bKIaxek9iE4+3cWE4xIHxpf3040ocAy7F7kA="}}
|
||||
1
baileys_sessions/pre-key-21.json
Normal file
1
baileys_sessions/pre-key-21.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"4ITs08IrEv8dW5abfdg2H8s6cPJtpYAT13zJsuDSaUg="},"public":{"type":"Buffer","data":"gCoApsLAH2QYAIfl3f3L31bg4jL3e0cwHI6OEP9Wlxw="}}
|
||||
1
baileys_sessions/pre-key-22.json
Normal file
1
baileys_sessions/pre-key-22.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"CO14Yf87LQXBymSN8kucxUCGeVGTiv4HA/7GhMXWilM="},"public":{"type":"Buffer","data":"u56U8FJr9IM9yaQ+3/PRQccqLFceh4Wm9Cjv/ALVukI="}}
|
||||
1
baileys_sessions/pre-key-23.json
Normal file
1
baileys_sessions/pre-key-23.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"4EOuSuO4TljG7YZ1e0GXTud/MO6+l5BO89MCj7vjZ30="},"public":{"type":"Buffer","data":"7hnDkNFussVh7RZLPRhNUqFiD0siWRvbbxED1+uqgXA="}}
|
||||
1
baileys_sessions/pre-key-24.json
Normal file
1
baileys_sessions/pre-key-24.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"8K7ve2m9blTjDJMR9P0ebvGiySp46xxFb8T2C5BVrXw="},"public":{"type":"Buffer","data":"xKF70evZVkzh+LGoyFufhafxog7/Zpn09X2viw6RyCk="}}
|
||||
1
baileys_sessions/pre-key-25.json
Normal file
1
baileys_sessions/pre-key-25.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"+P8sfww+EiM6wXmpyvoPPio7s5wIMtXivK7F33KP0mg="},"public":{"type":"Buffer","data":"tEreX+5bpr25HBJlDvQmLrWRgRxEhkQvnf9RyfML/x4="}}
|
||||
1
baileys_sessions/pre-key-26.json
Normal file
1
baileys_sessions/pre-key-26.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"0G4vLdglHfq45SrcgxI4p4ekoBzIjkn/b8GFJU26BXM="},"public":{"type":"Buffer","data":"84xxsPfRGAoSvBKUWPTCnQJ7yVA8wvGseTSyowuzKgQ="}}
|
||||
1
baileys_sessions/pre-key-27.json
Normal file
1
baileys_sessions/pre-key-27.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"MKkM47jAYat4+0ujumCf1ca9yycAl2sCHjZ+w0nYAm4="},"public":{"type":"Buffer","data":"9GIS9Z1YoSTDQNUlfe4Fc6ujcmaeEJwmyOupLFB7YGc="}}
|
||||
1
baileys_sessions/pre-key-28.json
Normal file
1
baileys_sessions/pre-key-28.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"WMO4DHV4wQEhhHsR6IaGi4DO50q1JnJMtqqPJX1mFmM="},"public":{"type":"Buffer","data":"Errx1U1nyOF3EWAqmv21U5gXbF7xk7D4j4R+uzNKWUY="}}
|
||||
1
baileys_sessions/pre-key-29.json
Normal file
1
baileys_sessions/pre-key-29.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"kILpr6rpMGB9H3xH6Irm8fwFQs34PPeergvlAIveh2I="},"public":{"type":"Buffer","data":"sey4ZP17mw/mbRChFlH28M0Yq2OX2qR7iKB7SQs2B0M="}}
|
||||
1
baileys_sessions/pre-key-3.json
Normal file
1
baileys_sessions/pre-key-3.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"kJLaGVbfaPWXwqpwQMPjkFQL0xxuWhSoaXCRNL/j83w="},"public":{"type":"Buffer","data":"nimjXO6RKmrKZhQnzT4dcgbyGiAmjN31fq8m9mKh9RE="}}
|
||||
1
baileys_sessions/pre-key-30.json
Normal file
1
baileys_sessions/pre-key-30.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"yEmbjTjUv8LzyxTvIuGQWySv7zH2D1ubF1wZIMRlZ0U="},"public":{"type":"Buffer","data":"+NcB3zXH6OAu/MH7VDrrm9QmEJTeI3PjSMZ0D/ORDg4="}}
|
||||
1
baileys_sessions/pre-key-4.json
Normal file
1
baileys_sessions/pre-key-4.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"kAPwqsoreHzruSplFKJSGbXYZMavLHB3ubA8Dfy8Bls="},"public":{"type":"Buffer","data":"zwYg7MMOj0WGIB/gthqeQfmCQfshiVUXIBYC3YaO5Ak="}}
|
||||
1
baileys_sessions/pre-key-5.json
Normal file
1
baileys_sessions/pre-key-5.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"6AANkhB5n4Wi6tmZxXiLnyco7oSRK4e7cugczobDVl8="},"public":{"type":"Buffer","data":"1IjI7LiDYAQs7FnbGRNE2zRXBoNHeiT5ZqkoRq31+Xc="}}
|
||||
1
baileys_sessions/pre-key-6.json
Normal file
1
baileys_sessions/pre-key-6.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"6HmT4XDc4NgunR6aZW9UwUOq4Mo30P8Y7EhTuwhb0kE="},"public":{"type":"Buffer","data":"SSntsDeGFN57jCH59MU+dU0foIxyzrt8QPzmk4xArWA="}}
|
||||
1
baileys_sessions/pre-key-7.json
Normal file
1
baileys_sessions/pre-key-7.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"wEkyX9w8HqMTRcMCMo/SXBu0DjCNozLUHy/q1I4kil0="},"public":{"type":"Buffer","data":"foSPOVTnEdW9vWNMZXjWvTZUlgMWknYQvb8rmrFNLik="}}
|
||||
1
baileys_sessions/pre-key-8.json
Normal file
1
baileys_sessions/pre-key-8.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"+FW+HZE+/V1uQ8YGqphVOtkiuM1PiXt+SJXJjv/HGUE="},"public":{"type":"Buffer","data":"78GEjcz7Be/vdWrn7F7Jit5dFLMhKkRqOIkjjk90Llc="}}
|
||||
1
baileys_sessions/pre-key-9.json
Normal file
1
baileys_sessions/pre-key-9.json
Normal file
@@ -0,0 +1 @@
|
||||
{"private":{"type":"Buffer","data":"yKy6mgIh/l1Ff81sG1Je97g62rki09KeUUMAubt3vlQ="},"public":{"type":"Buffer","data":"XloBosk8O0OMWhdPV1TL2/7DmSlC9uccQsiCVEyCpw4="}}
|
||||
@@ -0,0 +1 @@
|
||||
[{"senderKeyId":432476765,"senderChainKey":{"iteration":0,"seed":"uXGYSkrX9NTvc75omk03IAlwJety7fhAwlEPa9ndMYE="},"senderSigningKey":{"public":"BZi/bffxv+VxHPIPIbeAH4+F5UPV/zB1IgVhpSrw0eFV"},"senderMessageKeys":[]},{"senderKeyId":318391970,"senderChainKey":{"iteration":0,"seed":"9KF/237LV00EwRIpoRWxeUen30Mxe3N7wA7V59zlvUo="},"senderSigningKey":{"public":"BUvcM7XuqIHhk2dHygulwJncJ2b4Zm/kfeV6rEII6JgG"},"senderMessageKeys":[]},{"senderKeyId":141107147,"senderChainKey":{"iteration":0,"seed":"JV+clRJfIiX/7eibtGBBvYWIoL8d9ZUMoRHpOANnqeQ="},"senderSigningKey":{"public":"Babl0uA4k/LqfIiuIJA1WlWOprgBkZ0GhhOdx4jazkZY"}}]
|
||||
@@ -0,0 +1 @@
|
||||
[{"senderKeyId":187540798,"senderChainKey":{"iteration":3,"seed":"R5zhfkhRO410kgCnKSHzHXIIhLBdw81IacO+a8UHlDs="},"senderSigningKey":{"public":"BcGXx4dQHAkbvisyzptMcufq4IVCKry3afunohyjRwAD"},"senderMessageKeys":[]},{"senderKeyId":1967596939,"senderChainKey":{"iteration":0,"seed":"z7navZ7LN6V9Nd0Rxg6h/VuHhiT09ITkK8ngAQuNyCQ="},"senderSigningKey":{"public":"BYoZMvs6TtLwbbOGJy/TdQSWDyapiFBi4I13vRRxqWtf"}}]
|
||||
1
baileys_sessions/session-5213511080612.0.json
Normal file
1
baileys_sessions/session-5213511080612.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"BXq6VGc6/T1YM7BHWIY0Xo3Nr5SnBDGY2m/G6PXl+Acp":{"registrationId":1714460135,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BTuyPoihyKVkLBFSZozPnIv/s2a7Zwu5aFhbE6y3Nr9Y","privKey":"6HKG+d0NwtQhiDfRlLrugdWPqy8sHpaEnSURkZaJOFo="},"lastRemoteEphemeralKey":"BbrWFV3djGdVctncyanZeP4coYSFCfZUfr/fDkh5qpZo","previousCounter":0,"rootKey":"VbRI/VLZogVUhS/aFxALCCsZado7cUK8I6RfvbQoATg="},"indexInfo":{"baseKey":"BXq6VGc6/T1YM7BHWIY0Xo3Nr5SnBDGY2m/G6PXl+Acp","baseKeyType":2,"closed":-1,"used":1676563632538,"created":1676563632538,"remoteIdentityKey":"BTFr14ABs94X8EftsKbc0cjiioabAkTpXSd7TaUJvHgc"},"_chains":{"BbrWFV3djGdVctncyanZeP4coYSFCfZUfr/fDkh5qpZo":{"chainKey":{"counter":5,"key":"ogyejL4esn0prOOnnVbhd9vLwz4uF/0aLsvF6FQY81A="},"chainType":2,"messageKeys":{}},"BTuyPoihyKVkLBFSZozPnIv/s2a7Zwu5aFhbE6y3Nr9Y":{"chainKey":{"counter":-1,"key":"JGq3D+sYO0xdMxyI12qYG+L/G8jubDDHAIFPz8Ys7pQ="},"chainType":1,"messageKeys":{}}}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215516611480-26.0.json
Normal file
1
baileys_sessions/session-5215516611480-26.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"BTdnXwNZL+hE3VnnHt1+8G5/f/PoQ5NDCZ3zXRu3kvsb":{"registrationId":3564,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BYwhgVl35Ggm8PT0OLtuIvFpkYsA5lPdG5zBDjQYf6Jz","privKey":"EIaTXaH+nsJBfrwDGTICHmxjw7Toqw6yiHIFk109+EE="},"lastRemoteEphemeralKey":"BUvlGIoqqnmj8XEOpWO/dmRldQmNk6WuoWY0iEAvap4k","previousCounter":0,"rootKey":"RYWfNEqR3BU9bfsyWkJkBphsqcH0zWN8SZKzTY8Bnu4="},"indexInfo":{"baseKey":"BTdnXwNZL+hE3VnnHt1+8G5/f/PoQ5NDCZ3zXRu3kvsb","baseKeyType":2,"closed":-1,"used":1676514632922,"created":1676514632922,"remoteIdentityKey":"BUHwxfAd61hnKFyZMzOxxjEboUOLzntmedOuibqcUoVr"},"_chains":{"BUvlGIoqqnmj8XEOpWO/dmRldQmNk6WuoWY0iEAvap4k":{"chainKey":{"counter":12,"key":"xRkSYB3dGJ+RjqzGCsPbU3T1Y7AG7KqAdPHDVE7+4gM="},"chainType":2,"messageKeys":{}},"BYwhgVl35Ggm8PT0OLtuIvFpkYsA5lPdG5zBDjQYf6Jz":{"chainKey":{"counter":29,"key":"1JphtXuD111nzrdF38TV+VH96lSyMEQ7CrWdlM8qBmc="},"chainType":1,"messageKeys":{}}}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215516611480-27.0.json
Normal file
1
baileys_sessions/session-5215516611480-27.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"BdgWAo1egUrQUPN3exIO10SpcBEbPRDD+pnQnbEtu4QT":{"registrationId":2559,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BQ/C7Hmy6EQW80xasJaekvEa3tOnCWvI2wRmZU/7TYk9","privKey":"ONT2whD6sjb23uyjDzZSob6ikNNnI1aMazlyIxENU2g="},"lastRemoteEphemeralKey":"BUW/j+ZIjyl8WO/Ckt8ykE1u8ntGqpQsKqtniXJsbNw4","previousCounter":0,"rootKey":"6q/aMW2nmPrquj6Gw0oKJYSpCI4TS1j3ypAot+WGTsc="},"indexInfo":{"baseKey":"BdgWAo1egUrQUPN3exIO10SpcBEbPRDD+pnQnbEtu4QT","baseKeyType":2,"closed":-1,"used":1676515314124,"created":1676515314124,"remoteIdentityKey":"Bdg+RySLukTCZyJUvt/BkEd/+nWHv/FtNaP+jjLQTMFa"},"_chains":{"BUW/j+ZIjyl8WO/Ckt8ykE1u8ntGqpQsKqtniXJsbNw4":{"chainKey":{"counter":0,"key":"TchxOpv5dBTK7reN1IJUeod/s6TxKzhJZJb3iCpVTLk="},"chainType":2,"messageKeys":{}},"BQ/C7Hmy6EQW80xasJaekvEa3tOnCWvI2wRmZU/7TYk9":{"chainKey":{"counter":-1,"key":"4UoJgkW1hdnkd0jIrN74gG/9uojY8JubgDSE+iiZ/II="},"chainType":1,"messageKeys":{}}}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215516611480-28.0.json
Normal file
1
baileys_sessions/session-5215516611480-28.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"BUXzSzjao60esTdHBlArTohp+OXqGmJHQaITYTpggSFS":{"registrationId":12128,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"Bc6CSZHPmpHa/HJm69yHvbKVrgf9BtWrV7eINh+AzqN2","privKey":"QFghWivYo2SXI32FAyfSZEyEuE6E0YLdYxJ+hec4imY="},"lastRemoteEphemeralKey":"BSZ+dlgL9SzjlgnrYZs0QPOBqmGVGhJRQ6XTqG6u0fUo","previousCounter":0,"rootKey":"zkPhp6ZNaKX7DwIlRDHFm7pc2Gywa6TPb11gapS0ccw="},"indexInfo":{"baseKey":"BUXzSzjao60esTdHBlArTohp+OXqGmJHQaITYTpggSFS","baseKeyType":2,"closed":-1,"used":1676515314131,"created":1676515314131,"remoteIdentityKey":"Bb9R5Ucm3Mega1WaatZ+cOMH0Rw+lF49bjzoCESs0QNb"},"_chains":{"BSZ+dlgL9SzjlgnrYZs0QPOBqmGVGhJRQ6XTqG6u0fUo":{"chainKey":{"counter":0,"key":"PuD3C7/k+NMu8HYijNzKqT4qKc9cZHY+Gv8bAxy9gFQ="},"chainType":2,"messageKeys":{}},"Bc6CSZHPmpHa/HJm69yHvbKVrgf9BtWrV7eINh+AzqN2":{"chainKey":{"counter":-1,"key":"zyCesniFSBLEsXz6yJuNwWbaOAmp2ag/A8Wj3LwBvso="},"chainType":1,"messageKeys":{}}}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215516611480-29.0.json
Normal file
1
baileys_sessions/session-5215516611480-29.0.json
Normal file
File diff suppressed because one or more lines are too long
1
baileys_sessions/session-5215516611480-30.0.json
Normal file
1
baileys_sessions/session-5215516611480-30.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"BUZ1YkgIgWjqsFn/wb2vAhSN2h8f24JFNIFfOsSkwFkV":{"registrationId":3199,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BZz6ZNox4cggWCikFfiThbgZBNA19FMu4bzktJHQ7rkI","privKey":"yH9EISEZkHpvI9NIjj+dodNyht++mhhl/D944sbNI1I="},"lastRemoteEphemeralKey":"BZ/O8Wxuhw9AUrXpORRMk+WHE/uwG34y+VhX2FQM/E0s","previousCounter":0,"rootKey":"uWLxGhoWZOTfxI4OHfTZaPNdGk2YBCGcfKND9jDhJ70="},"indexInfo":{"baseKey":"BUZ1YkgIgWjqsFn/wb2vAhSN2h8f24JFNIFfOsSkwFkV","baseKeyType":2,"closed":1676616816297,"used":1676613575711,"created":1676613575711,"remoteIdentityKey":"BWMbwv3hUdyCp8tsG0XAo1C6Eh+QU0tHG8bcwsvlaJM2"},"_chains":{"BZ/O8Wxuhw9AUrXpORRMk+WHE/uwG34y+VhX2FQM/E0s":{"chainKey":{"counter":9,"key":"5ToLDQ89AoNw27l3h2lMfc58RS5VNZnl+yWCed38XAI="},"chainType":2,"messageKeys":{}},"BZz6ZNox4cggWCikFfiThbgZBNA19FMu4bzktJHQ7rkI":{"chainKey":{"counter":81,"key":"vba4Z77PeTeHmH4UbanEUWKtBNBOpHbXZJFrPMIUcgE="},"chainType":1,"messageKeys":{}}}},"BbHD/7Qc1qH/YNWetQuL03gLXZaVEkjTG/aVuMBMYwdT":{"registrationId":3199,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BVeo/KUOEDUXILNa2aq9Md+ZhX8CinlPzNsOMXBKOKhZ","privKey":"qMPdSSX8YCrBVtPr0n4xERnXyhKR8vZ/+9lsU2E5pWs="},"lastRemoteEphemeralKey":"BXW4cfagSwg8J/hAGGUzDdxK1524TdCMNiqXTgNHEKJp","previousCounter":0,"rootKey":"JbnddtK+6YhlvolxNBvI/3iDsXua/dJGqn3sZA0m2ro="},"indexInfo":{"baseKey":"BbHD/7Qc1qH/YNWetQuL03gLXZaVEkjTG/aVuMBMYwdT","baseKeyType":1,"closed":1676616816370,"used":1676616816243,"created":1676616816243,"remoteIdentityKey":"BWMbwv3hUdyCp8tsG0XAo1C6Eh+QU0tHG8bcwsvlaJM2"},"_chains":{"BVeo/KUOEDUXILNa2aq9Md+ZhX8CinlPzNsOMXBKOKhZ":{"chainKey":{"counter":-1,"key":"qMVgOCZWaJGp9JvRNBNUdhWoDZxdJV6ah7QxYlUmNpI="},"chainType":1,"messageKeys":{}}},"pendingPreKey":{"signedKeyId":1,"baseKey":"BbHD/7Qc1qH/YNWetQuL03gLXZaVEkjTG/aVuMBMYwdT","preKeyId":174}},"BbJ8Qu6GPv9I9CMJc2x+3tF1L7l7h5U2hB3r6FeDX4t1":{"registrationId":3199,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BYeepGJZQICCzaXZVZpkkeHiD36wVUyYd1jVwwk0K8Js","privKey":"0FaF/Yov1sNTU0MHfX2TZQb6owJM869WtXBvHc1htVU="},"lastRemoteEphemeralKey":"BXW4cfagSwg8J/hAGGUzDdxK1524TdCMNiqXTgNHEKJp","previousCounter":0,"rootKey":"hZzkhD9itssnWUhHluwzraf2zTp0zLASEu1MtwVwTaU="},"indexInfo":{"baseKey":"BbJ8Qu6GPv9I9CMJc2x+3tF1L7l7h5U2hB3r6FeDX4t1","baseKeyType":1,"closed":1676619799181,"used":1676616816348,"created":1676616816348,"remoteIdentityKey":"BWMbwv3hUdyCp8tsG0XAo1C6Eh+QU0tHG8bcwsvlaJM2"},"_chains":{"BYeepGJZQICCzaXZVZpkkeHiD36wVUyYd1jVwwk0K8Js":{"chainKey":{"counter":43,"key":"9LDS3JbX7b6eujgT5ayJfMvZnE6Mjhsm1/IeSkOhujw="},"chainType":1,"messageKeys":{}}},"pendingPreKey":{"signedKeyId":1,"baseKey":"BbJ8Qu6GPv9I9CMJc2x+3tF1L7l7h5U2hB3r6FeDX4t1","preKeyId":126}},"BUhZhzBcI0wY6Cu7OU2LEqDkjTs8T79jwMSoPEZxIYJz":{"registrationId":3199,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BbRJiHB1m2jCRm2PpkjfKc/aF7BEgETSma3BpnOfwPl2","privKey":"2MWnZwf2CaqeNfc9fmOEnprFIt98w+53K71uwKH8TmI="},"lastRemoteEphemeralKey":"BXW4cfagSwg8J/hAGGUzDdxK1524TdCMNiqXTgNHEKJp","previousCounter":0,"rootKey":"xnBPZD4INsiwWZnP8GhEEKdOmTg5x6M/GgrztfwOjZ0="},"indexInfo":{"baseKey":"BUhZhzBcI0wY6Cu7OU2LEqDkjTs8T79jwMSoPEZxIYJz","baseKeyType":1,"closed":1676619805774,"used":1676619799172,"created":1676619799172,"remoteIdentityKey":"BWMbwv3hUdyCp8tsG0XAo1C6Eh+QU0tHG8bcwsvlaJM2"},"_chains":{"BbRJiHB1m2jCRm2PpkjfKc/aF7BEgETSma3BpnOfwPl2":{"chainKey":{"counter":2,"key":"Egy/oyMLldWWjqwLSrMp+jo+qZSKrCd3j3gjn0GkYjo="},"chainType":1,"messageKeys":{}}},"pendingPreKey":{"signedKeyId":1,"baseKey":"BUhZhzBcI0wY6Cu7OU2LEqDkjTs8T79jwMSoPEZxIYJz","preKeyId":195}},"BU7TUAOG/t0viGqJqhnoJHX2oS/3WJRcllfIdcxiosA3":{"registrationId":3199,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BW3PbwcruRgOjNrrnJmLgwq44CSnJdM6myXr+AESm287","privKey":"YF/ngMIMXhbq5vQYNcgXx+zB+LJkvdwgWXYmdhWBZXc="},"lastRemoteEphemeralKey":"BXW4cfagSwg8J/hAGGUzDdxK1524TdCMNiqXTgNHEKJp","previousCounter":0,"rootKey":"Y/NdV++pAEoB4R37QxAedRyfYcNMtO5qFMDANRxRs4k="},"indexInfo":{"baseKey":"BU7TUAOG/t0viGqJqhnoJHX2oS/3WJRcllfIdcxiosA3","baseKeyType":1,"closed":-1,"used":1676619805762,"created":1676619805762,"remoteIdentityKey":"BWMbwv3hUdyCp8tsG0XAo1C6Eh+QU0tHG8bcwsvlaJM2"},"_chains":{"BW3PbwcruRgOjNrrnJmLgwq44CSnJdM6myXr+AESm287":{"chainKey":{"counter":110,"key":"KN3e1e9C0AnTarHLLyW2IMRZA2l9phDfUpdCb2jmFxA="},"chainType":1,"messageKeys":{}}},"pendingPreKey":{"signedKeyId":1,"baseKey":"BU7TUAOG/t0viGqJqhnoJHX2oS/3WJRcllfIdcxiosA3","preKeyId":156}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215516611480.0.json
Normal file
1
baileys_sessions/session-5215516611480.0.json
Normal file
File diff suppressed because one or more lines are too long
1
baileys_sessions/session-5215527026728.0.json
Normal file
1
baileys_sessions/session-5215527026728.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"Bf9lN2kk9Ow+687G0OP2qGRI6EHOgy5lz4fwnqlBtr8f":{"registrationId":917869974,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BR4bcQnaFclFnDYY5xFUcZI/0X+tedtxgAni4wwUnZFO","privKey":"GHZq5SLwC4JWFn5NGwPFy3FoMZgEzyzTKCpQ2/bAs1g="},"lastRemoteEphemeralKey":"BXay5B717VFyh4dq6kQWz+OgXxTYCfjw8hOJhxq8vBp+","previousCounter":0,"rootKey":"hyRttFQzNyAs/QKRUKg6xx2Pck1OKOyJcgj+77vrDOE="},"indexInfo":{"baseKey":"Bf9lN2kk9Ow+687G0OP2qGRI6EHOgy5lz4fwnqlBtr8f","baseKeyType":2,"closed":-1,"used":1676613575714,"created":1676613575714,"remoteIdentityKey":"BYFM8Y/vqUjvS/Te+O6hjMCKeUjvT1x36ECaLgHyW8pj"},"_chains":{"BXay5B717VFyh4dq6kQWz+OgXxTYCfjw8hOJhxq8vBp+":{"chainKey":{"counter":2,"key":"0jfMBmgKZveVxjPTYAKQremV9OpjuXdBPF4+XaurBPw="},"chainType":2,"messageKeys":{}},"BR4bcQnaFclFnDYY5xFUcZI/0X+tedtxgAni4wwUnZFO":{"chainKey":{"counter":-1,"key":"rnCU0p/q9Bi7NHWz+yb6QqAOg2V1VkF/qlgbE55V0Vs="},"chainType":1,"messageKeys":{}}}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215527049036.0.json
Normal file
1
baileys_sessions/session-5215527049036.0.json
Normal file
@@ -0,0 +1 @@
|
||||
{"_sessions":{"BYuuzcjiljF4phxisWr1qclLXVcZW6Up0ks6CwYQIa4i":{"registrationId":700962419,"currentRatchet":{"ephemeralKeyPair":{"pubKey":"BZMBqhLo0+E7O6zeYZ28GE2T2FcUskZ0szPG/tWHKT4x","privKey":"gJk6rV2f5K76zDPMBLf8irFTjAuycbe2xeEwFULyOWM="},"lastRemoteEphemeralKey":"BbrIvqXwaNzARRhvImiJE6Zm6kibmrldreCWtAN692Us","previousCounter":0,"rootKey":"ZvWCrt6MHvg5Tr7BhUHLi4l3nIHFNi2IylMu/PUTq8Q="},"indexInfo":{"baseKey":"BYuuzcjiljF4phxisWr1qclLXVcZW6Up0ks6CwYQIa4i","baseKeyType":2,"closed":-1,"used":1676563632556,"created":1676563632556,"remoteIdentityKey":"BW+O8TIFKawqsOWwDxeNQ7n75mSVQrKn7taPAmP8AvJ5"},"_chains":{"BbrIvqXwaNzARRhvImiJE6Zm6kibmrldreCWtAN692Us":{"chainKey":{"counter":1,"key":"8MWYu7nY9xEToxM85TvEwAs8YovZ2sMTeYTrY0V3mxw="},"chainType":2,"messageKeys":{}},"BZMBqhLo0+E7O6zeYZ28GE2T2FcUskZ0szPG/tWHKT4x":{"chainKey":{"counter":-1,"key":"NfrGoyu8nRBFD8T/IYXYJ7HUjGWk7XDn6SbCM+3hqqI="},"chainType":1,"messageKeys":{}}}}},"version":"v1"}
|
||||
1
baileys_sessions/session-5215554192439-64.0.json
Normal file
1
baileys_sessions/session-5215554192439-64.0.json
Normal file
File diff suppressed because one or more lines are too long
1
baileys_sessions/session-5215554192439.0.json
Normal file
1
baileys_sessions/session-5215554192439.0.json
Normal file
File diff suppressed because one or more lines are too long
BIN
bot.qr.png
Normal file
BIN
bot.qr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
@@ -1,6 +1,12 @@
|
||||
const { get, reply, getIA } = require('../adapter')
|
||||
const { saveExternalFile, checkIsUrl } = require('./handle')
|
||||
|
||||
/**
|
||||
* Regresa la regla que se cumple con el texto el mensaje.
|
||||
* @param {*} message
|
||||
* @param {*} num
|
||||
* @returns
|
||||
*/
|
||||
const getMessages = async (message, num) => { //MOD by CHV - Agregamos el parametro "num" para recibir el numero desde "app.js"
|
||||
// console.log("GETMESSAGES (flow.js)")
|
||||
const data = await get(message, num) //MOD by CHV - Agregamos "num"
|
||||
|
||||
@@ -6,12 +6,18 @@ const qr = require('qr-image')
|
||||
|
||||
const MULTI_DEVICE = process.env.MULTI_DEVICE || 'true';
|
||||
|
||||
const cleanNumber = (number) => {
|
||||
const cleanNumber_wwebjs = (number) => {
|
||||
number = number.replace('@c.us', '');
|
||||
number = `${number}@c.us`;
|
||||
return number
|
||||
}
|
||||
|
||||
const cleanNumber_baileys = (number) => {
|
||||
number = number.replace('@s.whatsapp.net', '');
|
||||
number = `${number}@s.whatsapp.net`;
|
||||
return number
|
||||
}
|
||||
|
||||
const saveExternalFile = (url) => new Promise((resolve, reject) => {
|
||||
const ext = url.split('.').pop()
|
||||
const checkProtocol = url.split('/').includes('https:');
|
||||
@@ -74,10 +80,21 @@ const createClient = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const isValidNumber = (rawNumber) => {
|
||||
const isValidNumber_wwebjs = (rawNumber) => {
|
||||
const regexGroup = /\@g.us\b/gm;
|
||||
const exist = rawNumber.match(regexGroup);
|
||||
console.log("IsValidWawebJS", rawNumber, exist, !exist)
|
||||
return !exist
|
||||
}
|
||||
|
||||
module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl, checkEnvFile, createClient, isValidNumber}
|
||||
const isValidNumber_baileys = (rawNumber) => {
|
||||
const regexGroup = /\@g.us\b/gm;
|
||||
const exist = rawNumber.match(regexGroup);
|
||||
// console.log("IsValidBaileys", rawNumber, exist, !exist)
|
||||
return !exist
|
||||
}
|
||||
|
||||
const isValidNumber = eval(`isValidNumber_${provider}`)
|
||||
const cleanNumber = eval(`cleanNumber_${provider}`)
|
||||
|
||||
module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl, checkEnvFile, createClient, isValidNumber }
|
||||
|
||||
@@ -9,7 +9,6 @@ var fileName;
|
||||
* @param {*} media
|
||||
*/
|
||||
|
||||
|
||||
const saveMedia = (media) => {
|
||||
const extensionProcess = mimeDb[media.mimetype];
|
||||
let ext;
|
||||
@@ -27,10 +26,8 @@ const saveMedia = (media) => {
|
||||
}
|
||||
|
||||
const saveMediaToGoogleDrive = async (media) => {
|
||||
|
||||
fileName = saveMedia(media);
|
||||
filePath = `${__dirname}/../media/${fileName}`
|
||||
|
||||
const googleDriveUrl = await uploadSingleFile(fileName, filePath);
|
||||
return googleDriveUrl
|
||||
}
|
||||
|
||||
188
controllers/send_baileys.js
Normal file
188
controllers/send_baileys.js
Normal file
@@ -0,0 +1,188 @@
|
||||
const ExcelJS = require('exceljs');
|
||||
const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
const { MessageMedia, Buttons, List } = require('whatsapp-web.js');
|
||||
const { cleanNumber } = require('./handle')
|
||||
const { remplazos } = require('../implementaciones/extraFuncs'); //MOD by CHV - Agregamos remplazos
|
||||
const DELAY_TIME = 170; //ms
|
||||
const DIR_MEDIA = `${__dirname}/../mediaSend`;
|
||||
// import { Low, JSONFile } from 'lowdb'
|
||||
// import { join } from 'path'
|
||||
const { saveMessage } = require('../adapter')
|
||||
const { ingresarDatos, leerDatos } = require('../implementaciones/sheets')
|
||||
const mime = require('mime-types')
|
||||
|
||||
/**
|
||||
* Enviar imagen o multimedia
|
||||
* @param {*} number
|
||||
* @param {*} mediaInput
|
||||
* @param {*} message
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'https://dominio.com/imagen.jpg' | 'img/imagen.jpg')
|
||||
*/
|
||||
const sendMedia = async (client, number, fileName, text) => {
|
||||
console.log("SendMedia = ", number, fileName, text)
|
||||
// const fileDownloaded = await generalDownload(imageUrl)
|
||||
|
||||
const file = `${DIR_MEDIA}/${fileName}`;
|
||||
console.log("FILE="+file);
|
||||
if (fs.existsSync(file)) {
|
||||
console.log("ARCHIVO EXISTE");
|
||||
const mimeType = mime.lookup(file)
|
||||
if (mimeType.includes('image')) return sendImage(client, number, file, text)
|
||||
if (mimeType.includes('video')) return sendVideo(client, number, file, text)
|
||||
if (mimeType.includes('audio')) return sendAudio(client, number, file, text)
|
||||
return sendFile(client, number, file)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
const sendImage = async (client, number, filePath, text) => {
|
||||
client.sendMessage(number, {
|
||||
image: fs.readFileSync(filePath),
|
||||
caption: text,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviamos archivos como notas de voz
|
||||
* @param {*} number
|
||||
* @param {*} fileName
|
||||
*/
|
||||
|
||||
const sendMediaVoiceNote = (client, number = null, fileName = null) => {
|
||||
if(!client) return console.error("El objeto cliente no está definido.");
|
||||
try {
|
||||
number = cleanNumber(number || 0)
|
||||
const file = `${DIR_MEDIA}/${fileName}`;
|
||||
if (fs.existsSync(file)) {
|
||||
const media = MessageMedia.fromFilePath(file);
|
||||
client.sendMessage(number, media ,{ sendAudioAsVoice: true });
|
||||
|
||||
}
|
||||
}catch(e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Enviamos un mensaje simple (texto) a nuestro cliente
|
||||
* @param {*} number
|
||||
*/
|
||||
const sendMessage = async (client, number = null, text = null, trigger = null, regla) => { //MOD by CHV - Agregamos el parametro "regla" para guardarlo en "chats/numero.json"
|
||||
if(text !== undefined && text != null){
|
||||
setTimeout(async () => {
|
||||
number = cleanNumber(number)
|
||||
await client.sendMessage(number, { text: text })
|
||||
// console.log(number, message, regla)
|
||||
await readChat(number, text, trigger, regla) //MOD by CHV - Agregamos el parametro "regla"
|
||||
console.log(`⚡⚡⚡ Enviando mensajes....`);
|
||||
ingresarDatos(number, text, 'Salida', 'Bot Pruebas')
|
||||
// console.log("********************* SEND MESSAGE **************************************");
|
||||
},DELAY_TIME)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviamos un mensaje con buttons a nuestro cliente
|
||||
* @param {*} number
|
||||
*/
|
||||
const sendMessageButton2 = async (client, number = null, text = null, actionButtons) => {
|
||||
setTimeout(async () => {
|
||||
number = cleanNumber(number)
|
||||
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, actionButtons)
|
||||
client.sendMessage(number, button);
|
||||
console.log(`⚡⚡⚡ Enviando mensajes (botones)....`);
|
||||
// console.log("sendMessageButton.");
|
||||
}, DELAY_TIME)
|
||||
// console.log("************************ SEND MESSAGE BUTTON ***********************************");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} number
|
||||
* @param {string} text
|
||||
* @param {string} footer
|
||||
* @param {Array} buttons
|
||||
* @example await sendMessage("+XXXXXXXXXXX", "Your Text", "Your Footer", [{"buttonId": "id", "buttonText": {"displayText": "Button"}, "type": 1}])
|
||||
*/
|
||||
const sendMessageButton = async (client, number, text = null, actionButtons) => {
|
||||
number = cleanNumber(number)
|
||||
const { title = null, message = null, footer = null, buttons = [] } = actionButtons;
|
||||
const templateButtons = buttons.map((btn, i) => ({
|
||||
buttonId: `id-btn-${i}`,
|
||||
buttonText: { displayText: btn.body },
|
||||
type: 1,
|
||||
}))
|
||||
text = remplazos(`*${title}*\n${message}`, client)
|
||||
await readChat(number, message, actionButtons)
|
||||
// console.log("sendMessageButton:", text, templateButtons)
|
||||
const buttonMessage = { text, footer, buttons: templateButtons, headerType: 1 }
|
||||
return client.sendMessage(number, buttonMessage)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviamos listas (con el formato de response.json)
|
||||
* @param {*} number
|
||||
*/
|
||||
const sendMessageList = async (client, number = null, text = null, actionList) => {
|
||||
console.log("**************** baileys send")
|
||||
setTimeout(async () => {
|
||||
// console.log("********************** client **************************")
|
||||
number = cleanNumber(number)
|
||||
const { body = null, buttonText = null, sections = [], title = null, footer = null } = actionList;
|
||||
const theList = {
|
||||
text: remplazos(body, client),
|
||||
footer: remplazos(footer, client),
|
||||
title: remplazos(title, client),
|
||||
buttonText: remplazos(buttonText, client),
|
||||
sections
|
||||
}
|
||||
console.log(theList)
|
||||
// console.log(sections[0])
|
||||
client.sendMessage(number, theList);
|
||||
await readChat(number, body, actionList)
|
||||
console.log('⚡⚡⚡ Enviando lista a '+number+' ....');
|
||||
}, DELAY_TIME)
|
||||
}
|
||||
|
||||
/**
|
||||
* Opte
|
||||
*/
|
||||
const lastTrigger = (number) => new Promise((resolve, reject) => {
|
||||
number = cleanNumber(number)
|
||||
const pathExcel = `${__dirname}/../chats/${number}.xlsx`;
|
||||
const workbook = new ExcelJS.Workbook();
|
||||
if (fs.existsSync(pathExcel)) {
|
||||
workbook.xlsx.readFile(pathExcel)
|
||||
.then(() => {
|
||||
const worksheet = workbook.getWorksheet(1);
|
||||
const lastRow = worksheet.lastRow;
|
||||
const getRowPrevStep = worksheet.getRow(lastRow.number);
|
||||
const lastStep = getRowPrevStep.getCell('C').value;
|
||||
resolve(lastStep)
|
||||
});
|
||||
} else {
|
||||
resolve(null)
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* Guardar historial de conversacion
|
||||
* @param {*} number
|
||||
* @param {*} message
|
||||
*/
|
||||
const readChat = async (number, message, trigger = null, regla) => { //MOD by CHV - Agregamos el parametro "regla" para guardarlo en "chats/numero.json"
|
||||
number = cleanNumber(number)
|
||||
await saveMessage( message, trigger, number, regla ) //MOD by CHV - Agregamos "regla"
|
||||
// console.log('Saved')
|
||||
}
|
||||
|
||||
module.exports = { sendMessage, sendMedia, lastTrigger, sendMessageButton, sendMessageList, readChat, sendMediaVoiceNote }
|
||||
@@ -1,38 +1,59 @@
|
||||
|
||||
const ExcelJS = require('exceljs');
|
||||
const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
const { MessageMedia, Buttons, List } = require('whatsapp-web.js');
|
||||
const { cleanNumber } = require('./handle')
|
||||
const { remplazos } = require('../adapter/index'); //MOD by CHV - Agregamos remplazos
|
||||
const { remplazos } = require('../implementaciones/extraFuncs') //MOD by CHV - Agregamos remplazos
|
||||
const DELAY_TIME = 170; //ms
|
||||
const DIR_MEDIA = `${__dirname}/../mediaSend`;
|
||||
// import { Low, JSONFile } from 'lowdb'
|
||||
// import { join } from 'path'
|
||||
const { saveMessage } = require('../adapter')
|
||||
/**
|
||||
* Enviamos archivos multimedia a nuestro cliente
|
||||
* @param {*} number
|
||||
* @param {*} fileName
|
||||
*/
|
||||
const { ingresarDatos, leerDatos } = require('../implementaciones/sheets')
|
||||
const mime = require('mime-types')
|
||||
|
||||
const sendMedia = (client, number = null, fileName = null, trigger = null) => {
|
||||
if(!client) return console.error("El objeto cliente no está definido.");
|
||||
console.log("MEDIA:"+fileName);
|
||||
try {
|
||||
number = cleanNumber(number || 0)
|
||||
const file = `${DIR_MEDIA}/${fileName}`;
|
||||
console.log("FILE="+file);
|
||||
if (fs.existsSync(file)) {
|
||||
console.log("ARCHIVO EXISTE");
|
||||
const media = MessageMedia.fromFilePath(file);
|
||||
client.sendMessage(number, media, { sendAudioAsVoice: true });
|
||||
}
|
||||
} catch(e) {
|
||||
throw e;
|
||||
/**
|
||||
* Enviar imagen o multimedia
|
||||
* @param {*} number
|
||||
* @param {*} mediaInput
|
||||
* @param {*} message
|
||||
* @returns
|
||||
*/
|
||||
const sendMedia = async (client, number, fileName, text) => {
|
||||
console.log("SendMedia = ", number, fileName, text)
|
||||
// const fileDownloaded = await generalDownload(imageUrl)
|
||||
const file = `${DIR_MEDIA}/${fileName}`;
|
||||
console.log("FILE="+file);
|
||||
if (fs.existsSync(file)) {
|
||||
console.log("ARCHIVO EXISTE");
|
||||
const mimeType = mime.lookup(file)
|
||||
if (mimeType.includes('image')) return sendImage(client, number, file, text)
|
||||
if (mimeType.includes('video')) return sendVideo(client, number, file, text)
|
||||
if (mimeType.includes('audio')) return sendAudio(client, number, file, text)
|
||||
return sendFile(client, number, file)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
const sendImage = async (client, number, fileName, caption) => {
|
||||
const file = `${DIR_MEDIA}/${fileName}`;
|
||||
console.log("FILE="+file);
|
||||
if (fs.existsSync(file)) {
|
||||
console.log("ARCHIVO EXISTE");
|
||||
const media = MessageMedia.fromFilePath(file);
|
||||
}
|
||||
const base64 = fs.readFileSync(fileName, { encoding: 'base64' })
|
||||
const mimeType = mime.lookup(fileName)
|
||||
const media = new MessageMedia(mimeType, base64)
|
||||
client.sendMessage(number, media, { caption })
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviamos archivos como notas de voz
|
||||
* @param {*} number
|
||||
@@ -63,6 +84,7 @@ const sendMessage = async (client, number = null, text = null, trigger = null, r
|
||||
number = cleanNumber(number)
|
||||
const message = text
|
||||
client.sendMessage(number, message);
|
||||
// console.log(number, message, regla)
|
||||
await readChat(number, message, trigger, regla) //MOD by CHV - Agregamos el parametro "regla"
|
||||
console.log(`⚡⚡⚡ Enviando mensajes....`);
|
||||
// console.log("********************* SEND MESSAGE **************************************");
|
||||
@@ -91,6 +113,7 @@ const sendMessageButton = async (client, number = null, text = null, actionButto
|
||||
* @param {*} number
|
||||
*/
|
||||
const sendMessageList = async (client, number = null, text = null, actionList) => {
|
||||
// console.log("*************** wwebjs send")
|
||||
setTimeout(async () => {
|
||||
// console.log("********************** client **************************")
|
||||
// console.log(client)
|
||||
@@ -135,4 +158,4 @@ const readChat = async (number, message, trigger = null, regla) => { //MOD by CH
|
||||
// console.log('Saved')
|
||||
}
|
||||
|
||||
module.exports = { sendMessage, sendMedia, lastTrigger, sendMessageButton, sendMessageList, readChat, sendMediaVoiceNote }
|
||||
module.exports = { sendMessage, sendMedia, sendImage, lastTrigger, sendMessageButton, sendMessageList, readChat, sendMediaVoiceNote }
|
||||
@@ -1,5 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const { sendMessage } = require('../controllers/send')
|
||||
const { sendMessage } = require(`./send_${provider}`)
|
||||
|
||||
const sendMessagePost = (req, res) => {
|
||||
console.log('asdasdasdasdasd')
|
||||
|
||||
@@ -55,6 +55,10 @@
|
||||
"keywords": ["6"],
|
||||
"key": "botonespaq3"
|
||||
},
|
||||
{
|
||||
"keywords": "7|*doble*mensaje*",
|
||||
"key": "doblemensaje"
|
||||
},
|
||||
{
|
||||
"keywords": ["cursos"],
|
||||
"key": "cursos"
|
||||
@@ -82,5 +86,16 @@
|
||||
{
|
||||
"keywords": "*pak*3*|*pak*angular*|*paquete*3*|*paquete*angular*",
|
||||
"key": "paq3"
|
||||
},
|
||||
{
|
||||
"keywords": [
|
||||
"/soporte",
|
||||
"/ayuda"
|
||||
],
|
||||
"key": "soporte"
|
||||
},
|
||||
{
|
||||
"keywords": "*",
|
||||
"key": "Desbloqueo"
|
||||
}
|
||||
]
|
||||
@@ -1,71 +1,114 @@
|
||||
{
|
||||
"DEFAULT":{
|
||||
"replyMessage":[
|
||||
"*Esta respuesta es un respuesta default* cuando no se consigue una palabra clave \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"
|
||||
{ "mensaje":[
|
||||
"*Esta es una respuesta por default* para cuando no se encuentra una palabra clave predefinida.",
|
||||
"Se puede desactivar en el archivo .env DEFAULT_MESSAGE=false",
|
||||
"tambien te quiero recordar que si presentas algun error pasarte por el repositorio",
|
||||
"https://github.com/leifermendez/bot-whatsapp#chatbot-whatsapp-opensource",
|
||||
"y recuerda tener la ultima versión del proyecto.",
|
||||
"Prueba escribiendo */Menu*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null
|
||||
},
|
||||
"menu":{
|
||||
"doblemensaje":{
|
||||
"keywords": "7|*doble*mensaje*",
|
||||
"replyMessage":[
|
||||
"%saludo% %primer_nombre%, este es el menú, selecciona una opción: \n",
|
||||
"Pon *1* para mensajes anteriores.\n",
|
||||
"Pon *2* para ver remplazos.\n",
|
||||
"Pon *3* para pedir nombre (RegExp).\n",
|
||||
"Pon *4* para un ejemplo de listas y expresiones regulares.\n",
|
||||
"Pon *5* para un ejemplo de botones.\n",
|
||||
"Pon *6* para un ejemplo de botones y regExp.\n"
|
||||
{"mensaje":["Este es un ejemplo del envío de *varios* mensajes con la *misma regla* en el *response.json*"]},
|
||||
{
|
||||
"mensaje":["Este es el *segundo* mensaje.","Contiene dos lineas 🤪"]
|
||||
},
|
||||
{"mensaje":["Este es el *tercer* mensaje, los *tres* van definidos en la *misma regla* del *response.json*"]}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"goto":"menu",
|
||||
"pasoRequerido":"menu"
|
||||
},
|
||||
"menu":{
|
||||
"keywords": ["/menu"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":[
|
||||
"%saludo% %primer_nombre%, este es el *menú*, selecciona una opción:",
|
||||
"Pon *1* para ver mensajes anteriores.",
|
||||
"Pon *2* para ver remplazos.",
|
||||
"Pon *3* para capturar cualquier texto (RegExp).",
|
||||
"Pon *4* para un ejemplo de listas y expresiones regulares.",
|
||||
"Pon *5* para un ejemplo de botones.",
|
||||
"Pon *6* para un ejemplo de botones y regExp.",
|
||||
"Pon *7* para un ejemplo de envío de *tres* mensajes en una *misma* regla."
|
||||
]
|
||||
}
|
||||
] ,
|
||||
"media":null,
|
||||
"trigger":null
|
||||
},
|
||||
"opcion1":{
|
||||
"keywords": ["1"],
|
||||
"replyMessage":[
|
||||
"Seleccionaste la opción 1\n",
|
||||
"*Ultimo mensaje:*\n",
|
||||
"%msjant_0%\n",
|
||||
"*Penultimo mensaje:*\n",
|
||||
"%msjant_1%\n",
|
||||
"*Antepenultimo mensaje:*\n",
|
||||
"%msjant_2% \n\n",
|
||||
"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 3 sin necesidad de volver a iniciar con */menu*."
|
||||
{
|
||||
"mensaje":[
|
||||
"Seleccionaste la *opción 1*",
|
||||
"*Ultimo mensaje:*",
|
||||
"%msjant_0%",
|
||||
"*Penultimo mensaje:*",
|
||||
"%msjant_1%",
|
||||
"*Antepenultimo mensaje:*",
|
||||
"%msjant_2% \n",
|
||||
"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"opcion2":{
|
||||
"keywords": ["2"],
|
||||
"replyMessage":[
|
||||
"Seleccionaste la opción 2\n",
|
||||
"Remplazamos %saludo.% con *\"%saludo%\"*\n",
|
||||
"Remplazamos %dia_semana.% con *\"%dia_semana%\"*\n",
|
||||
"Remplazamos %hora24.%:%minutos.% con *\"%hora24%:%minutos%\"*\n",
|
||||
"Remplazamos %.rnd_👍🏽,🤞🏼,🤪,🤔% con '%rnd_👍🏽,🤞🏼,🤪,🤔%'\n\n",
|
||||
"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 3 sin necesidad de volver a iniciar con */menu*."
|
||||
{
|
||||
"mensaje":[
|
||||
"Seleccionaste la *opción 2*",
|
||||
"Remplazamos %saludo.% con *\"%saludo%\"*",
|
||||
"Remplazamos %dia_semana.% con *\"%dia_semana%\"*",
|
||||
"Remplazamos %hora24.%:%minutos.% con *\"%hora24%:%minutos%\"*",
|
||||
"Remplazamos %.rnd_👍🏽,🤞🏼,🤪,🤔% con '%rnd_👍🏽,🤞🏼,🤪,🤔%'\n",
|
||||
"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"opcion3":{
|
||||
"keywords": ["3"],
|
||||
"replyMessage":[
|
||||
"Seleccionaste la opción 3\n\n",
|
||||
"Por favor dame tu nombre.\n\n",
|
||||
"Aquí vamos a aceptar *cualquier* texto, porque en el *initial.json* tenemos keywords : \"***\" (un asterisco en expresiones regulares quiere decir *\"cualquier cosa\"*)\n",
|
||||
"Y en *response.json* en la opción correspondiente tenemos \"pasoRequerido\" : \"menu\", que quiere decir que SOLO se va a disparar cuando el paso anterior sea \"menu\"."
|
||||
{
|
||||
"mensaje":[
|
||||
"Seleccionaste la *opción 3*\n",
|
||||
"*Por favor dame tu nombre.*\n",
|
||||
"Aquí vamos a aceptar *cualquier* texto, porque en *keyword* tenemos : \"*\" (un asterisco en expresiones regulares quiere decir *\"cualquier cosa\"*)",
|
||||
"Y en *response.json* en la opción correspondiente tenemos \"pasoRequerido\" : \"menu\", que quiere decir que SOLO se va a disparar cuando el paso anterior sea \"menu\"."
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"pasoRequerido":"menu"
|
||||
},
|
||||
"recibenombre":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"Gracias por tu nombre *%msjant_0%*.\n\n",
|
||||
"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 3 sin necesidad de volver a iniciar con */menu*."
|
||||
{
|
||||
"mensaje":[
|
||||
"Gracias por tu nombre *%msjant_0%*.\n",
|
||||
"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
@@ -73,31 +116,55 @@
|
||||
"goto":"menu"
|
||||
},
|
||||
"gRevisaCliente":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"/URL=http://localhost:8888/dbrquery?j={\"query\":\"select_revisacliente_GUNA\",\"exec\":\"ExecuteQuery\",\"params\":{\"par1\":\"XXPARAM1XX\"}}"
|
||||
{
|
||||
"mensaje":[
|
||||
"/URL=http://localhost:8888/dbrquery?j={\"query\":\"select_revisacliente_GUNA\",\"exec\":\"ExecuteQuery\",\"params\":{\"par1\":\"XXPARAM1XX\"}}"
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gallina"
|
||||
},
|
||||
"gGuardainfo":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"/URL=http://localhost:8888/dbrquery?j={\"query\":\"insert_registroGallina_GUNA\",\"exec\":\"ExecuteCommand\",\"params\":{\"par1\":\"XXPARAM1XX\", \"par2\":\"XXPARAM2XX\", \"par3\":\"XXPARAM3XX\", \"par4\":\"XXPARAM4XX\"}}"
|
||||
{
|
||||
"mensaje":[
|
||||
"/URL=http://localhost:8888/dbrquery?j={\"query\":\"insert_registroGallina_GUNA\",\"exec\":\"ExecuteCommand\",\"params\":{\"par1\":\"XXPARAM1XX\", \"par2\":\"XXPARAM2XX\", \"par3\":\"XXPARAM3XX\", \"par4\":\"XXPARAM4XX\"}}"
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gRevisaCliente"
|
||||
},
|
||||
"rnd":{
|
||||
"keywords": ["rnd"],
|
||||
"replyMessage":[
|
||||
"%saludo%\nHoy es %dia_semana%.\nSon las %hora24%:%minutos% hrs.\nSon las %hora12%:%minutos% %ampm%\n*Palabra random:* %rnd_arbol,burro,cabra,dinosaurio,elefante,fuego,gorila%\n*Emoji random:* %rnd_👍🏽,😁,🤣,🤔,🤦🏽♂️,🙄,😎%\n*Número random:* %rnd_1,2,3,4,5,6,7%\n"
|
||||
{
|
||||
"mensaje":[
|
||||
"%saludo%",
|
||||
"Hoy es %dia_semana%.",
|
||||
"Son las %hora24%:%minutos% hrs.",
|
||||
"Son las %hora12%:%minutos% %ampm%",
|
||||
"*Palabra random:* %rnd_arbol,burro,cabra,dinosaurio,elefante,fuego,gorila%",
|
||||
"*Emoji random:* %rnd_👍🏽,😁,🤣,🤔,🤦🏽♂️,🙄,😎%",
|
||||
"*Número random:* %rnd_1,2,3,4,5,6,7%\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null
|
||||
},
|
||||
"rnd2":{
|
||||
"keywords": ["rnd2"],
|
||||
"replyMessage":[
|
||||
""
|
||||
{
|
||||
"mensaje":[""]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
@@ -113,21 +180,24 @@
|
||||
}
|
||||
},
|
||||
"lista":{
|
||||
"keywords": ["4"],
|
||||
"replyMessage":[
|
||||
"*%saludo%*, este es un ejemplo de listas"
|
||||
{
|
||||
"mensaje":["*%saludo%*, este es un ejemplo de listas"]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"actions":{
|
||||
"body":"Hola *%primer_nombre%*, estos son ejemplos del uso de expresiones regulares, todas las opciones de la lista disparan la misma regla:\n\n'*pak*3*|*pak*angular*|*paquete*3*|*paquete*angular*'\n\nAutomáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*.",
|
||||
"body":"Hola *%primer_nombre%*, este es un ejemplo de lista con expresiones regulares, *todas* las opciones de la *lista* disparan la misma regla:\n\n'*pak*3*|*pak*angular*|*paquete*3*|*paquete*angular*'\n\nAutomáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*.",
|
||||
"buttonText":"Ver los ejemplos de RegEx",
|
||||
"sections": [
|
||||
{"title":"Selecciona un mensaje:",
|
||||
"rows":[
|
||||
{"id": "paq3", "title": "Me gusta el paquete 3"},
|
||||
{"id": "paqA", "title": "Por favor mas info del paquete de Angular"},
|
||||
{"id": "pakA", "title": "Me gustó el pak de Angular"},
|
||||
{"id": "pak3", "title": "Estoy interesado en el pak 3"}
|
||||
{"rowId": "paq3", "title": "Me gusta el paquete 3"},
|
||||
{"rowId": "paqA", "title": "Por favor mas info del paquete de Angular"},
|
||||
{"rowId": "pakA", "title": "Me gustó el pak de Angular"},
|
||||
{"rowId": "pak3", "title": "Estoy interesado en el pak 3"}
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -137,15 +207,18 @@
|
||||
"goto":"menu"
|
||||
},
|
||||
"botones":{
|
||||
"keywords": ["5"],
|
||||
"replyMessage":[
|
||||
"*%saludo%*, este es un ejemplo de botones"
|
||||
{
|
||||
"mensaje":["*%saludo%*, este es un ejemplo de botones"]
|
||||
}
|
||||
],
|
||||
"media":"https://media2.giphy.com/media/VQJu0IeULuAmCwf5SL/giphy.gif",
|
||||
"trigger":null,
|
||||
"actions":{
|
||||
"title":"¿Que te interesa ver %primer_nombre%?",
|
||||
"message":"Recuerda todo este contenido es gratis y estaria genial que me sigas!",
|
||||
"footer":"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*.",
|
||||
"footer":"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*.",
|
||||
"buttons":[
|
||||
{"body":"Cursos"},
|
||||
{"body":"Youtube"},
|
||||
@@ -156,56 +229,94 @@
|
||||
"goto":"menu"
|
||||
},
|
||||
"cursos":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste *Cursos*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": ["cursos"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste *Cursos*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"youtube":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste *YouTube*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": ["youtube"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste *YouTube*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"telegram":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste *Telegram*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": ["telegram"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste *Telegram*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"manzana":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste *manzana*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": ["manzana"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste *manzana*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"mango":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste *mango*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": ["mango"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste *mango*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"platano":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste *platano*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": ["platano"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste *platano*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"paq3":{
|
||||
"replyMessage":["*%saludo% %primer_nombre%*, seleccionaste el *paquete 3 de Angular*\n\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*."],
|
||||
"keywords": "*pak*3*|*pak*angular*|*paquete*3*|*paquete*angular*",
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":["*%saludo% %primer_nombre%*, seleccionaste el *paquete 3 de Angular*\n","Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 7 sin necesidad de volver a iniciar con */menu*."]
|
||||
}
|
||||
],
|
||||
"trigger":null,
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"botonespaq3":{
|
||||
"keywords": ["6"],
|
||||
"replyMessage":[
|
||||
"*%saludo%*, este es un ejemplo de botones y regExp"
|
||||
{
|
||||
"mensaje":["*%saludo%*, este es un ejemplo de botones y regExp"]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"actions":{
|
||||
"title":"Hola %primer_nombre%, escoge un mensaje:",
|
||||
"message":"Estos son ejemplos del uso de expresiones regulares, todos los botones disparan la misma regla:\n\n'*pak*3*|*pak*angular*|*paquete*3*|*paquete*angular*'\n\n",
|
||||
"message":"Estos son ejemplos del uso de expresiones regulares, *todos* los botones disparan la misma regla:\n\n'*pak*3*|*pak*angular*|*paquete*3*|*paquete*angular*'\n\n",
|
||||
"footer":"Automáticamente el flujo se regresa al *menú*, asi que puedes poner nuevamente un número del 1 al 5 sin necesidad de volver a iniciar con */menu*.",
|
||||
"buttons":[
|
||||
{"body":"Me gusta el paquete 3"},
|
||||
@@ -215,5 +326,97 @@
|
||||
},
|
||||
"pasoRequerido":"menu",
|
||||
"goto":"menu"
|
||||
},
|
||||
"soporte":{
|
||||
"keywords":["/soporte", "/ayuda"],
|
||||
"replyMessage":[
|
||||
{
|
||||
"mensaje":[
|
||||
"Bienvenido al soporte de Keymon, soy *Bow*.\n\n",
|
||||
"Dame por favor el usuario que quieres desbloquear respetando *mayúsculas* y *minúsculas*."
|
||||
]
|
||||
}
|
||||
],
|
||||
"media":null,
|
||||
"trigger":null
|
||||
},
|
||||
"Desbloqueo":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"Mensaje de desbloqueo de usuarios."
|
||||
],
|
||||
"funcion":"desbloqueaUsuario",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"soporte"
|
||||
},
|
||||
"gunaCats":{
|
||||
"keywords": ["/guna", "/demoventa", "/demoguna", "⬅️ cambiar categoria"],
|
||||
"replyMessage":[
|
||||
"Mensaje de getGunaCats"
|
||||
],
|
||||
"funcion":"getGunaCats",
|
||||
"media":null,
|
||||
"trigger":null
|
||||
},
|
||||
"gunaCats2":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"Mensaje de getGunaCats2"
|
||||
],
|
||||
"funcion":"getGunaSubtipo",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gunaCats"
|
||||
},
|
||||
"gunaProds":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"Mensaje de getGunaCats2"
|
||||
],
|
||||
"funcion":"getGunaProds",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gunaCats2"
|
||||
},
|
||||
"gunaProdsAgrega":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"Seleccionaste *%msjant_0%*, por favor indica la cantidad que quieres comprar (*solo el número*)."
|
||||
],
|
||||
"funcion":"agregaProds",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gunaProds"
|
||||
},
|
||||
"gunaProdsCantidad":{
|
||||
"keywords": "*",
|
||||
"replyMessage":[
|
||||
"Recibi cantidad"
|
||||
],
|
||||
"funcion":"prodCantidad",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gunaProdsAgrega"
|
||||
},
|
||||
"gunaComprarMas":{
|
||||
"keywords": "*agregar productos",
|
||||
"replyMessage":[
|
||||
"Quiero comprar mas."
|
||||
],
|
||||
"funcion":"comprarMas",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gunaProdsCantidad"
|
||||
},
|
||||
"gunaTerminaCompra":{
|
||||
"keywords": "*terminar",
|
||||
"replyMessage":[
|
||||
"Termina la compra"
|
||||
],
|
||||
"funcion":"terminaCompra",
|
||||
"media":null,
|
||||
"trigger":null,
|
||||
"pasoRequerido":"gunaProdsCantidad"
|
||||
}
|
||||
}
|
||||
12
implementaciones/credenciales.json
Normal file
12
implementaciones/credenciales.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "strong-maker-107118",
|
||||
"private_key_id": "419c2f761213d11f2f30edab66832a9c475e1d33",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDXlNkR2C9L7mXp\niMfPC4GwOKZcLIAa2XzrigJg3ettAHnWbxFSX4mS9AsmDKjBvkxpRVo+6gBzdtPa\nCZUQVZI6cWE+lCD2fMabwRQMosHxpRTUCruAnb/sku9y1o/KpdDemmqPaAHYxZXV\nex88svqcCPNhivqiPE/cRb1HoVu08IDG31Kgy3+iTpKQux05ngrYwem7wQl2k8dX\nS2SPp7YQID3gZeqWHyC2GVazn3Rz0PuKdp3wMnGB6MMI0yk3vLPHNpsEGyuyNeLG\nya68XBY86y9+LHZ8EwxUdVUmt8hUm0h5bDQftosRhgJakTUHZg9qNTM4iEJ7WYwP\nSao143C/AgMBAAECggEAI6kWxSm5HSWDdyot6cpR+sKhhjgYPW4XiLuCDDWkFsT6\n4nqUkhyFRylBBNttjkA6fI7BJbdojrEBIfKZf/kKYMorggICd94zrkULL3yRegr1\nfePZQ1EU6SnJxnnGkbN0cGDOWrLOMhDxFD4IcJknSmin9c0wYLt69wlpjNqcrw/B\ny6K63hi7M0iXGEHp8nz8Vf1l7VA82hCwUi7D73pkORH98xVY4+MYOTqrCvU0/O2m\nVqP5+mLMG/fPFlMnk8FgL3Q4dqiZ/ds7a6qXND5htSX0sFroINrTYiyXJ73OCgre\nlIbUuAD/92fuHKBdcIaaZvkEEAVTYlainm6LGroeSQKBgQDtq3mUTYO3998GiWO4\nVKnw7yC12WbwOaIDvlccWuTRWByJrRIJmsA1EXg18i9kf9AwxesbRT7xRBCwRMhs\nKUDbKaqvdf4BRARFWe0DSKQZIJpjCQsOtmOaV3yZP5uKLehQKPGgsIVT1A3XmIZW\nNzDAufVM5mjW8KbTNeBmMKRCJwKBgQDoNUMzDTLFl147jOaBJbq99Gd2pB7Aa8dY\n7SI3mXMMX0xCPU06Ym+wI485ybFllm+Bg018/+fJzli3Ko3nNuGcJplYzV8Z/eru\nMWGFCAXq3iWUiwXR9snmTAyO8uYXm7DnnhPxHNr8B3g3v55cTIqEjRn6YF5p7qBD\ntFQrV0ozqQKBgAvqqx/qew5AWWhkfyGA7TxtYQB9NBIbcaoqYwfC7vIoLtYgXWUp\n4zVF+PcLe6DYX8HySoWFhVBnj0anTD1QHDZg8nP1wJSjqmsnxSCDBedUoSkSDQHh\n10Cn3lF4xP26q4lJZEQgVa8MVN1YgnPUNJeVO11tuBf+3P5+FxBIpBPFAoGARxcH\nW7nOsW+GCfU5HJDQexc4FbppL7/PaAoxT5RLBJ6oWh8qZZV9XA+G6co15UQJHz1z\nm7E85SunPWxpxT+oEoY+rFEzrGFwazvy/ydVqHIaTz/AqGdFqJvfvGPgzZl8r2xV\n7ptG76HZzDd95AQK5EnOiji2rve/WPr8SciPjwECgYBf2SejOtRDWo6TOAQtEgvL\ngxU852DwuIW79U/+G2zrJ7qbbRzYCiHtsuaGOgzR5AfqN1+i4PWaJxdIKxymlv4w\nMs+swdsTZCn2/Rj4TndvEXr3OvfMtp0uN68rBNG+pNe1cwi+/+wx/E5ZC3QWxePt\nOwijAJ+obR377HMJOTTOTg==\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "strong-maker-107118@appspot.gserviceaccount.com",
|
||||
"client_id": "",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/strong-maker-107118%40appspot.gserviceaccount.com"
|
||||
}
|
||||
336
implementaciones/extraFuncs.js
Normal file
336
implementaciones/extraFuncs.js
Normal file
@@ -0,0 +1,336 @@
|
||||
const fs = require('fs')
|
||||
/**
|
||||
* Regresa un número random entre los parametros min y max dados.
|
||||
* @param {*} min
|
||||
* @param {*} max
|
||||
* @returns
|
||||
*/
|
||||
function getRandomInt(min, max) {
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
return Math.floor(Math.random() * (max - min) + min); // The maximum is exclusive and the minimum is inclusive
|
||||
}
|
||||
|
||||
/**
|
||||
* Revisa que exista el archivo "chats/numero.json"
|
||||
* @param {*} theFile
|
||||
* @returns
|
||||
*/
|
||||
function chkFile(theFile){ //MOD by CHV - Agregamos para revisar que exista el archivo "chats/numero.json"
|
||||
const fs = require('fs');
|
||||
if (fs.existsSync(theFile)) {
|
||||
// console.log("Si existe el archivo "+ theFile);
|
||||
var h = true;
|
||||
}
|
||||
else{
|
||||
// console.log("No existe el archivo "+ theFile);
|
||||
var h = false;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reemplaza texto en la respuesta con variables predefinidas.
|
||||
*/
|
||||
function remplazos(elTexto, extraInfo){
|
||||
if(elTexto == null){elTexto = '';}
|
||||
// console.log("EXTRAINFO_THEMSG", extraInfo.theMsg)
|
||||
// console.log(extraInfo.theMsg.messages)
|
||||
const { from, body, name } = extraInfo.theMsg
|
||||
laLista = elTexto.toString().split(' ');
|
||||
// console.log(laLista);
|
||||
// console.log('============= remplazos ============');
|
||||
for (var i = 0; i < laLista.length; i++) {
|
||||
// console.log('Revisamos: '+laLista[i]);
|
||||
if (laLista[i].search('%dia_semana%')>-1){//Remplaza con el dia de hoy.
|
||||
var dia = new Date().getDay();
|
||||
if(dia==0){diaSemana='domingo';}
|
||||
else if(dia==1){diaSemana='lunes';}
|
||||
else if(dia==2){diaSemana='martes';}
|
||||
else if(dia==3){diaSemana='miercoles';}
|
||||
else if(dia==4){diaSemana='jueves';}
|
||||
else if(dia==5){diaSemana='viernes';}
|
||||
else {diaSemana='sábado';}
|
||||
elTexto = elTexto.replace('%dia_semana%', diaSemana);
|
||||
}
|
||||
if (laLista[i].search('%saludo%')>-1){//Remplaza con "Buenos dias, tardes o noches" dependiendo de la hora.
|
||||
var hora = new Date().getHours()
|
||||
if(hora>0 && hora < 12){saludo='Buenos días';}
|
||||
else if(hora>11 && hora < 19){saludo='Buenas tardes';}
|
||||
else {saludo='Buenas noches';}
|
||||
elTexto = elTexto.toString().replace('%saludo%', saludo);
|
||||
}
|
||||
if (laLista[i].search('%hora24%')>-1){//Remplaza con la hora a 24 hrs.
|
||||
var hora = new Date().getHours();
|
||||
if (hora.toString().length < 2){hora = "0" + hora;}
|
||||
elTexto = elTexto.toString().replace('%hora24%', hora);
|
||||
}
|
||||
if (laLista[i].search('%hora12%')>-1){//Remplaza con la hora a 12 hrs.
|
||||
var hora = new Date().getHours();
|
||||
var ampm = hora >= 12 ? 'pm' : 'am';
|
||||
hora = hora % 12;
|
||||
hora = hora ? hora : 12; // the hour '0' should be '12'
|
||||
if (hora.toString().length < 2){hora = "0" + hora;}
|
||||
elTexto = elTexto.toString().replace('%hora12%', hora);
|
||||
}
|
||||
if (laLista[i].search('%minutos%')>-1){//Remplaza con los minutos de la hora actual.
|
||||
var mins = new Date().getMinutes();
|
||||
if (mins.toString().length < 2){mins = "0" + mins;}
|
||||
elTexto = elTexto.toString().replace('%minutos%', mins);
|
||||
}
|
||||
if (laLista[i].search('%ampm%')>-1){//Remplaza con am o pm.
|
||||
var hours = new Date().getHours();
|
||||
var ampm = hours >= 12 ? 'pm' : 'am';
|
||||
elTexto = elTexto.toString().replace('%ampm%', ampm);
|
||||
}
|
||||
if (laLista[i].search('%rnd_')>-1){//Remplaza con opción al azar dentro de las especificadas.
|
||||
var inicio = laLista[i].search('%rnd_');
|
||||
var final = laLista[i].indexOf("%", inicio+1);
|
||||
// console.log(inicio, final);
|
||||
var subStr = laLista[i].substring(inicio, final+1);
|
||||
// console.log("El substring="+subStr);
|
||||
var partes = subStr.toString().split('_');
|
||||
if(partes.length > 1){
|
||||
var opciones = partes[1].toString().substring(0,partes[1].toString().length-1).split(",");
|
||||
var elRand = Math.floor(Math.random() * (opciones.length));
|
||||
if(elRand == opciones.length){elRand = elRand - 1;}
|
||||
// console.log(opciones.length, elRand, opciones[elRand]);
|
||||
elTexto = elTexto.toString().replace(subStr, opciones[elRand]);
|
||||
}
|
||||
else{
|
||||
elTexto = elTexto.toString().replace(subStr, "");
|
||||
}
|
||||
}
|
||||
if(laLista[i].search('%msjant_')>-1){//Remplaza con el mensaje anterior especificado.
|
||||
var histlMsjs = {};
|
||||
console.log("entramos a msjant", from)
|
||||
var hayHistorial = (chkFile(`${__dirname}/chats/`+from+".json"));
|
||||
if(chkFile(`${__dirname}/../chats/`+from+".json")){
|
||||
let rawdata = fs.readFileSync(`./chats/${from}.json`);
|
||||
let elHistorial0 = JSON.parse(rawdata);
|
||||
elHistorial = elHistorial0["messages"];
|
||||
elHistorial = elHistorial.filter(x => x.message != "") //Quitamos mensajes en blanco.
|
||||
var inicio = laLista[i].search('%msjant_');
|
||||
var final = laLista[i].indexOf("%", inicio+1);
|
||||
var subStr = laLista[i].substring(inicio, final+1);
|
||||
// console.log("Substr = |" + subStr + "|");
|
||||
var partes = subStr.toString().split('_');
|
||||
if(partes.length > 1){
|
||||
// console.log("Partes[1] = |" + partes[1] + "|");
|
||||
let posicion0 = partes[1].substring(0, partes[1].length-1)
|
||||
// console.log("Posicion0 = |" + posicion0 + "|");
|
||||
posicion = ((posicion0*1) + 1);
|
||||
// console.log("Posicion = " + posicion);
|
||||
// console.log( elHistorial.length );
|
||||
// console.log((elHistorial.length*1)-posicion);
|
||||
// console.log("Mensaje="+elHistorial[elHistorial.length - posicion]["message"])
|
||||
elTexto = elTexto.toString().replace(subStr, elHistorial[elHistorial.length - posicion]["message"].trim());
|
||||
}
|
||||
// histlMsjs = elHistorial["messages"];
|
||||
// totalMsjs = histlMsjs.length-1;
|
||||
// ultimoMensaje = histlMsjs[histlMsjs.length-1];
|
||||
// let mensajeAnterior = elHistorial["messages"][totalMsjs-1];
|
||||
// console.log("Mensajes:"+totalMsjs+", Ultimo:"+JSON.stringify(ultimoMensaje));
|
||||
// console.log("Anterior:"+JSON.stringify(mensajeAnterior));
|
||||
}
|
||||
// return histlMsjs;
|
||||
}
|
||||
if (laLista[i].search('%body%')>-1){//Remplaza con el body del ctx.
|
||||
elTexto = elTexto.toString().replace('%body%', body);
|
||||
}
|
||||
if (laLista[i].search('%from%')>-1){//Remplaza con el from del ctx.
|
||||
elTexto = elTexto.toString().replace('%from%', from);
|
||||
}
|
||||
if (laLista[i].search('%solonumero%')>-1){//Remplaza con el from del ctx.
|
||||
elTexto = elTexto.toString().replace('%solonumero%', from.replace('@c.us', ''));
|
||||
}
|
||||
if (laLista[i].search('%nombre%')>-1){//Remplaza con el nombre del remitente.
|
||||
if(typeof extraInfo !== undefined){
|
||||
if(name !== undefined){
|
||||
elTexto = elTexto.toString().replace('%nombre%', name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (laLista[i].search('%primer_nombre%')>-1){//Remplaza con el nombre del remitente.
|
||||
if(typeof extraInfo !== undefined){
|
||||
// console.log("EXRAINFO:", extraInfo.theMsg)
|
||||
if(name !== undefined){
|
||||
elTexto = elTexto.toString().replace('%primer_nombre%', name.split(' ')[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log("EL TEXTO="+elTexto);
|
||||
return elTexto.trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* Regresa el historial de mensajes del número especificado del directorio "chats".
|
||||
*/
|
||||
function traeMensajes(from){ //MOD by CHV - Agregamos para traer el historial de mensajes
|
||||
var histlMsjs = {};
|
||||
var hayHistorial = (chkFile(`${__dirname}/chats/`+from+".json"));
|
||||
console.log(hayHistorial)
|
||||
// var hayHistorialNoBlanks = hayHistorial.find(k => k.messages.message != "")
|
||||
// console.log(hayHistorialNoBlanks)
|
||||
// var {keywords} = stepsInitial.find(k => k.key.includes(key))
|
||||
if(hayHistorial){
|
||||
let rawdata = fs.readFileSync(`./chats/${from}.json`);
|
||||
let elHistorial = JSON.parse(rawdata);
|
||||
histlMsjs = elHistorial["messages"];
|
||||
// totalMsjs = histlMsjs.length-1;
|
||||
ultimoMensaje = histlMsjs[histlMsjs.length-1];
|
||||
// let mensajeAnterior = elHistorial["messages"][totalMsjs-1];
|
||||
// console.log("Mensajes:"+totalMsjs+", Ultimo:"+JSON.stringify(ultimoMensaje));
|
||||
// console.log("Anterior:"+JSON.stringify(mensajeAnterior));
|
||||
}
|
||||
console.log(histlMsjs)
|
||||
// var histlMsjsNoBlanks = histlMsjs.find(k => k.message != "")
|
||||
var histlMsjsNoBlanks = histlMsjs.filter(x => x.message != "")
|
||||
console.log(histlMsjsNoBlanks)
|
||||
return histlMsjs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regresa el número limpio, sin @x.xxx
|
||||
* @param {*} from
|
||||
* @returns
|
||||
*/
|
||||
function soloNumero(from){
|
||||
let soloNum
|
||||
if(provider == 'baileys'){soloNum = from.replace('@s.whatsapp.net', '')}
|
||||
else if(provider == 'wwebjs'){soloNum = from.replace('@c.us', '')}
|
||||
return soloNum
|
||||
}
|
||||
|
||||
function agregaVars(client, msg, vars){
|
||||
const { from, body, name, hasMedia } = vars
|
||||
client.theMsg = msg;
|
||||
client.theMsg['body'] = body
|
||||
client.theMsg['from'] = from
|
||||
client.theMsg['hasMedia'] = hasMedia
|
||||
client.theMsg['name'] = name
|
||||
client.theMsg['numero'] = soloNumero(from)
|
||||
return client
|
||||
}
|
||||
|
||||
/*
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
var defaultDiacriticsRemovalMap = [ //MOD by CHV - Agregamos para eliminar acentos
|
||||
{'base':'A', 'letters':'\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'},
|
||||
{'base':'AA','letters':'\uA732'},
|
||||
{'base':'AE','letters':'\u00C6\u01FC\u01E2'},
|
||||
{'base':'AO','letters':'\uA734'},
|
||||
{'base':'AU','letters':'\uA736'},
|
||||
{'base':'AV','letters':'\uA738\uA73A'},
|
||||
{'base':'AY','letters':'\uA73C'},
|
||||
{'base':'B', 'letters':'\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181'},
|
||||
{'base':'C', 'letters':'\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E'},
|
||||
{'base':'D', 'letters':'\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0'},
|
||||
{'base':'DZ','letters':'\u01F1\u01C4'},
|
||||
{'base':'Dz','letters':'\u01F2\u01C5'},
|
||||
{'base':'E', 'letters':'\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E'},
|
||||
{'base':'F', 'letters':'\u0046\u24BB\uFF26\u1E1E\u0191\uA77B'},
|
||||
{'base':'G', 'letters':'\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E'},
|
||||
{'base':'H', 'letters':'\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D'},
|
||||
{'base':'I', 'letters':'\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197'},
|
||||
{'base':'J', 'letters':'\u004A\u24BF\uFF2A\u0134\u0248'},
|
||||
{'base':'K', 'letters':'\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2'},
|
||||
{'base':'L', 'letters':'\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780'},
|
||||
{'base':'LJ','letters':'\u01C7'},
|
||||
{'base':'Lj','letters':'\u01C8'},
|
||||
{'base':'M', 'letters':'\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C'},
|
||||
{'base':'N', 'letters':'\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4'},
|
||||
{'base':'NJ','letters':'\u01CA'},
|
||||
{'base':'Nj','letters':'\u01CB'},
|
||||
{'base':'O', 'letters':'\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C'},
|
||||
{'base':'OI','letters':'\u01A2'},
|
||||
{'base':'OO','letters':'\uA74E'},
|
||||
{'base':'OU','letters':'\u0222'},
|
||||
{'base':'OE','letters':'\u008C\u0152'},
|
||||
{'base':'oe','letters':'\u009C\u0153'},
|
||||
{'base':'P', 'letters':'\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754'},
|
||||
{'base':'Q', 'letters':'\u0051\u24C6\uFF31\uA756\uA758\u024A'},
|
||||
{'base':'R', 'letters':'\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782'},
|
||||
{'base':'S', 'letters':'\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784'},
|
||||
{'base':'T', 'letters':'\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786'},
|
||||
{'base':'TZ','letters':'\uA728'},
|
||||
{'base':'U', 'letters':'\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244'},
|
||||
{'base':'V', 'letters':'\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245'},
|
||||
{'base':'VY','letters':'\uA760'},
|
||||
{'base':'W', 'letters':'\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72'},
|
||||
{'base':'X', 'letters':'\u0058\u24CD\uFF38\u1E8A\u1E8C'},
|
||||
{'base':'Y', 'letters':'\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE'},
|
||||
{'base':'Z', 'letters':'\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762'},
|
||||
{'base':'a', 'letters':'\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250'},
|
||||
{'base':'aa','letters':'\uA733'},
|
||||
{'base':'ae','letters':'\u00E6\u01FD\u01E3'},
|
||||
{'base':'ao','letters':'\uA735'},
|
||||
{'base':'au','letters':'\uA737'},
|
||||
{'base':'av','letters':'\uA739\uA73B'},
|
||||
{'base':'ay','letters':'\uA73D'},
|
||||
{'base':'b', 'letters':'\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253'},
|
||||
{'base':'c', 'letters':'\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184'},
|
||||
{'base':'d', 'letters':'\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A'},
|
||||
{'base':'dz','letters':'\u01F3\u01C6'},
|
||||
{'base':'e', 'letters':'\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD'},
|
||||
{'base':'f', 'letters':'\u0066\u24D5\uFF46\u1E1F\u0192\uA77C'},
|
||||
{'base':'g', 'letters':'\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F'},
|
||||
{'base':'h', 'letters':'\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265'},
|
||||
{'base':'hv','letters':'\u0195'},
|
||||
{'base':'i', 'letters':'\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131'},
|
||||
{'base':'j', 'letters':'\u006A\u24D9\uFF4A\u0135\u01F0\u0249'},
|
||||
{'base':'k', 'letters':'\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3'},
|
||||
{'base':'l', 'letters':'\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747'},
|
||||
{'base':'lj','letters':'\u01C9'},
|
||||
{'base':'m', 'letters':'\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F'},
|
||||
{'base':'n', 'letters':'\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5'},
|
||||
{'base':'nj','letters':'\u01CC'},
|
||||
{'base':'o', 'letters':'\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275'},
|
||||
{'base':'oi','letters':'\u01A3'},
|
||||
{'base':'ou','letters':'\u0223'},
|
||||
{'base':'oo','letters':'\uA74F'},
|
||||
{'base':'p','letters':'\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755'},
|
||||
{'base':'q','letters':'\u0071\u24E0\uFF51\u024B\uA757\uA759'},
|
||||
{'base':'r','letters':'\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783'},
|
||||
{'base':'s','letters':'\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B'},
|
||||
{'base':'t','letters':'\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787'},
|
||||
{'base':'tz','letters':'\uA729'},
|
||||
{'base':'u','letters': '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289'},
|
||||
{'base':'v','letters':'\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C'},
|
||||
{'base':'vy','letters':'\uA761'},
|
||||
{'base':'w','letters':'\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73'},
|
||||
{'base':'x','letters':'\u0078\u24E7\uFF58\u1E8B\u1E8D'},
|
||||
{'base':'y','letters':'\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF'},
|
||||
{'base':'z','letters':'\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763'}
|
||||
];
|
||||
|
||||
var diacriticsMap = {};
|
||||
for (var i=0; i < defaultDiacriticsRemovalMap .length; i++){
|
||||
var letters = defaultDiacriticsRemovalMap [i].letters;
|
||||
for (var j=0; j < letters.length ; j++){
|
||||
diacriticsMap[letters[j]] = defaultDiacriticsRemovalMap [i].base;
|
||||
}
|
||||
}
|
||||
|
||||
// "what?" version ... http://jsperf.com/diacritics/12
|
||||
function removeDiacritics (str) {
|
||||
return str.replace(/[^\u0000-\u007E]/g, function(a){
|
||||
return diacriticsMap[a] || a;
|
||||
});
|
||||
}
|
||||
// var paragraph = "L'avantage d'utiliser le lorem ipsum est bien évidemment de pouvoir créer des maquettes ou de remplir un site internet de contenus qui présentent un rendu s'approchant un maximum du rendu final. \n Par défaut lorem ipsum ne contient pas d'accent ni de caractères spéciaux contrairement à la langue française qui en contient beaucoup. C'est sur ce critère que nous proposons une solution avec cet outil qui générant du faux-texte lorem ipsum mais avec en plus, des caractères spéciaux tel que les accents ou certains symboles utiles pour la langue française. \n L'utilisation du lorem standard est facile d’utilisation mais lorsque le futur client utilisera votre logiciel il se peut que certains caractères spéciaux ou qu'un accent ne soient pas codés correctement. \n Cette page a pour but donc de pouvoir perdre le moins de temps possible et donc de tester directement si tous les encodages de base de donnée ou des sites sont les bons de plus il permet de récuperer un code css avec le texte formaté !";
|
||||
// alert(removeDiacritics(paragraph));
|
||||
|
||||
module.exports = { removeDiacritics, traeMensajes, chkFile, getRandomInt, remplazos, soloNumero, agregaVars }
|
||||
74
implementaciones/sheets.js
Normal file
74
implementaciones/sheets.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const { getTime, getDate, getFormat, getCompareDate, getFormatMs } = require('util-tiempo')
|
||||
const { GoogleSpreadsheet } = require('google-spreadsheet');
|
||||
const fs = require('fs');
|
||||
const RESPONSES_SHEET_ID = '1tVRX1ojXJadsjRUJ-pNv8DZgziaIMcAdsMtPmWQRBcM'; //Generar en google.cloud
|
||||
const doc = new GoogleSpreadsheet(RESPONSES_SHEET_ID);
|
||||
const CREDENTIALS = JSON.parse(fs.readFileSync('./implementaciones/credenciales.json'));
|
||||
|
||||
async function ingresarDatos(numero, mensaje, sentido){
|
||||
let Fecha = getDate();
|
||||
let Hora = getTime(Date.now(), {local: 'es-MX', timeZone: 'America/Mexico_City', hour12:false});
|
||||
elNum = numero.replace('@c.us', '')
|
||||
if(elNum.substring(0,3) == '521') { elNum = elNum.replace('521', '52') }
|
||||
let rows = [{
|
||||
Numero: elNum.trim(),
|
||||
Mensaje: mensaje,
|
||||
Sentido: sentido,
|
||||
Fecha: Fecha,
|
||||
Hora: Hora
|
||||
}];
|
||||
try{
|
||||
await doc.useServiceAccountAuth({
|
||||
client_email: CREDENTIALS.client_email,
|
||||
private_key: CREDENTIALS.private_key
|
||||
});
|
||||
await doc.loadInfo();
|
||||
let sheet = doc.sheetsByTitle['Mensajes'];
|
||||
// console.log("SHEET=", sheet)
|
||||
for (let index = 0; index < rows.length; index++) {
|
||||
const row = rows[index];
|
||||
await sheet.addRow(row);
|
||||
console.log(`Datos guardados - ${sentido} (sheets.js)`)
|
||||
}
|
||||
}
|
||||
catch{
|
||||
console.log("Error Sheets")
|
||||
}
|
||||
}
|
||||
|
||||
async function leerDatos(telsim){
|
||||
await doc.useServiceAccountAuth({
|
||||
client_email: CREDENTIALS.client_email,
|
||||
private_key: CREDENTIALS.private_key
|
||||
});
|
||||
await doc.loadInfo();
|
||||
let sheet = doc.sheetsByIndex[0];
|
||||
let nya;
|
||||
let cont = 0
|
||||
let found = false
|
||||
nya = [];
|
||||
let rows = await sheet.getRows();
|
||||
console.log(rows.length)
|
||||
// for (let index = 0; index < rows.length; index++) {
|
||||
// const row = rows[index];
|
||||
// if (row.Telefono == telsim) {
|
||||
// nya['Nombre'] = row.Nombre+' '+row.Apellido
|
||||
// nya['Direccion'] = row.Direccion+' '+row.Planta+', '+row.CP
|
||||
// nya['Estado'] = row.Estado
|
||||
// }
|
||||
// }
|
||||
while (!found && cont < rows.length){ //Usamos while para que no recorra TODOS los registros y se pare encuanto lo encuentre.
|
||||
const row = rows[cont];
|
||||
console.log(row.Nombre, found, cont)
|
||||
if (row.Telefono == telsim) {
|
||||
nya['Nombre'] = row.Nombre+' '+row.Apellido
|
||||
nya['Direccion'] = row.Direccion+', '+row.Planta+', CP:'+row.CP
|
||||
nya['Estado'] = row.Estado
|
||||
found = true
|
||||
}
|
||||
cont++
|
||||
}
|
||||
return nya
|
||||
};
|
||||
|
||||
module.exports = {ingresarDatos,leerDatos};
|
||||
125
initBailey.js
Normal file
125
initBailey.js
Normal file
@@ -0,0 +1,125 @@
|
||||
const baileysReq = require ('@adiwajshing/baileys')
|
||||
var pino = require('pino');
|
||||
const { createWriteStream } = require('fs')
|
||||
var combineImage = require('combine-image');
|
||||
const {
|
||||
default: makeWASocket,
|
||||
useMultiFileAuthState,
|
||||
Browsers,
|
||||
DisconnectReason,
|
||||
} = baileysReq
|
||||
const globalVendorArgs = { name: `bot` }
|
||||
var qr = require('qr-image');
|
||||
|
||||
/**
|
||||
* Hace promesa el write
|
||||
* @param {*} base64
|
||||
*/
|
||||
const baileyGenerateImage = async (base64, name = 'qr.png') => {
|
||||
const PATH_QR = `${process.cwd()}/${name}`;
|
||||
let qr_svg = qr.image(base64, { type: 'png', margin: 4 });
|
||||
|
||||
const writeFilePromise = () =>
|
||||
new Promise((resolve, reject) => {
|
||||
const file = qr_svg.pipe(createWriteStream(PATH_QR));
|
||||
file.on('finish', () => resolve(true));
|
||||
file.on('error', reject);
|
||||
});
|
||||
|
||||
await writeFilePromise();
|
||||
|
||||
const cleanImage = await combineImage([PATH_QR], {
|
||||
margin: 15,
|
||||
color: 0xffffffff,
|
||||
});
|
||||
cleanImage.write(PATH_QR);
|
||||
};
|
||||
|
||||
|
||||
function listenMessage(client){
|
||||
client.ev.on('messages.upsert', async msg => {
|
||||
console.log('M=', msg)
|
||||
console.log('replying to', msg.messages[0])
|
||||
// await sock.sendMessage(m.messages[0].key.remoteJid, { text: 'hola como estas' })
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Iniciar todo Bailey
|
||||
*/
|
||||
initBailey = async () => {
|
||||
const NAME_DIR_SESSION = `baileys_sessions`;
|
||||
const { state, saveCreds } = await useMultiFileAuthState(
|
||||
NAME_DIR_SESSION
|
||||
);
|
||||
saveCredsGlobal = saveCreds;
|
||||
const sock = makeWASocket({
|
||||
// can provide additional config here
|
||||
printQRInTerminal: true,
|
||||
auth: state,
|
||||
browser: Browsers.macOS('Desktop'),
|
||||
syncFullHistory: false,
|
||||
logger: pino({ level: 'error' }),
|
||||
})
|
||||
try {
|
||||
sock.ev.on('connection.update', async (update) => {
|
||||
const { connection, lastDisconnect, qr } = update;
|
||||
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
||||
if(connection === 'close') {
|
||||
if (statusCode !== DisconnectReason.loggedOut) {
|
||||
initBailey();
|
||||
}
|
||||
if (statusCode === DisconnectReason.loggedOut) {
|
||||
const PATH_BASE = join(process.cwd(), NAME_DIR_SESSION);
|
||||
rimraf(PATH_BASE, (err) => {
|
||||
if (err) return
|
||||
});
|
||||
initBailey();
|
||||
}
|
||||
}
|
||||
/** Conexion abierta correctamente */
|
||||
if (connection === 'open') {
|
||||
console.log('ready', true);
|
||||
// initBusEvents(sock);
|
||||
}
|
||||
/** QR Code */
|
||||
if (qr) {
|
||||
console.log('require_action', {
|
||||
instructions: [
|
||||
`Debes escanear el QR Code para iniciar ${globalVendorArgs.name}.qr.png`,
|
||||
`Recuerda que el QR se actualiza cada minuto `,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
});
|
||||
await baileyGenerateImage(
|
||||
qr,
|
||||
`${globalVendorArgs.name}.qr.png`
|
||||
);
|
||||
}
|
||||
});
|
||||
sock.ev.on('creds.update', async () => {
|
||||
await saveCreds();
|
||||
});
|
||||
} catch (e) {
|
||||
// logger.log(e);
|
||||
console.log('auth_failure', [
|
||||
`Algo inesperado ha ocurrido NO entres en pánico`,
|
||||
`Reinicia el BOT`,
|
||||
`Tambien puedes mirar un log que se ha creado baileys.log`,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
`(Puedes abrir un ISSUE) https://github.com/codigoencasa/bot-whatsapp/issues/new/choose`,
|
||||
]);
|
||||
}
|
||||
listenMessage(sock)
|
||||
// sock.ev.on('messages.upsert', async (m) => {
|
||||
// console.log('M=', m)
|
||||
// console.log('replying to', m.messages[0])
|
||||
// // await sock.sendMessage(m.messages[0].key.remoteJid, { text: 'hola como estas' })
|
||||
// })
|
||||
}
|
||||
// run in main file
|
||||
initBailey()
|
||||
|
||||
|
||||
module.exports = { initBailey, listenMessage, baileyGenerateImage }
|
||||
2077
package-lock.json
generated
2077
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "test-ws-bot",
|
||||
"version": "1.0.0",
|
||||
"name": "chv-wweb-bot",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
@@ -11,13 +11,16 @@
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@adiwajshing/baileys": "^4.4.0",
|
||||
"@google-cloud/dialogflow": "^5.2.0",
|
||||
"axios": "^0.27.2",
|
||||
"combine-image": "^1.0.3",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.0.1",
|
||||
"exceljs": "^4.3.0",
|
||||
"express": "^4.18.1",
|
||||
"file-type": "^17.1.6",
|
||||
"google-spreadsheet": "^3.3.0",
|
||||
"googleapis": "^109.0.1",
|
||||
"mime-db": "^1.52.0",
|
||||
"moment": "^2.29.4",
|
||||
@@ -27,7 +30,8 @@
|
||||
"qrcode-terminal": "^0.12.0",
|
||||
"socket.io": "^4.5.1",
|
||||
"stormdb": "^0.6.0",
|
||||
"whatsapp-web.js": "github:pedroslopez/whatsapp-web.js#fix-buttons-list",
|
||||
"util-tiempo": "^1.0.41",
|
||||
"whatsapp-web.js": "github:cheveguerra/whatsapp-web.js#WaWJS2",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
133
provider/baileys.js
Normal file
133
provider/baileys.js
Normal file
@@ -0,0 +1,133 @@
|
||||
const { default: makeWASocket, useMultiFileAuthState, Browsers, DisconnectReason } = require ('@adiwajshing/baileys')
|
||||
var pino = require('pino');
|
||||
const { createWriteStream } = require('fs')
|
||||
var combineImage = require('combine-image');
|
||||
const { path, join } = require('path');
|
||||
const rimraf = require('rimraf')
|
||||
// function listenMessage(client){
|
||||
// client.on('messages.upsert', async msg => {
|
||||
// console.log('MSG=', msg)
|
||||
// console.log('REPLY TO=', msg.messages[0])
|
||||
// // await sock.sendMessage(m.messages[0].key.remoteJid, { text: 'hola como estas' })
|
||||
// })
|
||||
// }
|
||||
|
||||
// const { default: makeWASocket, useMultiFileAuthState, Browsers, DisconnectReason } = baileysReq
|
||||
const globalVendorArgs = { name: `bot` }
|
||||
var qr = require('qr-image');
|
||||
|
||||
/**
|
||||
* Hace promesa el write
|
||||
* @param {*} base64
|
||||
*/
|
||||
const baileyGenerateImage = async (base64, name = 'qr.png') => {
|
||||
const PATH_QR = `${process.cwd()}/${name}`;
|
||||
let qr_svg = qr.image(base64, { type: 'png', margin: 4 });
|
||||
|
||||
const writeFilePromise = () =>
|
||||
new Promise((resolve, reject) => {
|
||||
const file = qr_svg.pipe(createWriteStream(PATH_QR));
|
||||
file.on('finish', () => resolve(true));
|
||||
file.on('error', reject);
|
||||
});
|
||||
|
||||
await writeFilePromise();
|
||||
|
||||
const cleanImage = await combineImage([PATH_QR], {
|
||||
margin: 15,
|
||||
color: 0xffffffff,
|
||||
});
|
||||
cleanImage.write(PATH_QR);
|
||||
};
|
||||
/**
|
||||
* Iniciar todo Bailey
|
||||
*/
|
||||
initBot = async () => {
|
||||
console.log("Baileys Init")
|
||||
const NAME_DIR_SESSION = `baileys_sessions`;
|
||||
const { state, saveCreds } = await useMultiFileAuthState(
|
||||
NAME_DIR_SESSION
|
||||
);
|
||||
saveCredsGlobal = saveCreds;
|
||||
const sock = makeWASocket({
|
||||
// can provide additional config here
|
||||
printQRInTerminal: true,
|
||||
auth: state,
|
||||
browser: Browsers.macOS('Desktop'),
|
||||
syncFullHistory: false,
|
||||
logger: pino({ level: 'error' }),
|
||||
})
|
||||
try {
|
||||
sock.ev.on('connection.update', async (update) => {
|
||||
const { connection, lastDisconnect, qr } = update;
|
||||
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
||||
if(connection === 'close') {
|
||||
if (statusCode !== DisconnectReason.loggedOut) {
|
||||
initBot();
|
||||
}
|
||||
if (statusCode === DisconnectReason.loggedOut) {
|
||||
const PATH_BASE = join(process.cwd(), NAME_DIR_SESSION);
|
||||
rimraf(PATH_BASE, (err) => {
|
||||
if (err) return
|
||||
});
|
||||
initBot();
|
||||
}
|
||||
}
|
||||
/** Conexion abierta correctamente */
|
||||
if (connection === 'open') {
|
||||
console.log('ready', true);
|
||||
// initBusEvents(sock);
|
||||
}
|
||||
/** QR Code */
|
||||
if (qr) {
|
||||
console.log('require_action', {
|
||||
instructions: [
|
||||
`Debes escanear el QR Code para iniciar ${globalVendorArgs.name}.qr.png`,
|
||||
`Recuerda que el QR se actualiza cada minuto `,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
],
|
||||
});
|
||||
await baileyGenerateImage(qr, `${globalVendorArgs.name}.qr.png`);
|
||||
}
|
||||
});
|
||||
sock.ev.on('creds.update', async () => { await saveCreds() });
|
||||
}
|
||||
catch (e) {
|
||||
logger.log(e);
|
||||
console.log('auth_failure', [
|
||||
`Algo inesperado ha ocurrido NO entres en pánico`,
|
||||
`Reinicia el BOT`,
|
||||
`Tambien puedes mirar un log que se ha creado baileys.log`,
|
||||
`Necesitas ayuda: https://link.codigoencasa.com/DISCORD`,
|
||||
`(Puedes abrir un ISSUE) https://github.com/codigoencasa/bot-whatsapp/issues/new/choose`,
|
||||
]);
|
||||
}
|
||||
// listenMessage(sock.ev)
|
||||
return sock
|
||||
}
|
||||
// run in main file
|
||||
// initBot()
|
||||
|
||||
/**
|
||||
* Regresa las variables from, body, name y hasMedia de el objeto del mensaje.
|
||||
* @param {*} msg
|
||||
* @returns from, body, name, hasMedia
|
||||
*/
|
||||
function traeVariables(msg){
|
||||
const { remoteJid } = msg.messages[0].key
|
||||
const { pushName } = msg.messages[0]
|
||||
// console.log("THE_MSG = ", client.theMsg.messages[0])
|
||||
// console.log("*** CONVERSATION=", client.theMsg.messages[0].message?.conversation)
|
||||
// console.log("*** SELECTEDDISPLAYTEXT=", client.theMsg.messages[0].message?.buttonsResponseMessage?.selectedDisplayText)
|
||||
// console.log("*** TITLE=", client.theMsg.messages[0].message?.listResponseMessage?.title)
|
||||
let theBody = msg.messages[0].message?.conversation || msg.messages[0].message?.buttonsResponseMessage?.selectedDisplayText || msg.messages[0].message?.listResponseMessage?.title
|
||||
let from = remoteJid
|
||||
let body = theBody
|
||||
let name = pushName
|
||||
let hasMedia = false
|
||||
// console.log("fromBody=", from, body)
|
||||
return {"from":from, "body":body, "name":name, "hasMedia":hasMedia}
|
||||
}
|
||||
|
||||
|
||||
module.exports = { initBot, baileyGenerateImage, makeWASocket, traeVariables }
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user