mirror of
https://github.com/cheveguerra/botGuna.git
synced 2026-04-19 04:09:24 +00:00
Compare commits
3 Commits
master
...
BotPruebas
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e3e02c50b | |||
| 0bd297ec94 | |||
| e35147bb90 |
1
.env
1
.env
@@ -13,3 +13,4 @@ KEEP_DIALOG_FLOW=false
|
||||
MULTI_DEVICE=true
|
||||
DIALOGFLOW_MEDIA_FOR_SLOT_FILLING=false
|
||||
GDRIVE_FOLDER_ID=
|
||||
PROVIDER=baileys
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ mediaSend/*
|
||||
.wwebjs_auth
|
||||
backup
|
||||
backup/*
|
||||
/implementaciones/credenciales.json
|
||||
162
adapter/index.js
162
adapter/index.js
@@ -3,7 +3,7 @@ const { saveMessageJson } = require('./jsonDb')
|
||||
const { getDataIa } = require('./diaglogflow')
|
||||
// const stepsInitial = require('../flow/initial.json')
|
||||
const stepsReponse = require('../flow/response.json')
|
||||
const { isUndefined } = require('util');
|
||||
// const { isUndefined } = require('util');
|
||||
var ultimoStep; //MOD by CHV -
|
||||
var pasoRequerido; //MOD by CHV -
|
||||
var _vamosA = ""; //MOD by CHV -
|
||||
@@ -11,7 +11,9 @@ var VA = ""; //MOD by CHV -
|
||||
var elNum; //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).
|
||||
@@ -30,6 +32,12 @@ const getStepsInitial = () => {
|
||||
}
|
||||
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 -
|
||||
@@ -145,7 +153,6 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
||||
// 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;
|
||||
@@ -223,7 +230,7 @@ const saveMessage = ( message, trigger, number, regla ) => new Promise( async (r
|
||||
break;
|
||||
case 'none':
|
||||
resolve( await saveMessageJson( message, trigger, number, regla) ) //MOD by CHV - Agregamos el parametro "regla"
|
||||
// console.log("REGLA DESDE APP.JS="+regla)
|
||||
console.log("Guardamos mensaje JSON=", message)
|
||||
break;
|
||||
default:
|
||||
resolve(true)
|
||||
@@ -231,7 +238,6 @@ const saveMessage = ( message, trigger, number, regla ) => new Promise( async (r
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = { get, reply, getIA, saveMessage, remplazos, stepsInitial, vamosA, traeUltimaVisita } //MOD by CHV - Agregamos "remplazos" y "stepsInitial" para usarlos en "apps.js"
|
||||
|
||||
/**
|
||||
* Asigna el valor especificado a la variable pasoAnterior.
|
||||
@@ -245,146 +251,6 @@ function vamosA (elNum, elPaso){
|
||||
console.log("Asignamos pasoAnterior con " + elPaso, elNum)
|
||||
}
|
||||
|
||||
/**
|
||||
* Reemplaza texto en la respuesta con variables predefinidas.
|
||||
*/
|
||||
function remplazos(elTexto, extraInfo){
|
||||
if(elTexto == null){elTexto = '';}
|
||||
const fs = require('fs');
|
||||
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"];
|
||||
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.
|
||||
const {theMsg} = extraInfo;
|
||||
const { body } = theMsg
|
||||
elTexto = elTexto.toString().replace('%body%', body);
|
||||
}
|
||||
if (laLista[i].search('%from%')>-1){//Remplaza con el from del ctx.
|
||||
const {theMsg} = extraInfo;
|
||||
const { from } = theMsg
|
||||
elTexto = elTexto.toString().replace('%from%', from);
|
||||
}
|
||||
if (laLista[i].search('%solonumero%')>-1){//Remplaza con el from del ctx.
|
||||
const {theMsg} = extraInfo;
|
||||
const { from } = theMsg
|
||||
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){
|
||||
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.trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* Revisa si la regla especificada depende (es submenu) de otra regla, y cambia la variable "cumplePasoPrevio" a verdadero o falso.
|
||||
*/
|
||||
@@ -475,7 +341,9 @@ function dateDiff(datepart, fromdate, todate){
|
||||
d:86400000,
|
||||
h:3600000,
|
||||
n:60000,
|
||||
s:1000 };
|
||||
|
||||
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"
|
||||
495
app.js
495
app.js
@@ -2,93 +2,76 @@
|
||||
* ⚡⚡⚡ DECLARAMOS LAS LIBRERIAS y CONSTANTES A USAR! ⚡⚡⚡
|
||||
*/
|
||||
require('dotenv').config()
|
||||
global.provider = process.env.PROVIDER || 'wwebjs';
|
||||
const fs = require('fs');
|
||||
const express = require('express');
|
||||
global.siguientePaso = [{"numero":"1", "va":"XXX"}]; //MOD by CHV - Agregamos para pasar el VAMOSA a "index.js"
|
||||
global.pasoAnterior = [];
|
||||
const cors = require('cors')
|
||||
const axios = require('axios').default;//MOD by CHV - Agregamos para el get del "/URL"
|
||||
const qrcode = require('qrcode-terminal');
|
||||
const { Client, LocalAuth, Buttons, List } = require('whatsapp-web.js');
|
||||
const mysqlConnection = require('./config/mysql')
|
||||
// const { middlewareClient } = require('./middleware/client')
|
||||
const { generateImage, cleanNumber, checkEnvFile, createClient, isValidNumber } = require('./controllers/handle')
|
||||
const { connectionReady, connectionLost } = require('./controllers/connection')
|
||||
const { List } = require('whatsapp-web.js');
|
||||
// const mysqlConnection = require('./config/mysql')
|
||||
const { initBot, traeVariables } = require(`./provider/${provider}`)
|
||||
const { isValidNumber } = require('./controllers/handle')
|
||||
const { saveMedia, saveMediaToGoogleDrive } = require('./controllers/save')
|
||||
const { getMessages, responseMessages, bothResponse, waitFor } = require('./controllers/flows')
|
||||
const { sendMedia, sendMessage, lastTrigger, sendMessageButton, sendMessageList, readChat } = require('./controllers/send');
|
||||
const { remplazos, stepsInitial, vamosA, traeUltimaVisita } = require('./adapter/index');//MOD by CHV - Agregamos para utilizar remplazos y stepsInitial
|
||||
// const { isUndefined } = require('util');
|
||||
// const { isSet } = require('util/types');
|
||||
const { Console } = require('console');
|
||||
// const { ClientRequest } = require('http');
|
||||
const { sendMedia, sendMessage, sendMessageButton, sendMessageList, readChat } = require(`./controllers/send_${provider}`);
|
||||
const { stepsInitial, vamosA, traeUltimaVisita } = require('./adapter/index');//MOD by CHV - Agregamos para utilizar remplazos y stepsInitial
|
||||
const { removeDiacritics, getRandomInt, remplazos, soloNumero, agregaVars } = require('./implementaciones/extraFuncs')
|
||||
const { guardaXLSDatos, leeXLSDatos} = require('./Excel');
|
||||
// const { ContextsClient } = require('@google-cloud/dialogflow');
|
||||
const { ingresarDatos, leerDatos } = require('./implementaciones/sheets')
|
||||
const app = express();
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
const MULTI_DEVICE = process.env.MULTI_DEVICE || 'true';
|
||||
const server = require('http').Server(app)
|
||||
const port = process.env.PORT || 3000
|
||||
const delay = (ms) => new Promise((resolve) => setTimeout(resolve,ms))
|
||||
var client;
|
||||
let client
|
||||
let client0
|
||||
var dialogflowFilter = false;
|
||||
// var totalMsjs; //MOD by CHV -
|
||||
// var vamosA = ""; //MOD by CHV -
|
||||
var newBody; //MOD by CHV -
|
||||
var nuevaRespuesta; //MOD by CHV - Se agrego para los remplazos
|
||||
var vars = []
|
||||
app.use('/', require('./routes/web'))
|
||||
let blackList = ['34692936038', '34678310819', '34660962689', '34649145761','34630283553','34648827637','34630255646','14178973313']
|
||||
|
||||
/**
|
||||
* Escuchamos cuando entre un mensaje
|
||||
*/
|
||||
listenMessage = () => client.on('message', async msg => {
|
||||
const { from, body, hasMedia } = msg;
|
||||
function listenMessage(client){
|
||||
if(provider == 'wwebjs'){ client0 = client; messageEV = 'message' } // Usamos WWebJS.
|
||||
else { client0 = client.ev; messageEV = 'messages.upsert' } // Usamos Baileys.
|
||||
client0.on(messageEV, async msg => {
|
||||
const { from, body, name, hasMedia } = traeVariables(msg);
|
||||
if(provider == 'wwebjs'){ msg.type = 'notify' }
|
||||
if (vars[from] === undefined) vars[from] = []
|
||||
console.log("+++++++++++++++++++++++++++++++++++++ INICIO +++++++++++++++++++++++++++++++++++++++");
|
||||
client.theMsg = msg;
|
||||
console.log("HORA:"+new Date().toLocaleTimeString()+" FROM:"+from+", BODY:"+body+", HASMEDIA:"+hasMedia+", DEVICETYPE:"+client.theMsg?.deviceType);
|
||||
newBody = removeDiacritics(body) //MOD by CHV - Agregamos para quitar acentos
|
||||
|
||||
// const uv = traeUltimaVisita(from, 's')
|
||||
// console.log("ultVista=", uv)
|
||||
|
||||
if(!isValidNumber(from)){
|
||||
return
|
||||
}
|
||||
// Este bug lo reporto Lucas Aldeco Brescia para evitar que se publiquen estados
|
||||
if (from === 'status@broadcast') { return }
|
||||
/**
|
||||
* Blacklist, los telefonos incluidos en este arreglo son ignorados por el bot.
|
||||
*/
|
||||
if (blackList.includes(from.replace("@c.us",""))) {
|
||||
console.log('BlackListed: ',blackList.includes(from.replace("@c.us","")))
|
||||
return
|
||||
}
|
||||
if (from === 'status@broadcast' || msg.type !== 'notify') { console.log("########### status@broadcast o tipo mensaje = ", msg.type); return }
|
||||
console.log("+++++++++++++++++++++++++++++++++++++ INICIO +++++++++++++++++++++++++++++++++++++++");
|
||||
console.log("HORA:"+new Date().toLocaleTimeString()+" FROM:"+from+", BODY:"+body+", HASMEDIA:"+hasMedia+", DEVICETYPE:"+client.theMsg?.deviceType);
|
||||
// * Numero NO válido.
|
||||
if(!isValidNumber(from)){ console.log("Número invalido"); return }
|
||||
const number = soloNumero(from)
|
||||
newBody = removeDiacritics(body) //MOD by CHV - Agregamos para quitar acentos
|
||||
message = newBody.toLowerCase();
|
||||
const number = cleanNumber(from)
|
||||
client.theMsg['numero'] = number
|
||||
|
||||
|
||||
// Guardamos el mensaje en Google Sheets
|
||||
ingresarDatos(from, body)
|
||||
|
||||
// console.log(stepsInitial)
|
||||
// * Blacklist, los telefonos incluidos en este arreglo son ignorados por el bot.
|
||||
if (blackList.includes(number)){ console.log('BlackListed'); return }
|
||||
var { key } = stepsInitial.find(k => k.keywords.includes(message)) || { key: null }//MOD by CHV - Se agrega para obtener KEY
|
||||
await readChat(number, message, null , key) //MOD by CHV - Agregamos key/regla para guardarla en "chats/numero.json"
|
||||
// client.theMsg = msg;
|
||||
// client.theMsg['body'] = body
|
||||
// client.theMsg['from'] = from
|
||||
// client.theMsg['hasMedia'] = hasMedia
|
||||
// client.theMsg['key'] = key
|
||||
// client.theMsg['name'] = name
|
||||
// client.theMsg['numero'] = number
|
||||
client = agregaVars(client, msg, traeVariables(msg))
|
||||
client.theMsg['key'] = key
|
||||
|
||||
/**
|
||||
* Guardamos el archivo multimedia que envia
|
||||
* Si el mensaje trae un archivo multimedia, aquí lo guardamos.
|
||||
*/
|
||||
if (process.env.SAVE_MEDIA === 'true' && hasMedia) {
|
||||
const media = await msg.downloadMedia();
|
||||
saveMedia(media);
|
||||
}
|
||||
|
||||
// Guardamos los mensajes entrantes en una hoja de Google Sheets
|
||||
ingresarDatos(from, body, 'Entrada', 'Bot Pruebas')
|
||||
|
||||
/**
|
||||
* Si estas usando dialogflow solo manejamos una funcion todo es IA
|
||||
*/
|
||||
@@ -119,8 +102,28 @@ listenMessage = () => client.on('message', async msg => {
|
||||
return
|
||||
}
|
||||
|
||||
if(body == "/botones"){
|
||||
// Asi se mandan botones **directamente** con el cliente de whatsapp-web.js "client.sendMessage(from, productList)"
|
||||
const buttonMessage = [
|
||||
{"body":"boton 1"},
|
||||
{"body":"boton 2"}
|
||||
]
|
||||
const ab = {
|
||||
"title":"¿Que te interesa ver?",
|
||||
"message":"%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",
|
||||
"footer":"Gracias",
|
||||
"buttons":[
|
||||
{"body":"Cursos"},
|
||||
{"body":"Youtube"},
|
||||
{"body":"Telegram"}
|
||||
]
|
||||
}
|
||||
console.log("Enviamos botones = ", from, ab)
|
||||
sendMessageButton(client, from, "texto", ab)
|
||||
}
|
||||
|
||||
if(body=='/listas'){
|
||||
// Asi se manda directamente con el ciente de whatsapp-web.js "client.sendMessage(from, productList)"
|
||||
// Asi se mandan **listas** directamente con el ciente de whatsapp-web.js "client.sendMessage(from, productList)"
|
||||
const productList = new List(
|
||||
"Here's our list of products at 50% off",
|
||||
"View all products",
|
||||
@@ -154,27 +157,7 @@ listenMessage = () => client.on('message', async msg => {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ver si viene de un paso anterior
|
||||
* Aqui podemos ir agregando más pasos
|
||||
* a tu gusto!
|
||||
*/
|
||||
// const lastStep = await lastTrigger(from) || null;
|
||||
// client.theMsg['lastStep'] = lastStep
|
||||
// // console.log("LAST STEP="+lastStep+", FROM:"+from);
|
||||
// if (lastStep) {
|
||||
// const response = await responseMessages(lastStep)
|
||||
// client.theMsg['trigger'] = response.trigger
|
||||
// console.log("CLIENT="+client+", FROM:"+from+", REPLYMESSAGE:"+response.replyMessage);
|
||||
// // await sendMessage(client, from, response.replyMessage, lastStep); // Mod by CHV - Para mandar varios mensajes en el mismo response, se cambio esta linea por el forEach de abajo.
|
||||
// response.replyMessage.forEach( async messages => {
|
||||
// var thisMsg = messages.mensaje
|
||||
// if(Array.isArray(messages.mensaje)){thisMsg = messages.mensaje.join('\n')}
|
||||
// await sendMessage(client, from, remplazos(thisMsg, client), response.trigger);
|
||||
// })
|
||||
// }
|
||||
|
||||
/**
|
||||
* Respondemos al primero paso si encuentra palabras clave
|
||||
* Si el texto del mensaje dispara alguna regla, entramos a esta condición.
|
||||
*/
|
||||
const step = await getMessages(message, from);
|
||||
client.theMsg['step'] = step
|
||||
@@ -185,13 +168,14 @@ listenMessage = () => client.on('message', async msg => {
|
||||
var resps = require('./flow/response.json');
|
||||
nuevaRespuesta = remplazos(resps[step].replyMessage.join(''), client);
|
||||
client.theMsg['replyMessage'] = nuevaRespuesta
|
||||
// var pasoRequerido = resps[step].pasoRequerido;
|
||||
|
||||
/**
|
||||
* Trae información desde un archivo de excel y le manda a cada numero un mensaje. (Envío masivo)
|
||||
*/
|
||||
if(body=='traeXLS'){
|
||||
const rows = await leeXLSDatos('x')
|
||||
console.log("RESULTADOS:")
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)) }
|
||||
async function retardo() {
|
||||
for (sp=1;sp<rows.length;sp++) {
|
||||
// console.log(masivo[sp].numero+"@c.us");
|
||||
@@ -213,7 +197,7 @@ listenMessage = () => client.on('message', async msg => {
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
========================== ENVIO MASIVO TEST ===========================
|
||||
========================== ENVIO MASIVO (JSON)) =========================
|
||||
============================================================================
|
||||
*/
|
||||
if(message=='/spam'){
|
||||
@@ -264,25 +248,23 @@ listenMessage = () => client.on('message', async msg => {
|
||||
tempItem['id']=response.data.respuesta[reg].CAT_PT_DESC
|
||||
tempItem['title']=response.data.respuesta[reg].CAT_PT_DESC
|
||||
lasOpciones.push(tempItem)
|
||||
console.log(lasOpciones.length, tempItem)
|
||||
// console.log(lasOpciones.length, tempItem)
|
||||
}
|
||||
// console.log("lasOpciones="+lasOpciones[1])
|
||||
const productList = new List(
|
||||
remplazos("%saludo%, selecciona una categoría 👇🏽"),
|
||||
"Ver las categorías",
|
||||
[
|
||||
const productList = {
|
||||
body: remplazos("%saludo%, selecciona una categoría 👇🏽", ctx),
|
||||
title: "Ver las categorías",
|
||||
sections:[
|
||||
{ title: "Categorías",
|
||||
rows: lasOpciones,
|
||||
}
|
||||
],
|
||||
"Categorías",
|
||||
"Selecciona"
|
||||
)
|
||||
console.log(productList)
|
||||
client.sendMessage(from, productList)
|
||||
footer:"Categorías",
|
||||
buttonText:"Selecciona"
|
||||
}
|
||||
sendMessageList(client, from, null, productList)
|
||||
// console.log(ctx)
|
||||
// sendMessagList(client, from, null, productList);
|
||||
return "1"
|
||||
return
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
return error
|
||||
@@ -310,20 +292,20 @@ listenMessage = () => client.on('message', async msg => {
|
||||
tempItem['id']=response.data.respuesta[reg].CAT_PS_DESC
|
||||
tempItem['title']=response.data.respuesta[reg].CAT_PS_DESC
|
||||
lasOpciones.push(tempItem)
|
||||
console.log(lasOpciones.length, tempItem)
|
||||
// console.log(lasOpciones.length, tempItem)
|
||||
}
|
||||
// console.log("lasOpciones="+lasOpciones[3])
|
||||
const productList = new List(
|
||||
"Selecciona una subcategoria 👇🏽",
|
||||
"Ver las subcategorías",
|
||||
[
|
||||
const productList = {
|
||||
body: remplazos("Sselecciona una subcategoría 👇🏽", ctx),
|
||||
title: "Ver las subcategorías",
|
||||
sections:[
|
||||
{ title: "Subcategorías",
|
||||
rows: lasOpciones,
|
||||
}
|
||||
],
|
||||
`CATEGORÍA ${body}`
|
||||
)
|
||||
client.sendMessage(from, productList)
|
||||
footer:"",
|
||||
buttonText:`CATEGORÍA ${body}`
|
||||
}
|
||||
sendMessageList(client, from, null, productList)
|
||||
return "1"
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
@@ -337,29 +319,29 @@ listenMessage = () => client.on('message', async msg => {
|
||||
*/
|
||||
async function getGunaProds(ctx) {
|
||||
if(vars[from]['recompra'] === undefined) vars[from]['subtipo'] = ctx.theMsg.body
|
||||
console.log(vars[from]['tipo'], vars[from]['subtipo'])
|
||||
console.log(vars[from]['tipo'], vars[from]['subtipo'], "RECOMPRA=", vars[from]['recompra'])
|
||||
let theUrl = `http://localhost:8888/dbrquery?j={"query":"selectProdsFerreroMty","exec":"ExecuteQuery","params":{"par1":"${vars[from]['tipo']}", "par2":"${vars[from]['subtipo']}"}}`
|
||||
const RES = await axios.get(theUrl).then(function (response) {
|
||||
let elMensaje = "Gracias,\nAhora un producto:\n\n"
|
||||
let lasOpciones = []
|
||||
console.log("resultados selectProds",response.data.respuesta.length)
|
||||
for(reg=0;reg<response.data.respuesta.length;reg++) {
|
||||
let tempItem = {}
|
||||
tempItem['id']=response.data.respuesta[reg].CAT_GP_ID
|
||||
tempItem['title']=`${response.data.respuesta[reg].CAT_GP_NOMBRE} $${response.data.respuesta[reg].CAT_GP_PRECIO}, INV:${response.data.respuesta[reg].CAT_GP_ALMACEN} `
|
||||
lasOpciones.push(tempItem)
|
||||
}
|
||||
const productList = new List(
|
||||
"Selecciona un producto 👇🏽",
|
||||
"Ver los productos",
|
||||
[
|
||||
const productList = {
|
||||
body: remplazos("Selecciona un producto 👇🏽", ctx),
|
||||
title: "Ver los productos",
|
||||
sections:[
|
||||
{ title: "Productos",
|
||||
rows: lasOpciones,
|
||||
}
|
||||
],
|
||||
`SUBCATEGORÍA ${vars[from]['subtipo']}`,
|
||||
"Footer"
|
||||
)
|
||||
client.sendMessage(from, productList)
|
||||
buttonText:`SUBCATEGORÍA ${vars[from]['subtipo']}`
|
||||
}
|
||||
sendMessageList(client, from, null, productList)
|
||||
return "1"
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
@@ -380,12 +362,12 @@ listenMessage = () => client.on('message', async msg => {
|
||||
vars[from]['ultimoProd'] = elProd
|
||||
elProd = elProd.substring(0, elProd.indexOf(' $')).trim().toLowerCase()
|
||||
var precio = ctx.theMsg.body.substring(ctx.theMsg.body.indexOf(' $')+2)
|
||||
console.log("precio",precio)
|
||||
// console.log("precio",precio)
|
||||
precio = precio.substring(0, precio.indexOf(','))
|
||||
console.log("precio",precio)
|
||||
// console.log("precio",precio)
|
||||
vars[from]['prods'][elProd] = {"cant":0, "precio":precio}
|
||||
console.log("EL_PROD=", elProd)
|
||||
console.log(vars[from]['prods'])
|
||||
// console.log("EL_PROD=", elProd)
|
||||
// console.log(vars[from]['prods'])
|
||||
elMensaje = ctx.theMsg.replyMessage
|
||||
let re = ctx.theMsg.body.trim().toLowerCase()
|
||||
elMensaje = elMensaje.replace(re, elProd.toLowerCase())
|
||||
@@ -415,10 +397,10 @@ listenMessage = () => client.on('message', async msg => {
|
||||
elProd = elProd.substring(0, elProd.indexOf(' $')).trim()
|
||||
console.log("SOLO NUMS |" + laCant + "|", reg.test(laCant))
|
||||
if(reg.test(laCant)){
|
||||
console.log(vars)
|
||||
console.log("Recibimos cant = " + laCant)
|
||||
console.log("EL_PROD=", vars[from]['prods'][elProd])
|
||||
console.log("precio=", vars[from]['prods'][elProd].precio)
|
||||
// console.log(vars)
|
||||
// console.log("Recibimos cant = " + laCant)
|
||||
// console.log("EL_PROD=", vars[from]['prods'][elProd])
|
||||
// console.log("precio=", vars[from]['prods'][elProd].precio)
|
||||
vars[from]['prods'][elProd] = {"cant":laCant, "precio":vars[from]['prods'][elProd]['precio']}
|
||||
var elMensaje = ""
|
||||
const prods = Object.keys(vars[from]['prods']);
|
||||
@@ -464,7 +446,7 @@ listenMessage = () => client.on('message', async msg => {
|
||||
vars[from]['recompra'] = true
|
||||
vamosA(from, "gunaProds")
|
||||
await getGunaProds(ctx)
|
||||
vars[from]['recompra'] = false
|
||||
vars[from]['recompra'] = undefined
|
||||
return "1"
|
||||
}
|
||||
|
||||
@@ -538,7 +520,6 @@ listenMessage = () => client.on('message', async msg => {
|
||||
console.log("############# Encontramos función, ejecutamos la función '" + response.funcion + "'")
|
||||
laFuncion = response.funcion + "(client)"
|
||||
eval(laFuncion)
|
||||
// return
|
||||
}
|
||||
if(response.hasOwnProperty('url') && response.hasOwnProperty('values')){
|
||||
// let theURL = response.url;
|
||||
@@ -565,7 +546,9 @@ listenMessage = () => client.on('message', async msg => {
|
||||
*/
|
||||
if (!response.delay && response.media) {
|
||||
// console.log("++++++++++++++++++++++++++++ SEND MEDIA NO DELAY +++++++++++++++++++++++++++++++++++");
|
||||
sendMedia(client, from, response.media, response.trigger);
|
||||
await sendMedia(client, from, response.media, response.trigger);
|
||||
console.log("Enviamos imagen")
|
||||
await delay(500)
|
||||
}
|
||||
/**
|
||||
* Si quieres enviar imagen con retraso.
|
||||
@@ -588,18 +571,20 @@ listenMessage = () => client.on('message', async msg => {
|
||||
await sendMessage(client, from, remplazos(thisMsg, client), response.trigger);
|
||||
})
|
||||
}, response.delay)
|
||||
await delay(500)
|
||||
}
|
||||
else
|
||||
/**
|
||||
* Si quieres enviar un mensaje.
|
||||
*/
|
||||
{
|
||||
// await sendMessage(client, from, nuevaRespuesta, response.trigger, step); // Mod by CHV - Para mandar varios mensajes en el mismo response, se cambio esta linea por el forEach de abajo.
|
||||
{ // await sendMessage(client, from, nuevaRespuesta, response.trigger, step); // Mod by CHV - Para mandar varios mensajes en el mismo response, se cambio esta linea por el forEach de abajo.
|
||||
response.replyMessage.forEach( async messages => {
|
||||
var thisMsg = messages.mensaje
|
||||
if(Array.isArray(messages.mensaje)){thisMsg = messages.mensaje.join('\n')}
|
||||
await sendMessage(client, from, remplazos(thisMsg, client), response.trigger);
|
||||
console.log("Mensaje=", thisMsg)
|
||||
if(thisMsg !== undefined) await sendMessage(client, from, remplazos(thisMsg, client), response.trigger);
|
||||
})
|
||||
await delay(500)
|
||||
}
|
||||
/**
|
||||
* Si quieres enviar botones o listas
|
||||
@@ -608,11 +593,11 @@ listenMessage = () => client.on('message', async msg => {
|
||||
const { actions } = response;
|
||||
// console.log("++++++++++++++++++++++++++++ SEND MESG BUTTON/LIST +++++++++++++++++++++++++++++++++++");
|
||||
if(actions['sections'] === undefined){ //Botones
|
||||
// console.log("Botones")
|
||||
console.log("Botones")
|
||||
await sendMessageButton(client, from, null, actions);
|
||||
}
|
||||
else { //Listas
|
||||
// console.log("Listas")
|
||||
console.log("Listas")
|
||||
await sendMessageList(client, from, null, actions);
|
||||
}
|
||||
}
|
||||
@@ -634,25 +619,29 @@ listenMessage = () => client.on('message', async msg => {
|
||||
/**
|
||||
* Si quieres enviar botones
|
||||
*/
|
||||
// if(response.hasOwnProperty('actions')){
|
||||
// const { actions } = response;
|
||||
// if(actions['sections'] === undefined){ //Botones
|
||||
// console.log("Botones")
|
||||
// await sendMessageButton(client, from, null, actions);
|
||||
// }
|
||||
// else{ //Listas
|
||||
// console.log("Listas")
|
||||
// await sendMessageList(client, from, null, actions);
|
||||
// }
|
||||
// }
|
||||
if(response.hasOwnProperty('actions')){
|
||||
const { actions } = response;
|
||||
if(actions['sections'] === undefined){ //Botones
|
||||
console.log("Botones")
|
||||
await sendMessageButton(client, from, null, actions);
|
||||
}
|
||||
else{ //Listas
|
||||
console.log("Listas")
|
||||
await sendMessageList(client, from, null, actions);
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Este evento es necesario para el filtro de Dialogflow
|
||||
*/
|
||||
const listenMessageFromBot = () => client.on('message_create', async botMsg => {
|
||||
function listenMessageFromBot(client0){
|
||||
if(provider == 'wwebjs') {client = client0} else {client = client0.ev}
|
||||
client.on('message_create', async botMsg => {
|
||||
// const listenMessageFromBot = () => client.on('message_create', async botMsg => {
|
||||
const { body } = botMsg;
|
||||
const dialogflowFilterConfig = fs.readFileSync('./flow/dialogflow.json', 'utf8');
|
||||
const keywords = JSON.parse(dialogflowFilterConfig);
|
||||
@@ -668,231 +657,15 @@ const listenMessageFromBot = () => client.on('message_create', async botMsg => {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ####################################################################################################################
|
||||
// ############################## INICIAN FUNCIONES PARA LA CREACION DEL CLIENTE ####################################
|
||||
// ############################## DE WHATSAPP-WEB.JS ####################################
|
||||
// ####################################################################################################################
|
||||
|
||||
client = new Client({
|
||||
authStrategy: new LocalAuth(),
|
||||
puppeteer: { headless: true, args: ['--no-sandbox','--disable-setuid-sandbox'] }
|
||||
});
|
||||
|
||||
client.on('qr', qr => generateImage(qr, () => {
|
||||
qrcode.generate(qr, { small: true });
|
||||
console.log(`Ver QR http://localhost:${port}/qr`)
|
||||
socketEvents.sendQR(qr)
|
||||
}))
|
||||
|
||||
client.on('ready', (a) => {
|
||||
connectionReady()
|
||||
listenMessage()
|
||||
listenMessageFromBot()
|
||||
// socketEvents.sendStatus(client)
|
||||
});
|
||||
|
||||
client.on('auth_failure', (e) => {
|
||||
// console.log(e)
|
||||
// connectionLost()
|
||||
});
|
||||
|
||||
client.on('authenticated', () => {
|
||||
console.log('AUTHENTICATED');
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
|
||||
/**
|
||||
* Verificamos si tienes un gesto de db
|
||||
*/
|
||||
|
||||
if (process.env.DATABASE === 'mysql') {
|
||||
mysqlConnection.connect()
|
||||
async function inicializaBot(){
|
||||
const ib = await initBot()
|
||||
listenMessage(ib)
|
||||
listenMessageFromBot(ib)
|
||||
}
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`El server esta listo en el puerto ${port}`);
|
||||
})
|
||||
|
||||
checkEnvFile();
|
||||
|
||||
// ####################################################################################################################
|
||||
// ############################## INICIAN FUNCIONES VARIAS ####################################
|
||||
// ####################################################################################################################
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/*
|
||||
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));
|
||||
inicializaBot()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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,36 +1,57 @@
|
||||
|
||||
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)
|
||||
/**
|
||||
* 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);
|
||||
client.sendMessage(number, media, { sendAudioAsVoice: true });
|
||||
}
|
||||
} catch(e) {
|
||||
throw e;
|
||||
}
|
||||
const base64 = fs.readFileSync(fileName, { encoding: 'base64' })
|
||||
const mimeType = mime.lookup(fileName)
|
||||
const media = new MessageMedia(mimeType, base64)
|
||||
client.sendMessage(number, media, { caption })
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,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)
|
||||
@@ -136,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')
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"%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 pedir nombre (RegExp).",
|
||||
"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.",
|
||||
@@ -92,7 +92,7 @@
|
||||
"mensaje":[
|
||||
"Seleccionaste la *opción 3*\n",
|
||||
"*Por favor dame tu nombre.*\n",
|
||||
"Aquí vamos a aceptar *cualquier* texto, porque en el *initial.json* tenemos keywords : \"*\" (un asterisco en expresiones regulares quiere decir *\"cualquier cosa\"*)",
|
||||
"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\"."
|
||||
]
|
||||
}
|
||||
@@ -189,15 +189,15 @@
|
||||
"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"}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
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 }
|
||||
@@ -5,7 +5,7 @@ const RESPONSES_SHEET_ID = '1tVRX1ojXJadsjRUJ-pNv8DZgziaIMcAdsMtPmWQRBcM'; //Ge
|
||||
const doc = new GoogleSpreadsheet(RESPONSES_SHEET_ID);
|
||||
const CREDENTIALS = JSON.parse(fs.readFileSync('./implementaciones/credenciales.json'));
|
||||
|
||||
async function ingresarDatos(numero, mensaje){
|
||||
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', '')
|
||||
@@ -13,9 +13,11 @@ async function ingresarDatos(numero, mensaje){
|
||||
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
|
||||
@@ -26,21 +28,12 @@ async function ingresarDatos(numero, mensaje){
|
||||
for (let index = 0; index < rows.length; index++) {
|
||||
const row = rows[index];
|
||||
await sheet.addRow(row);
|
||||
console.log("Datos guardados (sheets.js)")
|
||||
console.log(`Datos guardados - ${sentido} (sheets.js)`)
|
||||
}
|
||||
}
|
||||
catch{
|
||||
console.log("Error Sheets")
|
||||
}
|
||||
// console.log('Fecha:',Fecha,);
|
||||
// console.log('Hora:',Hora);
|
||||
// console.log('Nombre:',nombre);
|
||||
// console.log('Apellidos:',apellido);
|
||||
// console.log('Direccion:',direccion);
|
||||
// console.log('Planta:',planta);
|
||||
// console.log('Codigo Postal:',CP);
|
||||
// console.log('Descripcion:',descripcion);
|
||||
// console.log('Telefono:',telsim);
|
||||
// console.log('Horario deseado:',horario);
|
||||
// console.log('ID_Solicitud: ',ID_Solicitud);
|
||||
// console.log('Estado: ',Estado)
|
||||
// console.log('-----------------------------------');
|
||||
}
|
||||
|
||||
async function leerDatos(telsim){
|
||||
|
||||
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 }
|
||||
1875
package-lock.json
generated
1875
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,8 +11,10 @@
|
||||
"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",
|
||||
|
||||
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 }
|
||||
65
provider/download.js
Normal file
65
provider/download.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const mimeDep = require('mime-types')
|
||||
const { tmpdir } = require('os')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
const { rename, createWriteStream } = require('fs')
|
||||
|
||||
/**
|
||||
* Extrar el mimetype from buffer
|
||||
* @param {string} response
|
||||
* @returns
|
||||
*/
|
||||
const fileTypeFromFile = async (response) => {
|
||||
const type = response.headers['content-type'] ?? null
|
||||
const ext = mimeDep.extension(type)
|
||||
return {
|
||||
type,
|
||||
ext,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Descargar archivo binay en tmp
|
||||
* @param {*} url
|
||||
* @returns
|
||||
*/
|
||||
const generalDownload = async (url) => {
|
||||
const handleDownload = () => {
|
||||
const checkProtocol = url.includes('https:')
|
||||
const handleHttp = checkProtocol ? https : http
|
||||
const name = `tmp-${Date.now()}-dat`
|
||||
const fullPath = `${tmpdir()}/${name}`
|
||||
const file = createWriteStream(fullPath)
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
handleHttp.get(url, function (response) {
|
||||
response.pipe(file)
|
||||
file.on('finish', async function () {
|
||||
file.close()
|
||||
res({ response, fullPath })
|
||||
})
|
||||
file.on('error', function () {
|
||||
file.close()
|
||||
rej(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const handleFile = (pathInput, ext) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const fullPath = `${pathInput}.${ext}`
|
||||
rename(pathInput, fullPath, (err) => {
|
||||
if (err) reject(null)
|
||||
resolve(fullPath)
|
||||
})
|
||||
})
|
||||
|
||||
const httpResponse = await handleDownload()
|
||||
const { ext } = await fileTypeFromFile(httpResponse.response)
|
||||
const getPath = await handleFile(httpResponse.fullPath, ext)
|
||||
|
||||
return getPath
|
||||
}
|
||||
|
||||
module.exports = { generalDownload }
|
||||
74
provider/wwebjs.js
Normal file
74
provider/wwebjs.js
Normal file
@@ -0,0 +1,74 @@
|
||||
const { Client, LocalAuth, Buttons, List } = require('whatsapp-web.js');
|
||||
require('dotenv').config()
|
||||
const express = require('express');
|
||||
const cors = require('cors')
|
||||
const qrcode = require('qrcode-terminal');
|
||||
const app = express();
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
const server = require('http').Server(app)
|
||||
const port = process.env.PORT || 3000
|
||||
const { generateImage, checkEnvFile } = require('../controllers/handle')
|
||||
const { connectionReady } = require('../controllers/connection')
|
||||
app.use('/', require('../routes/web'))
|
||||
|
||||
initBot = async () => {
|
||||
console.log("WaWebJS Init")
|
||||
client = new Client({
|
||||
authStrategy: new LocalAuth(),
|
||||
puppeteer: { headless: true, args: ['--no-sandbox','--disable-setuid-sandbox'] }
|
||||
});
|
||||
|
||||
client.on('qr', qr => generateImage(qr, () => {
|
||||
qrcode.generate(qr, { small: true });
|
||||
console.log(`Ver QR http://localhost:${port}/qr`)
|
||||
socketEvents.sendQR(qr)
|
||||
}))
|
||||
|
||||
client.on('ready', (a) => {
|
||||
connectionReady()
|
||||
// listenMessage(client)
|
||||
// listenMessageFromBot()
|
||||
// socketEvents.sendStatus(client)
|
||||
});
|
||||
|
||||
client.on('auth_failure', (e) => {
|
||||
// console.log(e)
|
||||
// connectionLost()
|
||||
});
|
||||
|
||||
client.on('authenticated', () => {
|
||||
console.log('AUTHENTICATED');
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
|
||||
/**
|
||||
* Verificamos si tienes un gesto de db
|
||||
*/
|
||||
|
||||
if (process.env.DATABASE === 'mysql') {
|
||||
mysqlConnection.connect()
|
||||
}
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log(`El server esta listo en el puerto ${port}`);
|
||||
})
|
||||
|
||||
checkEnvFile();
|
||||
return client
|
||||
}
|
||||
|
||||
/**
|
||||
* Regresa las variables from, body, name y hasMedia de el objeto del mensaje.
|
||||
* @param {*} msg
|
||||
* @returns from, body, name, hasMedia
|
||||
*/
|
||||
function traeVariables(msg){
|
||||
const { from, body, hasMedia } = msg;
|
||||
let name = msg?._data?.notifyName
|
||||
// console.log("fromBody=", msg?._data)
|
||||
return {"from":from, "body":body, "name":name, "hasMedia":hasMedia}
|
||||
}
|
||||
|
||||
module.exports = { initBot, traeVariables }
|
||||
Reference in New Issue
Block a user