From ec7ea9f794ae786fc6f026c207e6d525eef74dd3 Mon Sep 17 00:00:00 2001 From: cheveguerra Date: Fri, 17 Feb 2023 06:57:54 -0600 Subject: [PATCH] Inicial --- .env | 3 +- .gitignore | 5 +- adapter/index.js | 184 +--- app.js | 1429 ++++++++++-------------- appBaileys.js | 48 + controllers/flows.js | 6 + controllers/handle.js | 23 +- controllers/save.js | 3 - controllers/send_baileys.js | 188 ++++ controllers/send_wwebjs.js | 161 +++ controllers/web.js | 2 +- flow/response.json | 14 +- implementaciones/extraFuncs.js | 336 ++++++ implementaciones/sheets.js | 43 +- initBailey.js | 125 +++ package-lock.json | 1875 ++++++++++++++++++++++++++++++-- package.json | 2 + provider/baileys.js | 133 +++ provider/download.js | 65 ++ provider/wwebjs.js | 74 ++ 20 files changed, 3627 insertions(+), 1092 deletions(-) create mode 100644 appBaileys.js create mode 100644 controllers/send_baileys.js create mode 100644 controllers/send_wwebjs.js create mode 100644 implementaciones/extraFuncs.js create mode 100644 initBailey.js create mode 100644 provider/baileys.js create mode 100644 provider/download.js create mode 100644 provider/wwebjs.js diff --git a/.env b/.env index 346cec9..90bc32a 100644 --- a/.env +++ b/.env @@ -12,4 +12,5 @@ SQL_DATABASE= KEEP_DIALOG_FLOW=false MULTI_DEVICE=true DIALOGFLOW_MEDIA_FOR_SLOT_FILLING=false -GDRIVE_FOLDER_ID= \ No newline at end of file +GDRIVE_FOLDER_ID= +PROVIDER=wwebjs \ No newline at end of file diff --git a/.gitignore b/.gitignore index 53a9edb..ecd3a50 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,8 @@ mediaSend/* !mediaSend/.gitkeep !mediaSend/nota-de-voz.mp3 .wwebjs_auth +/baileys_sessions/* +bot.qr.png backup -backup/* \ No newline at end of file +backup/* +implementaciones/credenciales.json diff --git a/adapter/index.js b/adapter/index.js index 7c4c84b..51fb65d 100644 --- a/adapter/index.js +++ b/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. @@ -239,156 +245,16 @@ module.exports = { get, reply, getIA, saveMessage, remplazos, stepsInitial, vamo * NO EJECUTA EL PASO DADO, solo espfecifica cual es el paso anterior para cuando una regla tiene el parametro "pasoRequerido". * @param {elNum} string - El numero del remitente. * @param {elPaso} string - El paso al que se va redirigir el flujo. - */ +*/ function vamosA (elNum, elPaso){ pasoAnterior[elNum] = elPaso; console.log("Asignamos pasoAnterior con " + elPaso, elNum) } - -/** - * 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. - */ - function cumplePasoRequerido(step){ +*/ +function cumplePasoRequerido(step){ //Traemos las respuestas para obtener el "pasoRequerido". if(resps[step]!=undefined){pasoRequerido=resps[step].pasoRequerido}else{pasoRequerido=null} if((pasoRequerido != null && pasoRequerido == ultimoStep)){ @@ -411,7 +277,7 @@ function remplazos(elTexto, extraInfo){ * 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)) { @@ -430,7 +296,7 @@ function chkFile(theFile){ //MOD by CHV - Agregamos para revisar que exista el a * datepart: 'y', 'm', 'w', 'd', 'h', 'n', 's' (default = n) * @param {*} file * @param {*} datepart - */ +*/ function traeUltimaVisita(file, datepart = 'n'){ // Node.js program to demonstrate the // fs.futimes() method @@ -460,7 +326,7 @@ function traeUltimaVisita(file, datepart = 'n'){ } else { return 0 } } - /** +/** * Regresa el tiempo transcurrido en (datepart) entre las fechas dadas. * datepart: 'y', 'm', 'w', 'd', 'h', 'n', 's' * @param {*} datepart @@ -472,10 +338,12 @@ function dateDiff(datepart, fromdate, todate){ datepart = datepart.toLowerCase(); var diff = todate - fromdate; var divideBy = { w:604800000, - d:86400000, - h:3600000, - n:60000, - s:1000 }; - + d:86400000, + h:3600000, + n:60000, + s:1000 + }; return Math.floor( diff/divideBy[datepart]); -} \ No newline at end of file +} + +module.exports = { get, reply, getIA, saveMessage, stepsInitial, vamosA, traeUltimaVisita } //MOD by CHV - Agregamos "stepsInitial" para usarlos en "apps.js" \ No newline at end of file diff --git a/app.js b/app.js index 7f1c31d..6a7f720 100644 --- a/app.js +++ b/app.js @@ -2,897 +2,670 @@ * ⚡⚡⚡ 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; - 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 +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] = [] + // Este bug lo reporto Lucas Aldeco Brescia para evitar que se publiquen estados + 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(); + // * 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 - // 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 - } - message = newBody.toLowerCase(); - const number = cleanNumber(from) - client.theMsg['numero'] = number - - - // Guardamos el mensaje en Google Sheets - ingresarDatos(from, body) - - // console.log(stepsInitial) - 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['key'] = key - - /** - * Guardamos el archivo multimedia que envia - */ - if (process.env.SAVE_MEDIA === 'true' && hasMedia) { - const media = await msg.downloadMedia(); - saveMedia(media); - } - - /** - * Si estas usando dialogflow solo manejamos una funcion todo es IA - */ - if (process.env.DATABASE === 'dialogflow') { - if (process.env.DIALOGFLOW_MEDIA_FOR_SLOT_FILLING === 'true' && dialogflowFilter) { - waitFor(_ => hasMedia, 30000) - .then(async _ => { - if (hasMedia) { - const media = await msg.downloadMedia(); - message = await saveMediaToGoogleDrive(media); - const response = await bothResponse(message.substring(256, -1), number); - await sendMessage(client, from, response.replyMessage); - } - return - }); - dialogflowFilter = false; - } - if (!message.length) return; - const response = await bothResponse(message.substring(256, -1), number); - await sendMessage(client, from, response.replyMessage); - if (response.actions) { - await sendMessageButton(client, from, null, response.actions); - return - } - if (response.media) { - sendMedia(client, from, response.media); - } - return - } - - if(body=='/listas'){ - // Asi se manda 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", - [ - { - title: "Products list", - rows: [ - { id: "apple", title: "Apple" }, - { id: "mango", title: "Mango" }, - { id: "banana", title: "Banana" }, - ], - }, - ], - "Please select a product" - ); - console.log('##################################################################################################') - console.log("****************** productList ******************") - console.log(productList) - client.sendMessage(from, productList); - // Asi se manda directamente con la funcion del bot. "sendMessageList(client, from, null, lista)" - // let sections = [ - // { title:'sectionTitle', - // rows:[ - // {id:'ListItem1', title: 'title1'}, - // {id:'ListItem2', title:'title2'} - // ] - // } - // ]; - // let lista = new List('List body','btnText',sections,'Title','footer'); - await sendMessageList(client, from, null, productList); //sendMessageList recibe el arreglo CON nombres, tal cual se usa en "response.json" - } - - /** - * 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 - */ - const step = await getMessages(message, from); - client.theMsg['step'] = step - if (step) { - // console.log("Entramos a STEP") - const response = await responseMessages(step); - client.theMsg['trigger'] = response.trigger - var resps = require('./flow/response.json'); - nuevaRespuesta = remplazos(resps[step].replyMessage.join(''), client); - client.theMsg['replyMessage'] = nuevaRespuesta - // var pasoRequerido = resps[step].pasoRequerido; - if(body=='traeXLS'){ - const rows = await leeXLSDatos('x') - console.log("RESULTADOS:") - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } - async function retardo() { - for (sp=1;sp setTimeout(resolve, ms)); - } - async function retardo() { - for (sp=0;sp hasMedia, 30000) + .then(async _ => { + if (hasMedia) { + const media = await msg.downloadMedia(); + message = await saveMediaToGoogleDrive(media); + const response = await bothResponse(message.substring(256, -1), number); + await sendMessage(client, from, response.replyMessage); } - ], - "Categorías", - "Selecciona" - ) - console.log(productList) - client.sendMessage(from, productList) - // console.log(ctx) - // sendMessagList(client, from, null, productList); - return "1" - }).catch(function (error) { - console.log(error); - return error - }); - } - /** - * Llama el API para traer subcategorias de Guna. - * @param {*} ctx El objeto del mensaje. - */ - async function getGunaSubtipo(ctx) { - let par1 = ctx.theMsg.body - vars[from]['tipo'] = ctx.theMsg.body - // console.log("V_TIPO=", from, vars[from]['tipo']) - let theUrl = `http://localhost:8888/dbrquery?j={"query":"selectSubtipoFerreroMty","exec":"ExecuteQuery","params":{"par1":"${vars[from]['tipo']}"}}` - const RES = await axios.get(theUrl).then(function (response) { - if( response.data.respuesta.length == 0 ) { - console.log("No hay resultados",from) - vamosA(from, "gunaCats") - client.sendMessage(from, "Esa categoría *no existe*, por favor revisa y vuelve a intentar.") - } - let elMensaje = "Gracias,\nAhora una subcategoría:\n\n" - let lasOpciones = [] - for(reg=0;reg -1){ // Producto con formato correcto. - 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) - precio = precio.substring(0, precio.indexOf(',')) - console.log("precio",precio) - vars[from]['prods'][elProd] = {"cant":0, "precio":precio} - 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()) + return + }); + dialogflowFilter = false; } - else{ // Producto SIN precio. - elMensaje = "El producto que seleccionaste es *incorrecto*, por favor intenta de nuevo." - sendMessage(client, from, elMensaje, ctx.theMsg.trigger, ctx.theMsg.step); - await delay(500) - vars[from]['recompra'] = true - getGunaProds() - vamosA(from, "gunaProds") + if (!message.length) return; + const response = await bothResponse(message.substring(256, -1), number); + await sendMessage(client, from, response.replyMessage); + if (response.actions) { + await sendMessageButton(client, from, null, response.actions); return } - sendMessage(client, from, elMensaje, ctx.theMsg.trigger, ctx.theMsg.step); + if (response.media) { + sendMedia(client, from, response.media); + } 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 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", + [ + { + title: "Products list", + rows: [ + { id: "apple", title: "Apple" }, + { id: "mango", title: "Mango" }, + { id: "banana", title: "Banana" }, + ], + }, + ], + "Please select a product" + ); + console.log('##################################################################################################') + console.log("****************** productList ******************") + console.log(productList) + client.sendMessage(from, productList); + // Asi se manda directamente con la funcion del bot. "sendMessageList(client, from, null, lista)" + // let sections = [ + // { title:'sectionTitle', + // rows:[ + // {id:'ListItem1', title: 'title1'}, + // {id:'ListItem2', title:'title2'} + // ] + // } + // ]; + // let lista = new List('List body','btnText',sections,'Title','footer'); + await sendMessageList(client, from, null, productList); //sendMessageList recibe el arreglo CON nombres, tal cual se usa en "response.json" + } + /** - * Tomamos la cantidad del producto seleccionado. - * @param {*} ctx El objeto del mensaje. - */ - async function prodCantidad(ctx) { - // console.log("Entramos a prodCantidad") - let laCant = ctx.theMsg.body.trim() - const reg = new RegExp(/^\d+$/) - let elProd = vars[from]['ultimoProd'].toLowerCase() - 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) - vars[from]['prods'][elProd] = {"cant":laCant, "precio":vars[from]['prods'][elProd]['precio']} - var elMensaje = "" - const prods = Object.keys(vars[from]['prods']); - var total = 0 - prods.forEach((prod, index) => { - if( vars[from]['prods'][prod] !== undefined && prod[0] !== undefined ){ - elMensaje = elMensaje + `${vars[from]['prods'][prod].cant} - ${prod[0].toUpperCase() + prod.substring(1)}\n` - console.log("cant y precio=", vars[from]['prods'][prod].cant, vars[from]['prods'][prod].precio) - if(reg.test(vars[from]['prods'][prod].cant) && vars[from]['prods'][prod].precio != ""){ - total = total + (vars[from]['prods'][prod].cant * vars[from]['prods'][prod].precio) - } - } - console.log(prod, vars[from]['prods'][prod]); - }); - let pesos = Intl.NumberFormat('en-US') - elMensaje = elMensaje + "\n*Total*: $" + pesos.format(total) - elMensaje = elMensaje + "\n¿Quieres agregar mas productos a tu orden?" - var bts = { - "title":"Tu orden", - "message":elMensaje, - "buttons":[ - {"body":"➕ Agregar productos"}, - {"body":"⬅️ Cambiar categoría"}, - {"body":"✖️ Terminar"} - ] + * Si el texto del mensaje dispara alguna regla, entramos a esta condición. + */ + const step = await getMessages(message, from); + client.theMsg['step'] = step + if (step) { + // console.log("Entramos a STEP") + const response = await responseMessages(step); + client.theMsg['trigger'] = response.trigger + var resps = require('./flow/response.json'); + nuevaRespuesta = remplazos(resps[step].replyMessage.join(''), client); + client.theMsg['replyMessage'] = nuevaRespuesta + + /** + * 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)) } + async function retardo() { + for (sp=1;sp setTimeout(resolve, ms)); + } + async function retardo() { + for (sp=0;sp -1){ // Producto con formato correcto. + 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) + precio = precio.substring(0, precio.indexOf(',')) + // console.log("precio",precio) + vars[from]['prods'][elProd] = {"cant":0, "precio":precio} + // 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()) + } + else{ // Producto SIN precio. + elMensaje = "El producto que seleccionaste es *incorrecto*, por favor intenta de nuevo." + sendMessage(client, from, elMensaje, ctx.theMsg.trigger, ctx.theMsg.step); + await delay(500) + vars[from]['recompra'] = true + getGunaProds() + vamosA(from, "gunaProds") + return + } + sendMessage(client, from, elMensaje, ctx.theMsg.trigger, ctx.theMsg.step); + return + } + + /** + * Tomamos la cantidad del producto seleccionado. + * @param {*} ctx El objeto del mensaje. + */ + async function prodCantidad(ctx) { + // console.log("Entramos a prodCantidad") + let laCant = ctx.theMsg.body.trim() + const reg = new RegExp(/^\d+$/) + let elProd = vars[from]['ultimoProd'].toLowerCase() + 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) + vars[from]['prods'][elProd] = {"cant":laCant, "precio":vars[from]['prods'][elProd]['precio']} + var elMensaje = "" + const prods = Object.keys(vars[from]['prods']); + var total = 0 + prods.forEach((prod, index) => { + if( vars[from]['prods'][prod] !== undefined && prod[0] !== undefined ){ + elMensaje = elMensaje + `${vars[from]['prods'][prod].cant} - ${prod[0].toUpperCase() + prod.substring(1)}\n` + console.log("cant y precio=", vars[from]['prods'][prod].cant, vars[from]['prods'][prod].precio) + if(reg.test(vars[from]['prods'][prod].cant) && vars[from]['prods'][prod].precio != ""){ + total = total + (vars[from]['prods'][prod].cant * vars[from]['prods'][prod].precio) + } + } + console.log(prod, vars[from]['prods'][prod]); + }); + let pesos = Intl.NumberFormat('en-US') + elMensaje = elMensaje + "\n*Total*: $" + pesos.format(total) + elMensaje = elMensaje + "\n¿Quieres agregar mas productos a tu orden?" + var bts = { + "title":"Tu orden", + "message":elMensaje, + "buttons":[ + {"body":"➕ Agregar productos"}, + {"body":"⬅️ Cambiar categoría"}, + {"body":"✖️ Terminar"} + ] + } + sendMessageButton(client, from, "xxx", bts) } else{ - sendMessage(client, from, "El usuario *"+response.data['params']['par1']+"* no *existe* o esta dado de *baja*, por favor revisarlo y volver a intentar.", response.trigger, step); + console.log("NO SOLO NUMS") + vamosA(from, "gunaProdsAgrega") + sendMessage(client, from, "Por favor escribe 👉🏽 *solo* 👈🏽 el número.", response.trigger, step); } - return response - }).catch(function (error) { - console.log(error); - return error - }); - } - - /** - * Llama el API para desbloquear el usuario. - * - * @param {*} theURL El URL para llamar al API - * @param {*} step - */ - async function desbloqueaUsuario2(theUrl, step) { - // const {from} = client.theMsg - // const RES = await axios.get(theUrl).then(function (response) { - // const { AffectedRows } = response.data['respuesta'][0] - // console.log('AFFECTED_ROWS = ', AffectedRows) - // if(response.data['respuesta'][0]['AffectedRows']=="1"){ - // sendMessage(client, from, "Listo, usuario *"+response.data['params']['par1']+"* desbloqueado, por favor *cerrar navegadores* y reingresar.", response.trigger, step); - // } - // else{ - // sendMessage(client, from, "El usuario *"+response.data['params']['par1']+"* no *existe* o esta dado de *baja*, por favor revisarlo y volver a intentar.", response.trigger, step); - // } - // return response - // }).catch(function (error) { - // console.log(error); - // return error - // }); - } + return "1" + } + + /** + * Mandamos nuevamente la lista de productos. + * @param {*} ctx El objeto del mensaje. + */ + async function comprarMas(ctx) { + console.log("Entramos a comprarMas") + vars[from]['recompra'] = true + vamosA(from, "gunaProds") + await getGunaProds(ctx) + vars[from]['recompra'] = undefined + return "1" + } + + /** + * Mandamos nuevamente la lista de categorías. + * @param {*} ctx El objeto del mensaje. + */ + async function terminaCompra(ctx) { + console.log("Entramos a terminaCompra") + vars[from] = [] + sendMessage(client, from, "!Gracias por tu compra, regresa pronto!", response.trigger, step); + return + } - // #################################################################################################################### - // ############################## INICIAN FUNCIONES PARA MANEJO DE PARAMETROS ##################################### - // ############################## EN EL RESPONSE.JSON ##################################### - // #################################################################################################################### + /** + * Llama el API para desbloquear un usuario. + * @param {*} ctx El objeto del mensaje. + */ + async function desbloqueaUsuario(ctx) { + let par1 = ctx.theMsg.body + let theUrl = `http://localhost:8888/dbrquery?j={"query":"update_usuario_guna_nobajas","exec":"ExecuteCommand","params":{"par1":"${par1}", "par2":"XXPARAM2XX", "par3":"XXPARAM3XX"}}` + const RES = await axios.get(theUrl).then(function (response) { + const { AffectedRows } = response.data['respuesta'][0] + console.log('AFFECTED_ROWS = ', AffectedRows) + if(response.data['respuesta'][0]['AffectedRows']=="1"){ + sendMessage(client, from, "Listo, usuario *"+response.data['params']['par1']+"* desbloqueado, por favor *cerrar navegadores* y reingresar.", response.trigger, step); + } + else{ + sendMessage(client, from, "El usuario *"+response.data['params']['par1']+"* no *existe* o esta dado de *baja*, por favor revisarlo y volver a intentar.", response.trigger, step); + } + return response + }).catch(function (error) { + console.log(error); + return error + }); + } + + /** + * Llama el API para desbloquear el usuario. + * + * @param {*} theURL El URL para llamar al API + * @param {*} step + */ + async function desbloqueaUsuario2(theUrl, step) { + // const {from} = client.theMsg + // const RES = await axios.get(theUrl).then(function (response) { + // const { AffectedRows } = response.data['respuesta'][0] + // console.log('AFFECTED_ROWS = ', AffectedRows) + // if(response.data['respuesta'][0]['AffectedRows']=="1"){ + // sendMessage(client, from, "Listo, usuario *"+response.data['params']['par1']+"* desbloqueado, por favor *cerrar navegadores* y reingresar.", response.trigger, step); + // } + // else{ + // sendMessage(client, from, "El usuario *"+response.data['params']['par1']+"* no *existe* o esta dado de *baja*, por favor revisarlo y volver a intentar.", response.trigger, step); + // } + // return response + // }).catch(function (error) { + // console.log(error); + // return error + // }); + } - /* - * Si quieres ejecutar una función. - */ - if(response.hasOwnProperty('funcion')){ - 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; - // let url0 = theURL - // let vals = response.values // Traemos los valores desde el response.json - // let j = theURL.split('j=')[1] // Traemos el JSON del URL. - // let j2 = JSON.parse(j) - // let cont = 0 - // const { params } = j2 // Traemos los parametros del JSON. - // console.log('PARAMS=', params, params['par1'], Object.keys(params).length) - // let url2 - // for (const par in params) { // Remplazamos los valores en lo parametros. - // console.log(`${par}: ${params[par]}, ${cont}: ${remplazos(vals[cont], client)}`); - // if(cont==0){url2=url0.replace(params[par], remplazos(vals[cont], client));} - // else {url2=url2.replace(params[par], remplazos(vals[cont], client));} - // cont++ - // } - // // console.log('THE_URL=', url2) - // desbloqueaUsuario2(url2, step) //Llamamos al API para desbloquear el usuario. - // return - } - /** - * Si quieres enviar imagen. - */ - if (!response.delay && response.media) { - // console.log("++++++++++++++++++++++++++++ SEND MEDIA NO DELAY +++++++++++++++++++++++++++++++++++"); - sendMedia(client, from, response.media, response.trigger); - } - /** - * Si quieres enviar imagen con retraso. - */ - if (response.delay && response.media) { - setTimeout(() => { - // console.log("++++++++++++++++++++++++++++ SEND MEDIA AND DELAY +++++++++++++++++++++++++++++++++++"); - sendMedia(client, from, response.media, response.trigger); - }, response.delay) - } - /** - * Si quieres enviar mensaje con retraso. - */ - if (response.delay){ - // 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. - setTimeout(() => { + // #################################################################################################################### + // ############################## INICIAN FUNCIONES PARA MANEJO DE PARAMETROS ##################################### + // ############################## EN EL RESPONSE.JSON ##################################### + // #################################################################################################################### + + /* + * Si quieres ejecutar una función. + */ + if(response.hasOwnProperty('funcion')){ + console.log("############# Encontramos función, ejecutamos la función '" + response.funcion + "'") + laFuncion = response.funcion + "(client)" + eval(laFuncion) + } + if(response.hasOwnProperty('url') && response.hasOwnProperty('values')){ + // let theURL = response.url; + // let url0 = theURL + // let vals = response.values // Traemos los valores desde el response.json + // let j = theURL.split('j=')[1] // Traemos el JSON del URL. + // let j2 = JSON.parse(j) + // let cont = 0 + // const { params } = j2 // Traemos los parametros del JSON. + // console.log('PARAMS=', params, params['par1'], Object.keys(params).length) + // let url2 + // for (const par in params) { // Remplazamos los valores en lo parametros. + // console.log(`${par}: ${params[par]}, ${cont}: ${remplazos(vals[cont], client)}`); + // if(cont==0){url2=url0.replace(params[par], remplazos(vals[cont], client));} + // else {url2=url2.replace(params[par], remplazos(vals[cont], client));} + // cont++ + // } + // // console.log('THE_URL=', url2) + // desbloqueaUsuario2(url2, step) //Llamamos al API para desbloquear el usuario. + // return + } + /** + * Si quieres enviar imagen. + */ + if (!response.delay && response.media) { + // console.log("++++++++++++++++++++++++++++ SEND MEDIA NO DELAY +++++++++++++++++++++++++++++++++++"); + await sendMedia(client, from, response.media, response.trigger); + console.log("Enviamos imagen") + await delay(500) + } + /** + * Si quieres enviar imagen con retraso. + */ + if (response.delay && response.media) { + setTimeout(() => { + // console.log("++++++++++++++++++++++++++++ SEND MEDIA AND DELAY +++++++++++++++++++++++++++++++++++"); + sendMedia(client, from, response.media, response.trigger); + }, response.delay) + } + /** + * Si quieres enviar mensaje con retraso. + */ + if (response.delay){ + // 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. + setTimeout(() => { + 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); + }) + }, 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. 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); }) - }, response.delay) + await delay(500) + } + /** + * Si quieres enviar botones o listas + */ + if(response.hasOwnProperty('actions')){ + const { actions } = response; + // console.log("++++++++++++++++++++++++++++ SEND MESG BUTTON/LIST +++++++++++++++++++++++++++++++++++"); + 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 } - 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. + * Si quieres tener un mensaje por defecto + */ + if (process.env.DEFAULT_MESSAGE === 'true') { + const response = await responseMessages('DEFAULT') + // await sendMessage(client, from, response.replyMessage, response.trigger); // 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); }) - } - /** - * Si quieres enviar botones o listas - */ - if(response.hasOwnProperty('actions')){ - const { actions } = response; - // console.log("++++++++++++++++++++++++++++ SEND MESG BUTTON/LIST +++++++++++++++++++++++++++++++++++"); - 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 - } - /** - * Si quieres tener un mensaje por defecto - */ - if (process.env.DEFAULT_MESSAGE === 'true') { - const response = await responseMessages('DEFAULT') - // await sendMessage(client, from, response.replyMessage, response.trigger); // 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); - }) - - /** - * 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); - // } - // } - return - } - }); + /** + * 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); + } + } + return + } + }); +} /** * Este evento es necesario para el filtro de Dialogflow */ -const listenMessageFromBot = () => client.on('message_create', async botMsg => { - const { body } = botMsg; - const dialogflowFilterConfig = fs.readFileSync('./flow/dialogflow.json', 'utf8'); - const keywords = JSON.parse(dialogflowFilterConfig); +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); - for (i = 0; i < keywords.length; i++) { - key = keywords[i]; - for (var j = 0; j < key.phrases.length; j++) { - let filters = key.phrases[j]; - if (body.includes(filters)) { - dialogflowFilter = true; - //console.log(`El filtro de Dialogflow coincidió con el mensaje: ${filters}`); + for (i = 0; i < keywords.length; i++) { + key = keywords[i]; + for (var j = 0; j < key.phrases.length; j++) { + let filters = key.phrases[j]; + if (body.includes(filters)) { + dialogflowFilter = true; + //console.log(`El filtro de Dialogflow coincidió con el mensaje: ${filters}`); + } } } - } -}); + }); +} // #################################################################################################################### // ############################## 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)); \ No newline at end of file + inicializaBot() diff --git a/appBaileys.js b/appBaileys.js new file mode 100644 index 0000000..93883cd --- /dev/null +++ b/appBaileys.js @@ -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() \ No newline at end of file diff --git a/controllers/flows.js b/controllers/flows.js index 043fdc8..2e4b52d 100644 --- a/controllers/flows.js +++ b/controllers/flows.js @@ -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" diff --git a/controllers/handle.js b/controllers/handle.js index 84a8d40..4dfdfd0 100644 --- a/controllers/handle.js +++ b/controllers/handle.js @@ -6,12 +6,18 @@ const qr = require('qr-image') const MULTI_DEVICE = process.env.MULTI_DEVICE || 'true'; -const cleanNumber = (number) => { +const cleanNumber_wwebjs = (number) => { number = number.replace('@c.us', ''); number = `${number}@c.us`; return number } +const cleanNumber_baileys = (number) => { + number = number.replace('@s.whatsapp.net', ''); + number = `${number}@s.whatsapp.net`; + return number +} + const saveExternalFile = (url) => new Promise((resolve, reject) => { const ext = url.split('.').pop() const checkProtocol = url.split('/').includes('https:'); @@ -74,10 +80,21 @@ const createClient = () => { }); } -const isValidNumber = (rawNumber) => { +const isValidNumber_wwebjs = (rawNumber) => { const regexGroup = /\@g.us\b/gm; const exist = rawNumber.match(regexGroup); + console.log("IsValidWawebJS", rawNumber, exist, !exist) return !exist } -module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl, checkEnvFile, createClient, isValidNumber} +const isValidNumber_baileys = (rawNumber) => { + const regexGroup = /\@g.us\b/gm; + const exist = rawNumber.match(regexGroup); + // console.log("IsValidBaileys", rawNumber, exist, !exist) + return !exist +} + +const isValidNumber = eval(`isValidNumber_${provider}`) +const cleanNumber = eval(`cleanNumber_${provider}`) + +module.exports = {cleanNumber, saveExternalFile, generateImage, checkIsUrl, checkEnvFile, createClient, isValidNumber } diff --git a/controllers/save.js b/controllers/save.js index 5dd5cb1..adde994 100644 --- a/controllers/save.js +++ b/controllers/save.js @@ -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 } diff --git a/controllers/send_baileys.js b/controllers/send_baileys.js new file mode 100644 index 0000000..407fe3e --- /dev/null +++ b/controllers/send_baileys.js @@ -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 } diff --git a/controllers/send_wwebjs.js b/controllers/send_wwebjs.js new file mode 100644 index 0000000..e16fdd6 --- /dev/null +++ b/controllers/send_wwebjs.js @@ -0,0 +1,161 @@ +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 + * @returns + */ +const sendMedia = async (client, number, fileName, text) => { + console.log("SendMedia = ", number, fileName, text) + // const fileDownloaded = await generalDownload(imageUrl) + const file = `${DIR_MEDIA}/${fileName}`; + console.log("FILE="+file); + if (fs.existsSync(file)) { + console.log("ARCHIVO EXISTE"); + const mimeType = mime.lookup(file) + if (mimeType.includes('image')) return sendImage(client, number, file, text) + if (mimeType.includes('video')) return sendVideo(client, number, file, text) + if (mimeType.includes('audio')) return sendAudio(client, number, file, text) + return sendFile(client, number, file) + } +} + +/** + * Enviar imagen + * @param {*} number + * @param {*} imageUrl + * @param {*} text + * @returns + */ +const sendImage = async (client, number, fileName, caption) => { + const file = `${DIR_MEDIA}/${fileName}`; + console.log("FILE="+file); + if (fs.existsSync(file)) { + console.log("ARCHIVO EXISTE"); + const media = MessageMedia.fromFilePath(file); + } + const base64 = fs.readFileSync(fileName, { encoding: 'base64' }) + const mimeType = mime.lookup(fileName) + const media = new MessageMedia(mimeType, base64) + client.sendMessage(number, media, { caption }) +} + +/** + * Enviamos archivos como notas de voz + * @param {*} number + * @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" + setTimeout(async () => { + number = cleanNumber(number) + const message = text + client.sendMessage(number, message); + // console.log(number, message, regla) + await readChat(number, message, trigger, regla) //MOD by CHV - Agregamos el parametro "regla" + console.log(`⚡⚡⚡ Enviando mensajes....`); + // console.log("********************* SEND MESSAGE **************************************"); + },DELAY_TIME) +} + +/** + * Enviamos un mensaje con buttons a nuestro cliente + * @param {*} number + */ +const sendMessageButton = 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 ***********************************"); +} + +/** + * Enviamos listas (con el formato de response.json) + * @param {*} number + */ +const sendMessageList = async (client, number = null, text = null, actionList) => { + // console.log("*************** wwebjs send") + setTimeout(async () => { + // console.log("********************** client **************************") + // console.log(client) + number = cleanNumber(number) + const { body = null, buttonText = null, sections = [], title = null, footer = null } = actionList; + let aList = new List( remplazos(body, client),remplazos(buttonText, client),[...sections],remplazos(title, client),remplazos(footer, client)); + client.sendMessage(number, aList); + await readChat(number, message, 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, sendImage, lastTrigger, sendMessageButton, sendMessageList, readChat, sendMediaVoiceNote } diff --git a/controllers/web.js b/controllers/web.js index 5b7bad9..32a220f 100644 --- a/controllers/web.js +++ b/controllers/web.js @@ -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') diff --git a/flow/response.json b/flow/response.json index f171a64..58b7559 100644 --- a/flow/response.json +++ b/flow/response.json @@ -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"} ] } ], diff --git a/implementaciones/extraFuncs.js b/implementaciones/extraFuncs.js new file mode 100644 index 0000000..b675899 --- /dev/null +++ b/implementaciones/extraFuncs.js @@ -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 } \ No newline at end of file diff --git a/implementaciones/sheets.js b/implementaciones/sheets.js index 2eea89d..895c1b0 100644 --- a/implementaciones/sheets.js +++ b/implementaciones/sheets.js @@ -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,34 +13,27 @@ async function ingresarDatos(numero, mensaje){ let rows = [{ Numero: elNum.trim(), Mensaje: mensaje, + Sentido: sentido, Fecha: Fecha, Hora: Hora }]; - await doc.useServiceAccountAuth({ - client_email: CREDENTIALS.client_email, - private_key: CREDENTIALS.private_key - }); - await doc.loadInfo(); - let sheet = doc.sheetsByTitle['Mensajes']; - // console.log("SHEET=", sheet) - for (let index = 0; index < rows.length; index++) { - const row = rows[index]; - await sheet.addRow(row); - console.log("Datos guardados (sheets.js)") + try{ + await doc.useServiceAccountAuth({ + client_email: CREDENTIALS.client_email, + private_key: CREDENTIALS.private_key + }); + await doc.loadInfo(); + let sheet = doc.sheetsByTitle['Mensajes']; + // console.log("SHEET=", sheet) + for (let index = 0; index < rows.length; index++) { + const row = rows[index]; + await sheet.addRow(row); + console.log(`Datos guardados - ${sentido} (sheets.js)`) + } } - // 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('-----------------------------------'); + catch{ + console.log("Error Sheets") + } } async function leerDatos(telsim){ diff --git a/initBailey.js b/initBailey.js new file mode 100644 index 0000000..ae4a9b1 --- /dev/null +++ b/initBailey.js @@ -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 } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8d65e84..f091798 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,10 @@ "version": "1.0.1", "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", @@ -38,10 +40,103 @@ "node": "16.x" } }, + "node_modules/@adiwajshing/baileys": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@adiwajshing/baileys/-/baileys-4.4.0.tgz", + "integrity": "sha512-5gEnkJBgraLL0USzndxto8ofYhWyMFZVkpZ4rD1nPqrjBjGMt+k+YDpllpFpOfA0yxWZb6nPrr04ikQv++dz2Q==", + "dependencies": { + "@hapi/boom": "^9.1.3", + "axios": "^0.24.0", + "futoin-hkdf": "^1.5.0", + "libsignal": "git+https://github.com/adiwajshing/libsignal-node.git", + "music-metadata": "^7.12.3", + "node-cache": "^5.1.2", + "pino": "^7.0.0", + "protobufjs": "^6.11.3", + "ws": "^8.0.0" + }, + "peerDependencies": { + "@adiwajshing/keyed-db": "^0.2.4", + "jimp": "^0.16.1", + "link-preview-js": "^2.1.13", + "qrcode-terminal": "^0.12.0", + "sharp": "^0.30.5" + }, + "peerDependenciesMeta": { + "@adiwajshing/keyed-db": { + "optional": true + }, + "jimp": { + "optional": true + }, + "link-preview-js": { + "optional": true + }, + "qrcode-terminal": { + "optional": true + }, + "sharp": { + "optional": true + } + } + }, + "node_modules/@adiwajshing/baileys/node_modules/axios": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz", + "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==", + "dependencies": { + "follow-redirects": "^1.14.4" + } + }, + "node_modules/@adiwajshing/baileys/node_modules/protobufjs": { + "version": "6.11.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.11.3.tgz", + "integrity": "sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==", + "hasInstallScript": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.1", + "@types/node": ">=13.7.0", + "long": "^4.0.0" + }, + "bin": { + "pbjs": "bin/pbjs", + "pbts": "bin/pbts" + } + }, + "node_modules/@adiwajshing/baileys/node_modules/ws": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz", + "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/@babel/parser": { - "version": "7.20.13", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.13.tgz", - "integrity": "sha512-gFDLKMfpiXCsjt4za2JA9oTMn70CeseCehb11kRZgvd7+F67Hih3OHOK24cRrWECJ/ljfPGac6ygXAs/C8kIvw==", + "version": "7.20.15", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.20.15.tgz", + "integrity": "sha512-DI4a1oZuf8wC+oAJA9RW6ga3Zbe8RZFt7kD9i4qAspz3I/yHet1VvC3DiSy/fsUvv5pvJuNPh0LPOdCcqinDPg==", "bin": { "parser": "bin/babel-parser.js" }, @@ -49,6 +144,19 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/runtime": { + "version": "7.20.13", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.13.tgz", + "integrity": "sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==", + "optional": true, + "peer": true, + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@fast-csv/format": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/@fast-csv/format/-/format-4.3.5.tgz", @@ -77,9 +185,9 @@ } }, "node_modules/@google-cloud/dialogflow": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@google-cloud/dialogflow/-/dialogflow-5.4.0.tgz", - "integrity": "sha512-2MBt4sOSgLKPubQEYW0YH9OcBx89SUUEUFfBA+vK1NH8tkjBIBvVqSXLPlXLCLZ2jRhTHSkncQO5MzAhrS4rhA==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/@google-cloud/dialogflow/-/dialogflow-5.5.0.tgz", + "integrity": "sha512-Ku+QmtzTF6hMyONWWipxZvSCSRWkFlOflw681sLCZqgZA3ce7QTesp/pPbKlMDZ3uRf1csCEhJssSbW4ycR18g==", "dependencies": { "google-gax": "^3.5.2" }, @@ -88,9 +196,9 @@ } }, "node_modules/@grpc/grpc-js": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.7.3.tgz", - "integrity": "sha512-H9l79u4kJ2PVSxUNA08HMYAnUBLj9v6KjYQ7SQ71hOZcEXhShE/y5iQCesP8+6/Ik/7i2O0a10bPquIcYfufog==", + "version": "1.8.8", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.8.8.tgz", + "integrity": "sha512-4gfDqMLXTrorvYTKA1jL22zLvVwiHJ73t6Re1OHwdCFRjdGTDOVtSJuaWhtHaivyeDGg0LeCkmU77MTKoV3wPA==", "dependencies": { "@grpc/proto-loader": "^0.7.0", "@types/node": ">=12.12.47" @@ -117,6 +225,594 @@ "node": ">=6" } }, + "node_modules/@hapi/boom": { + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/@hapi/boom/-/boom-9.1.4.tgz", + "integrity": "sha512-Ls1oH8jaN1vNsqcaHVYJrKmgMcKsC1wcp8bujvXrHaAqD2iDYq3HoOwsxwo09Cuda5R5nC0o0IxlrlTuvPuzSw==", + "dependencies": { + "@hapi/hoek": "9.x.x" + } + }, + "node_modules/@hapi/hoek": { + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.3.0.tgz", + "integrity": "sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==" + }, + "node_modules/@jimp/bmp": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/bmp/-/bmp-0.16.13.tgz", + "integrity": "sha512-9edAxu7N2FX7vzkdl5Jo1BbACfycUtBQX+XBMcHA2bk62P8R0otgkHg798frgAk/WxQIzwxqOH6wMiCwrlAzdQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "bmp-js": "^0.1.0" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/core": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/core/-/core-0.16.13.tgz", + "integrity": "sha512-qXpA1tzTnlkTku9yqtuRtS/wVntvE6f3m3GNxdTdtmc+O+Wcg9Xo2ABPMh7Nc0AHbMKzwvwgB2JnjZmlmJEObg==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "any-base": "^1.1.0", + "buffer": "^5.2.0", + "exif-parser": "^0.1.12", + "file-type": "^16.5.4", + "load-bmfont": "^1.3.1", + "mkdirp": "^0.5.1", + "phin": "^2.9.1", + "pixelmatch": "^4.0.2", + "tinycolor2": "^1.4.1" + } + }, + "node_modules/@jimp/core/node_modules/file-type": { + "version": "16.5.4", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", + "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", + "optional": true, + "peer": true, + "dependencies": { + "readable-web-to-node-stream": "^3.0.0", + "strtok3": "^6.2.4", + "token-types": "^4.1.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/file-type?sponsor=1" + } + }, + "node_modules/@jimp/core/node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "optional": true, + "peer": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/@jimp/core/node_modules/peek-readable": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", + "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==", + "optional": true, + "peer": true, + "engines": { + "node": ">=8" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/@jimp/core/node_modules/strtok3": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz", + "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==", + "optional": true, + "peer": true, + "dependencies": { + "@tokenizer/token": "^0.3.0", + "peek-readable": "^4.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/@jimp/core/node_modules/token-types": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz", + "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==", + "optional": true, + "peer": true, + "dependencies": { + "@tokenizer/token": "^0.3.0", + "ieee754": "^1.2.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/@jimp/custom": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/custom/-/custom-0.16.13.tgz", + "integrity": "sha512-LTATglVUPGkPf15zX1wTMlZ0+AU7cGEGF6ekVF1crA8eHUWsGjrYTB+Ht4E3HTrCok8weQG+K01rJndCp/l4XA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/core": "^0.16.13" + } + }, + "node_modules/@jimp/gif": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/gif/-/gif-0.16.13.tgz", + "integrity": "sha512-yFAMZGv3o+YcjXilMWWwS/bv1iSqykFahFMSO169uVMtfQVfa90kt4/kDwrXNR6Q9i6VHpFiGZMlF2UnHClBvg==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "gifwrap": "^0.9.2", + "omggif": "^1.0.9" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/jpeg": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/jpeg/-/jpeg-0.16.13.tgz", + "integrity": "sha512-BJHlDxzTlCqP2ThqP8J0eDrbBfod7npWCbJAcfkKqdQuFk0zBPaZ6KKaQKyKxmWJ87Z6ohANZoMKEbtvrwz1AA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "jpeg-js": "^0.4.2" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-blit": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-blit/-/plugin-blit-0.16.13.tgz", + "integrity": "sha512-8Z1k96ZFxlhK2bgrY1JNWNwvaBeI/bciLM0yDOni2+aZwfIIiC7Y6PeWHTAvjHNjphz+XCt01WQmOYWCn0ML6g==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-blur": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-blur/-/plugin-blur-0.16.13.tgz", + "integrity": "sha512-PvLrfa8vkej3qinlebyhLpksJgCF5aiysDMSVhOZqwH5nQLLtDE9WYbnsofGw4r0VVpyw3H/ANCIzYTyCtP9Cg==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-circle": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-circle/-/plugin-circle-0.16.13.tgz", + "integrity": "sha512-RNave7EFgZrb5V5EpdvJGAEHMnDAJuwv05hKscNfIYxf0kR3KhViBTDy+MoTnMlIvaKFULfwIgaZWzyhuINMzA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-color": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-color/-/plugin-color-0.16.13.tgz", + "integrity": "sha512-xW+9BtEvoIkkH/Wde9ql4nAFbYLkVINhpgAE7VcBUsuuB34WUbcBl/taOuUYQrPEFQJ4jfXiAJZ2H/rvKjCVnQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "tinycolor2": "^1.4.1" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-contain": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-contain/-/plugin-contain-0.16.13.tgz", + "integrity": "sha512-QayTXw4tXMwU6q6acNTQrTTFTXpNRBe+MgTGMDU0lk+23PjlFCO/9sacflelG8lsp7vNHhAxFeHptDMAksEYzg==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-blit": ">=0.3.5", + "@jimp/plugin-resize": ">=0.3.5", + "@jimp/plugin-scale": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-cover": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-cover/-/plugin-cover-0.16.13.tgz", + "integrity": "sha512-BSsP71GTNaqWRcvkbWuIVH+zK7b3TSNebbhDkFK0fVaUTzHuKMS/mgY4hDZIEVt7Rf5FjadAYtsujHN9w0iSYA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-crop": ">=0.3.5", + "@jimp/plugin-resize": ">=0.3.5", + "@jimp/plugin-scale": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-crop": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-crop/-/plugin-crop-0.16.13.tgz", + "integrity": "sha512-WEl2tPVYwzYL8OKme6Go2xqiWgKsgxlMwyHabdAU4tXaRwOCnOI7v4021gCcBb9zn/oWwguHuKHmK30Fw2Z/PA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-displace": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-displace/-/plugin-displace-0.16.13.tgz", + "integrity": "sha512-qt9WKq8vWrcjySa9DyQ0x/RBMHQeiVjdVSY1SJsMjssPUf0pS74qorcuAkGi89biN3YoGUgPkpqECnAWnYwgGA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-dither": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-dither/-/plugin-dither-0.16.13.tgz", + "integrity": "sha512-5/N3yJggbWQTlGZHQYJPmQXEwR52qaXjEzkp1yRBbtdaekXE3BG/suo0fqeoV/csf8ooI78sJzYmIrxNoWVtgQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-fisheye": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-fisheye/-/plugin-fisheye-0.16.13.tgz", + "integrity": "sha512-2rZmTdFbT/cF9lEZIkXCYO0TsT114Q27AX5IAo0Sju6jVQbvIk1dFUTnwLDadTo8wkJlFzGqMQ24Cs8cHWOliA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-flip": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-flip/-/plugin-flip-0.16.13.tgz", + "integrity": "sha512-EmcgAA74FTc5u7Z+hUO/sRjWwfPPLuOQP5O64x5g4j0T12Bd29IgsYZxoutZo/rb3579+JNa/3wsSEmyVv1EpA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-rotate": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-gaussian": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-gaussian/-/plugin-gaussian-0.16.13.tgz", + "integrity": "sha512-A1XKfGQD0iDdIiKqFYi8nZMv4dDVYdxbrmgR7y/CzUHhSYdcmoljLIIsZZM3Iks/Wa353W3vtvkWLuDbQbch1w==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-invert": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-invert/-/plugin-invert-0.16.13.tgz", + "integrity": "sha512-xFMrIn7czEZbdbMzZWuaZFnlLGJDVJ82y5vlsKsXRTG2kcxRsMPXvZRWHV57nSs1YFsNqXSbrC8B98n0E32njQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-mask": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-mask/-/plugin-mask-0.16.13.tgz", + "integrity": "sha512-wLRYKVBXql2GAYgt6FkTnCfE+q5NomM7Dlh0oIPGAoMBWDyTx0eYutRK6PlUrRK2yMHuroAJCglICTbxqGzowQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-normalize": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-normalize/-/plugin-normalize-0.16.13.tgz", + "integrity": "sha512-3tfad0n9soRna4IfW9NzQdQ2Z3ijkmo21DREHbE6CGcMIxOSvfRdSvf1qQPApxjTSo8LTU4MCi/fidx/NZ0GqQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-print": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-print/-/plugin-print-0.16.13.tgz", + "integrity": "sha512-0m6i3p01PGRkGAK9r53hDYrkyMq+tlhLOIbsSTmZyh6HLshUKlTB7eXskF5OpVd5ZUHoltlNc6R+ggvKIzxRFw==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "load-bmfont": "^1.4.0" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-blit": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-resize": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-resize/-/plugin-resize-0.16.13.tgz", + "integrity": "sha512-qoqtN8LDknm3fJm9nuPygJv30O3vGhSBD2TxrsCnhtOsxKAqVPJtFVdGd/qVuZ8nqQANQmTlfqTiK9mVWQ7MiQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-rotate": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-rotate/-/plugin-rotate-0.16.13.tgz", + "integrity": "sha512-Ev+Jjmj1nHYw897z9C3R9dYsPv7S2/nxdgfFb/h8hOwK0Ovd1k/+yYS46A0uj/JCKK0pQk8wOslYBkPwdnLorw==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-blit": ">=0.3.5", + "@jimp/plugin-crop": ">=0.3.5", + "@jimp/plugin-resize": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-scale": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-scale/-/plugin-scale-0.16.13.tgz", + "integrity": "sha512-05POQaEJVucjTiSGMoH68ZiELc7QqpIpuQlZ2JBbhCV+WCbPFUBcGSmE7w4Jd0E2GvCho/NoMODLwgcVGQA97A==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-resize": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-shadow": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-shadow/-/plugin-shadow-0.16.13.tgz", + "integrity": "sha512-nmu5VSZ9hsB1JchTKhnnCY+paRBnwzSyK5fhkhtQHHoFD5ArBQ/5wU8y6tCr7k/GQhhGq1OrixsECeMjPoc8Zw==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-blur": ">=0.3.5", + "@jimp/plugin-resize": ">=0.3.5" + } + }, + "node_modules/@jimp/plugin-threshold": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugin-threshold/-/plugin-threshold-0.16.13.tgz", + "integrity": "sha512-+3zArBH0OE3Rhjm4HyAokMsZlIq5gpQec33CncyoSwxtRBM2WAhUVmCUKuBo+Lr/2/4ISoY4BWpHKhMLDix6cA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5", + "@jimp/plugin-color": ">=0.8.0", + "@jimp/plugin-resize": ">=0.8.0" + } + }, + "node_modules/@jimp/plugins": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/plugins/-/plugins-0.16.13.tgz", + "integrity": "sha512-CJLdqODEhEVs4MgWCxpWL5l95sCBlkuSLz65cxEm56X5akIsn4LOlwnKoSEZioYcZUBvHhCheH67AyPTudfnQQ==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/plugin-blit": "^0.16.13", + "@jimp/plugin-blur": "^0.16.13", + "@jimp/plugin-circle": "^0.16.13", + "@jimp/plugin-color": "^0.16.13", + "@jimp/plugin-contain": "^0.16.13", + "@jimp/plugin-cover": "^0.16.13", + "@jimp/plugin-crop": "^0.16.13", + "@jimp/plugin-displace": "^0.16.13", + "@jimp/plugin-dither": "^0.16.13", + "@jimp/plugin-fisheye": "^0.16.13", + "@jimp/plugin-flip": "^0.16.13", + "@jimp/plugin-gaussian": "^0.16.13", + "@jimp/plugin-invert": "^0.16.13", + "@jimp/plugin-mask": "^0.16.13", + "@jimp/plugin-normalize": "^0.16.13", + "@jimp/plugin-print": "^0.16.13", + "@jimp/plugin-resize": "^0.16.13", + "@jimp/plugin-rotate": "^0.16.13", + "@jimp/plugin-scale": "^0.16.13", + "@jimp/plugin-shadow": "^0.16.13", + "@jimp/plugin-threshold": "^0.16.13", + "timm": "^1.6.1" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/png": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/png/-/png-0.16.13.tgz", + "integrity": "sha512-8cGqINvbWJf1G0Her9zbq9I80roEX0A+U45xFby3tDWfzn+Zz8XKDF1Nv9VUwVx0N3zpcG1RPs9hfheG4Cq2kg==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/utils": "^0.16.13", + "pngjs": "^3.3.3" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/tiff": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/tiff/-/tiff-0.16.13.tgz", + "integrity": "sha512-oJY8d9u95SwW00VPHuCNxPap6Q1+E/xM5QThb9Hu+P6EGuu6lIeLaNBMmFZyblwFbwrH+WBOZlvIzDhi4Dm/6Q==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "utif": "^2.0.1" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/types": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/types/-/types-0.16.13.tgz", + "integrity": "sha512-mC0yVNUobFDjoYLg4hoUwzMKgNlxynzwt3cDXzumGvRJ7Kb8qQGOWJQjQFo5OxmGExqzPphkirdbBF88RVLBCg==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/bmp": "^0.16.13", + "@jimp/gif": "^0.16.13", + "@jimp/jpeg": "^0.16.13", + "@jimp/png": "^0.16.13", + "@jimp/tiff": "^0.16.13", + "timm": "^1.6.1" + }, + "peerDependencies": { + "@jimp/custom": ">=0.3.5" + } + }, + "node_modules/@jimp/utils": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/@jimp/utils/-/utils-0.16.13.tgz", + "integrity": "sha512-VyCpkZzFTHXtKgVO35iKN0sYR10psGpV6SkcSeV4oF7eSYlR8Bl6aQLCzVeFjvESF7mxTmIiI3/XrMobVrtxDA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "regenerator-runtime": "^0.13.3" + } + }, + "node_modules/@jsdoc/salty": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.3.tgz", + "integrity": "sha512-bbtCxCkxcnWhi50I+4Lj6mdz9w3pOXOgEQrID8TCZ/DF51fW7M9GCQW2y45SpBDdHd1Eirm1X/Cf6CkAAe8HPg==", + "dependencies": { + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=v12.0.0" + } + }, "node_modules/@opencensus/core": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/@opencensus/core/-/core-0.0.9.tgz", @@ -516,6 +1212,15 @@ "@types/node": "*" } }, + "node_modules/@types/glob": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.0.1.tgz", + "integrity": "sha512-8bVUjXZvJacUFkJXHdyZ9iH1Eaj5V7I8c4NdH5sQJsdXkqT4CA5Dhb4yb4VE/3asyx4L9ayZr1NIhTsWHczmMw==", + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "node_modules/@types/linkify-it": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", @@ -540,11 +1245,25 @@ "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==" }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" + }, "node_modules/@types/node": { "version": "14.18.36", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.36.tgz", "integrity": "sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ==" }, + "node_modules/@types/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ==", + "dependencies": { + "@types/glob": "*", + "@types/node": "*" + } + }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -645,6 +1364,21 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/amp": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/amp/-/amp-0.3.1.tgz", @@ -691,6 +1425,13 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/any-base": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/any-base/-/any-base-1.1.0.tgz", + "integrity": "sha512-uMgjozySS8adZZYePpaWs8cxB9/kdzmpX6SgJZ+wbz1K5eYk5QMYDVJaZKhxyIHUdnnJkfR7SVgStgH7LkGUyg==", + "optional": true, + "peer": true + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -786,6 +1527,22 @@ "node": ">=8" } }, + "node_modules/asn1": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", + "dependencies": { + "safer-buffer": "~2.1.0" + } + }, + "node_modules/assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/ast-types": { "version": "0.13.4", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", @@ -836,6 +1593,27 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", + "engines": { + "node": "*" + } + }, + "node_modules/aws4": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz", + "integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==" + }, "node_modules/axios": { "version": "0.27.2", "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", @@ -877,6 +1655,14 @@ "node": "^4.5.0 || >= 5.9" } }, + "node_modules/bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", + "dependencies": { + "tweetnacl": "^0.14.3" + } + }, "node_modules/big-integer": { "version": "1.6.51", "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", @@ -941,6 +1727,13 @@ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" }, + "node_modules/bmp-js": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz", + "integrity": "sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==", + "optional": true, + "peer": true + }, "node_modules/bodec": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/bodec/-/bodec-0.1.0.tgz", @@ -1022,6 +1815,14 @@ "node": "*" } }, + "node_modules/buffer-equal": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal/-/buffer-equal-0.0.1.tgz", + "integrity": "sha512-RgSV6InVQ9ODPdLWJ5UAqBqJBOg370Nz6ZQtRzpt6nUjc8v0St97uJ4PYC6NztqIScrAXafKM3mZPMygSe1ggA==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/buffer-equal-constant-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", @@ -1069,6 +1870,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" + }, "node_modules/catharsis": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", @@ -1176,6 +1982,14 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/codepage": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", @@ -1200,6 +2014,66 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/combine-image": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/combine-image/-/combine-image-1.0.3.tgz", + "integrity": "sha512-qE7G/RXTc21sZuypwI2HPHgSf9pxWd2kHv8P7j1Qu6BIfLmNYW7LACixJ++dCCpIbZuCcurTeKU2nSaLTAloSg==", + "dependencies": { + "is-plain-obj": "^1.1.0", + "jimp": "0.2.27" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/combine-image/node_modules/bignumber.js": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.4.0.tgz", + "integrity": "sha512-uw4ra6Cv483Op/ebM0GBKKfxZlSmn6NgFRby5L3yGTlunLj53KQgndDlqy2WVFOwgvurocApYkSud0aO+mvrpQ==", + "engines": { + "node": "*" + } + }, + "node_modules/combine-image/node_modules/bmp-js": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.0.1.tgz", + "integrity": "sha512-OS74Rlt0Aynu2mTPmY9RZOUOXlqWecFIILFXr70vv16/xCZnFxvri9IKkF1IGxQ8r9dOE62qGNpKxXx8Lko8bg==" + }, + "node_modules/combine-image/node_modules/file-type": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", + "integrity": "sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/combine-image/node_modules/jimp": { + "version": "0.2.27", + "resolved": "https://registry.npmjs.org/jimp/-/jimp-0.2.27.tgz", + "integrity": "sha512-KP08kEe5pDY+AFg00vuqKP0zgUmeQXJXpzQ+w9+0pQA27GCF9RoWzOpf3AONHgf5h8raMrXaF18y4ug9Rw2xEw==", + "dependencies": { + "bignumber.js": "^2.1.0", + "bmp-js": "0.0.1", + "es6-promise": "^3.0.2", + "exif-parser": "^0.1.9", + "file-type": "^3.1.0", + "jpeg-js": "^0.2.0", + "load-bmfont": "^1.2.3", + "mime": "^1.3.4", + "pixelmatch": "^4.0.0", + "pngjs": "^3.0.0", + "read-chunk": "^1.0.1", + "request": "^2.65.0", + "stream-to-buffer": "^0.1.0", + "tinycolor2": "^1.1.2", + "url-regex": "^3.0.0" + } + }, + "node_modules/combine-image/node_modules/jpeg-js": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.2.0.tgz", + "integrity": "sha512-Ni9PffhJtYtdD7VwxH6V2MnievekGfUefosGCHadog0/jAevRu6HPjYeMHbUemn0IPE8d4wGa8UsOGsX+iKy2g==" + }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -1357,6 +2231,22 @@ "integrity": "sha512-yi1x3EAWKjQTreYWeSd98431AV+IEE0qoDyOoaHJ7KJ21gv6HtBXHVLX74opVSGqcR8/AbjJBHAHpcOy2bj5Gg==", "dev": true }, + "node_modules/curve25519-js": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/curve25519-js/-/curve25519-js-0.0.4.tgz", + "integrity": "sha512-axn2UMEnkhyDUPWOwVKBMVIzSQy2ejH2xRGy1wq81dqRwApXfIzfbE3hIX0ZRFBIihf/KDqK158DLwESu4AK1w==" + }, + "node_modules/dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", + "dependencies": { + "assert-plus": "^1.0.0" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/data-uri-to-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", @@ -1429,6 +2319,11 @@ "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", "integrity": "sha512-0cuGS8+jhR67Fy7qG3i3Pc7Aw494sb9yG9QgpG97SFVWwolgYjlhJg7n+UaHxOQT30d1TYu/EYe9k01ivLErIg==" }, + "node_modules/dom-walk": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz", + "integrity": "sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==" + }, "node_modules/dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -1483,6 +2378,15 @@ "stream-shift": "^1.0.0" } }, + "node_modules/ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", + "dependencies": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -1527,9 +2431,9 @@ } }, "node_modules/engine.io": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.2.1.tgz", - "integrity": "sha512-ECceEFcAaNRybd3lsGQKas3ZlMVjN3cyWwMP25D2i0zWfyiytVbTpRPa34qrr+FHddtpBVOmq4H/DCv1O0lZRA==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.4.0.tgz", + "integrity": "sha512-OgxY1c/RuCSeO/rTr8DIFXx76IzUUft86R7/P7MMbbkuzeqJoTNw2lmeD91IyGz41QYleIIjWeMJGgug043sfQ==", "dependencies": { "@types/cookie": "^0.4.1", "@types/cors": "^2.8.12", @@ -1540,7 +2444,7 @@ "cors": "~2.8.5", "debug": "~4.3.1", "engine.io-parser": "~5.0.3", - "ws": "~8.2.3" + "ws": "~8.11.0" }, "engines": { "node": ">=10.0.0" @@ -1584,9 +2488,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/engine.io/node_modules/ws": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", - "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==", + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", "engines": { "node": ">=10.0.0" }, @@ -1623,6 +2527,11 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/es6-promise": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", + "integrity": "sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==" + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -1770,6 +2679,11 @@ "node": ">=8.3.0" } }, + "node_modules/exif-parser": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/exif-parser/-/exif-parser-0.1.12.tgz", + "integrity": "sha512-c2bQfLNbMzLPmzQuOr8fy0csy84WmwnER81W88DzTp9CYNPJ6yzOj2EZAh9pywYpqHnshVLHQJ8WzldAyfY+Iw==" + }, "node_modules/express": { "version": "4.18.2", "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", @@ -1856,6 +2770,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", + "engines": [ + "node >=0.6.0" + ] + }, "node_modules/fast-csv": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/fast-csv/-/fast-csv-4.3.6.tgz", @@ -1868,17 +2790,35 @@ "node": ">=10.0.0" } }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, "node_modules/fast-json-patch": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/fast-json-patch/-/fast-json-patch-3.1.1.tgz", "integrity": "sha512-vf6IHUX2SBcA+5/+4883dsIjpBTqmfBjmYiWK1savxQmFk4JfBMLa7ynTYOs1Rolp/T1betJxHiGD3g1Mn8lUQ==", "dev": true }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" + }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==" }, + "node_modules/fast-redact": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.1.2.tgz", + "integrity": "sha512-+0em+Iya9fKGfEQGcd62Yv6onjBmmhV1uh86XVfOU8VwAe6kaFdQCWI9s0/Nnugx5Vd9tdbZ7e6gE2tR9dzXdw==", + "engines": { + "node": ">=6" + } + }, "node_modules/fast-text-encoding": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz", @@ -1995,6 +2935,14 @@ } } }, + "node_modules/forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", + "engines": { + "node": "*" + } + }, "node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", @@ -2148,6 +3096,14 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "node_modules/futoin-hkdf": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/futoin-hkdf/-/futoin-hkdf-1.5.1.tgz", + "integrity": "sha512-g5d0Qp7ks55hYmYmfqn4Nz18XH49lcCR+vvIvHT92xXnsJaGZmY1EtWQWilJ6BQp57heCIXM/rRo+AFep8hGgg==", + "engines": { + "node": ">=8" + } + }, "node_modules/gaxios": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-5.0.2.tgz", @@ -2249,6 +3205,25 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", + "dependencies": { + "assert-plus": "^1.0.0" + } + }, + "node_modules/gifwrap": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/gifwrap/-/gifwrap-0.9.4.tgz", + "integrity": "sha512-MDMwbhASQuVeD4JKd1fKgNgCRL3fGqMM4WaqpNhWO0JiMOAjbQdumbs4BbBZEy9/M00EHEjKN3HieVhCUlwjeQ==", + "optional": true, + "peer": true, + "dependencies": { + "image-q": "^4.0.0", + "omggif": "^1.0.10" + } + }, "node_modules/git-node-fs": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/git-node-fs/-/git-node-fs-1.0.0.tgz", @@ -2292,6 +3267,15 @@ "node": ">= 6" } }, + "node_modules/global": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", + "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "dependencies": { + "min-document": "^2.19.0", + "process": "^0.11.10" + } + }, "node_modules/google-auth-library": { "version": "8.7.0", "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-8.7.0.tgz", @@ -2312,13 +3296,14 @@ } }, "node_modules/google-gax": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-3.5.2.tgz", - "integrity": "sha512-AyP53w0gHcWlzxm+jSgqCR3Xu4Ld7EpSjhtNBnNhzwwWaIUyphH9kBGNIEH+i4UGkTUXOY29K/Re8EiAvkBRGw==", + "version": "3.5.7", + "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-3.5.7.tgz", + "integrity": "sha512-taDGwR9Ry5y6NkcPYKe0B3wr7rCwaImZZIuWajUcFe9Y8L71eBtaq0+ZJ62JByzr/2cJkd9EN1rr52rD6V/UDA==", "dependencies": { - "@grpc/grpc-js": "~1.7.0", + "@grpc/grpc-js": "~1.8.0", "@grpc/proto-loader": "^0.7.0", "@types/long": "^4.0.0", + "@types/rimraf": "^3.0.2", "abort-controller": "^3.0.0", "duplexify": "^4.0.0", "fast-text-encoding": "^1.0.3", @@ -2327,8 +3312,8 @@ "node-fetch": "^2.6.1", "object-hash": "^3.0.0", "proto3-json-serializer": "^1.0.0", - "protobufjs": "7.1.2", - "protobufjs-cli": "1.0.2", + "protobufjs": "7.2.2", + "protobufjs-cli": "1.1.1", "retry-request": "^5.0.0" }, "bin": { @@ -2501,6 +3486,27 @@ "node": ">=12.0.0" } }, + "node_modules/har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", + "engines": { + "node": ">=4" + } + }, + "node_modules/har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "deprecated": "this library is no longer supported", + "dependencies": { + "ajv": "^6.12.3", + "har-schema": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -2583,6 +3589,20 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", + "dependencies": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.3.7" + } + }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -2646,6 +3666,23 @@ } ] }, + "node_modules/image-q": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/image-q/-/image-q-4.0.0.tgz", + "integrity": "sha512-PfJGVgIfKQJuq3s0tTDOKtztksibuUEbJQIYT3by6wctQo+Rdlh7ef4evJ5NCdxY4CfMbvFkocEwbl4BF8RlJw==", + "optional": true, + "peer": true, + "dependencies": { + "@types/node": "16.9.1" + } + }, + "node_modules/image-q/node_modules/@types/node": { + "version": "16.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", + "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==", + "optional": true, + "peer": true + }, "node_modules/immediate": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", @@ -2677,6 +3714,14 @@ "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==", "dev": true }, + "node_modules/ip-regex": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-1.0.3.tgz", + "integrity": "sha512-HjpCHTuxbR/6jWJroc/VN+npo5j0T4Vv2TAI5qdEHQx7hsL767MeccGFSsLtF694EiZKTSEqgoeU6DtGFCcuqQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -2726,6 +3771,11 @@ "node": ">=8" } }, + "node_modules/is-function": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.2.tgz", + "integrity": "sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==" + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -2747,6 +3797,14 @@ "node": ">=0.12.0" } }, + "node_modules/is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-stream": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", @@ -2763,6 +3821,11 @@ "resolved": "https://registry.npmjs.org/is-stream-ended/-/is-stream-ended-0.1.4.tgz", "integrity": "sha512-xj0XPvmr7bQFTvirqnFr50o0hQIh6ZItDqloxt5aJrR4NQsYeSsyFQERYGCAzfindAcnKjINnwEEgLx4IqVzQw==" }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -2773,6 +3836,32 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, + "node_modules/isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" + }, + "node_modules/jimp": { + "version": "0.16.13", + "resolved": "https://registry.npmjs.org/jimp/-/jimp-0.16.13.tgz", + "integrity": "sha512-Bxz8q7V4rnCky9A0ktTNGA9SkNFVWRHodddI/DaAWZJzF7sVUlFYKQ60y9JGqrKpi48ECA/TnfMzzc5C70VByA==", + "optional": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.7.2", + "@jimp/custom": "^0.16.13", + "@jimp/plugins": "^0.16.13", + "@jimp/types": "^0.16.13", + "regenerator-runtime": "^0.13.3" + } + }, + "node_modules/jpeg-js": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.4.tgz", + "integrity": "sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg==", + "optional": true, + "peer": true + }, "node_modules/js-git": { "version": "0.7.8", "resolved": "https://registry.npmjs.org/js-git/-/js-git-0.7.8.tgz", @@ -2799,12 +3888,18 @@ "xmlcreate": "^2.0.4" } }, + "node_modules/jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" + }, "node_modules/jsdoc": { - "version": "3.6.11", - "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.11.tgz", - "integrity": "sha512-8UCU0TYeIYD9KeLzEcAu2q8N/mx9O3phAGl32nmHlE0LpaJL71mMkP4d+QE5zWfNt50qheHtOZ0qoxVrsX5TUg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-4.0.0.tgz", + "integrity": "sha512-tzTgkklbWKrlaQL2+e3NNgLcZu3NaK2vsHRx7tyHQ+H5jcB9Gx0txSd2eJWlMC/xU1+7LQu4s58Ry0RkuaEQVg==", "dependencies": { "@babel/parser": "^7.9.4", + "@jsdoc/salty": "^0.2.1", "@types/markdown-it": "^12.2.3", "bluebird": "^3.7.2", "catharsis": "^0.9.0", @@ -2817,7 +3912,6 @@ "mkdirp": "^1.0.4", "requizzle": "^0.2.3", "strip-json-comments": "^3.1.0", - "taffydb": "2.6.2", "underscore": "~1.13.2" }, "bin": { @@ -2843,12 +3937,20 @@ "bignumber.js": "^9.0.0" } }, + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" + }, "node_modules/json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "dev": true, - "optional": true + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" }, "node_modules/jsonfile": { "version": "4.0.0", @@ -2859,6 +3961,20 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsprim": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", + "dependencies": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.4.0", + "verror": "1.10.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, "node_modules/jsqr": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.4.0.tgz", @@ -2988,6 +4104,45 @@ "node": ">= 0.8.0" } }, + "node_modules/libsignal": { + "version": "2.0.1", + "resolved": "git+ssh://git@github.com/adiwajshing/libsignal-node.git#11dbd962ea108187c79a7c46fe4d6f790e23da97", + "license": "GPL-3.0", + "dependencies": { + "curve25519-js": "^0.0.4", + "protobufjs": "6.8.8" + } + }, + "node_modules/libsignal/node_modules/@types/node": { + "version": "10.17.60", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", + "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==" + }, + "node_modules/libsignal/node_modules/protobufjs": { + "version": "6.8.8", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz", + "integrity": "sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==", + "hasInstallScript": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.0", + "@types/node": "^10.1.0", + "long": "^4.0.0" + }, + "bin": { + "pbjs": "bin/pbjs", + "pbts": "bin/pbts" + } + }, "node_modules/lie": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", @@ -3009,6 +4164,21 @@ "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", "integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==" }, + "node_modules/load-bmfont": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/load-bmfont/-/load-bmfont-1.4.1.tgz", + "integrity": "sha512-8UyQoYmdRDy81Brz6aLAUhfZLwr5zV0L3taTQ4hju7m6biuwiWiJXjPhBJxbUQJA8PrkvJ/7Enqmwk2sM14soA==", + "dependencies": { + "buffer-equal": "0.0.1", + "mime": "^1.3.4", + "parse-bmfont-ascii": "^1.0.3", + "parse-bmfont-binary": "^1.0.5", + "parse-bmfont-xml": "^1.1.4", + "phin": "^2.9.1", + "xhr": "^2.0.1", + "xtend": "^4.0.0" + } + }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -3211,6 +4381,14 @@ "node": ">= 0.6" } }, + "node_modules/min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==", + "dependencies": { + "dom-walk": "^0.1.0" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -3223,9 +4401,9 @@ } }, "node_modules/minimist": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", - "integrity": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -3265,6 +4443,116 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/music-metadata": { + "version": "7.13.3", + "resolved": "https://registry.npmjs.org/music-metadata/-/music-metadata-7.13.3.tgz", + "integrity": "sha512-qxh+Xgy1qHhrgW4XnXu5JUxMmRNdQXDEeIZLGXpapOi96rRCocXn498L+y2P7t6NJXFK8e3Shv2tu0dC/HF/3g==", + "dependencies": { + "@tokenizer/token": "^0.3.0", + "content-type": "^1.0.4", + "debug": "^4.3.4", + "file-type": "^16.5.4", + "media-typer": "^1.1.0", + "strtok3": "^6.3.0", + "token-types": "^4.2.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/music-metadata/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/music-metadata/node_modules/file-type": { + "version": "16.5.4", + "resolved": "https://registry.npmjs.org/file-type/-/file-type-16.5.4.tgz", + "integrity": "sha512-/yFHK0aGjFEgDJjEKP0pWCplsPFPhwyfwevf/pVxiN0tmE4L9LmwWxWukdJSHdoCli4VgQLehjJtwQBnqmsKcw==", + "dependencies": { + "readable-web-to-node-stream": "^3.0.0", + "strtok3": "^6.2.4", + "token-types": "^4.1.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/file-type?sponsor=1" + } + }, + "node_modules/music-metadata/node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/music-metadata/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/music-metadata/node_modules/peek-readable": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-4.1.0.tgz", + "integrity": "sha512-ZI3LnwUv5nOGbQzD9c2iDG6toheuXSZP5esSHBjopsXH4dg19soufvpUGA3uohi5anFtGb2lhAVdHzH6R/Evvg==", + "engines": { + "node": ">=8" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/music-metadata/node_modules/strtok3": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/strtok3/-/strtok3-6.3.0.tgz", + "integrity": "sha512-fZtbhtvI9I48xDSywd/somNqgUHl2L2cstmXCCif0itOf96jeW18MBSyrLuNicYQVkvpOxkZtkzujiTJ9LW5Jw==", + "dependencies": { + "@tokenizer/token": "^0.3.0", + "peek-readable": "^4.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, + "node_modules/music-metadata/node_modules/token-types": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/token-types/-/token-types-4.2.1.tgz", + "integrity": "sha512-6udB24Q737UD/SDsKAHI9FCRP7Bqc9D/MQUV02ORQg5iskjtLJlZJNdN4kKtcdtwCeWIwIHDGaUsTsCCAa8sFQ==", + "dependencies": { + "@tokenizer/token": "^0.3.0", + "ieee754": "^1.2.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + } + }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -3369,10 +4657,21 @@ "node": ">= 0.4.0" } }, + "node_modules/node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "dependencies": { + "clone": "2.x" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/node-fetch": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.8.tgz", - "integrity": "sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz", + "integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -3428,6 +4727,14 @@ "integrity": "sha512-K7J4xq5xAD5jHsGM5ReWXRTFa3JRGofHiMcVgQ8PRwgWxzjHpMWCIzsmyf60+mh8KLsqYPcjUMa0AC4hd6lPyQ==", "dev": true }, + "node_modules/oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "engines": { + "node": "*" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -3452,6 +4759,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/omggif": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/omggif/-/omggif-1.0.10.tgz", + "integrity": "sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==", + "optional": true, + "peer": true + }, + "node_modules/on-exit-leak-free": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", + "integrity": "sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==" + }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -3582,6 +4901,30 @@ "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" }, + "node_modules/parse-bmfont-ascii": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/parse-bmfont-ascii/-/parse-bmfont-ascii-1.0.6.tgz", + "integrity": "sha512-U4RrVsUFCleIOBsIGYOMKjn9PavsGOXxbvYGtMOEfnId0SVNsgehXh1DxUdVPLoxd5mvcEtvmKs2Mmf0Mpa1ZA==" + }, + "node_modules/parse-bmfont-binary": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/parse-bmfont-binary/-/parse-bmfont-binary-1.0.6.tgz", + "integrity": "sha512-GxmsRea0wdGdYthjuUeWTMWPqm2+FAd4GI8vCvhgJsFnoGhTrLhXDDupwTo7rXVAgaLIGoVHDZS9p/5XbSqeWA==" + }, + "node_modules/parse-bmfont-xml": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/parse-bmfont-xml/-/parse-bmfont-xml-1.1.4.tgz", + "integrity": "sha512-bjnliEOmGv3y1aMEfREMBJ9tfL3WR0i0CKPj61DnSLaoxWR3nLrsQrEbCId/8rF4NyRF0cCqisSVXyQYWM+mCQ==", + "dependencies": { + "xml-parse-from-string": "^1.0.0", + "xml2js": "^0.4.5" + } + }, + "node_modules/parse-headers": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.5.tgz", + "integrity": "sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA==" + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -3639,6 +4982,16 @@ "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==" }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" + }, + "node_modules/phin": { + "version": "2.9.3", + "resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz", + "integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA==" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -3663,6 +5016,52 @@ "node": ">=10" } }, + "node_modules/pino": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-7.11.0.tgz", + "integrity": "sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg==", + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.0.0", + "on-exit-leak-free": "^0.2.0", + "pino-abstract-transport": "v0.5.0", + "pino-std-serializers": "^4.0.0", + "process-warning": "^1.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.1.0", + "safe-stable-stringify": "^2.1.0", + "sonic-boom": "^2.2.1", + "thread-stream": "^0.15.1" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz", + "integrity": "sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ==", + "dependencies": { + "duplexify": "^4.1.2", + "split2": "^4.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz", + "integrity": "sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q==" + }, + "node_modules/pixelmatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz", + "integrity": "sha512-J8B6xqiO37sU/gkcMglv6h5Jbd9xNER7aHzpfRdNmV4IbQBzBpe4l9XmbG+xPF/znacgu2jfEw+wHffaq/YkXA==", + "dependencies": { + "pngjs": "^3.0.0" + }, + "bin": { + "pixelmatch": "bin/pixelmatch" + } + }, "node_modules/pkg-dir": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", @@ -3893,6 +5292,14 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/pngjs": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", + "integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==", + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -3916,11 +5323,24 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" }, + "node_modules/process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" + }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -3950,9 +5370,9 @@ } }, "node_modules/protobufjs": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.1.2.tgz", - "integrity": "sha512-4ZPTPkXCdel3+L81yw3dG6+Kq3umdWKh7Dc7GW/CpNk4SX3hK58iPCWeCyhVTDrbkNeKrYNZ7EojM5WDaEWTLQ==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.2.tgz", + "integrity": "sha512-++PrQIjrom+bFDPpfmqXfAGSQs40116JRrqqyf53dymUMvvb5d/LMRyicRoF1AUKoXVS1/IgJXlEgcpr4gTF3Q==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", @@ -3973,16 +5393,16 @@ } }, "node_modules/protobufjs-cli": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/protobufjs-cli/-/protobufjs-cli-1.0.2.tgz", - "integrity": "sha512-cz9Pq9p/Zs7okc6avH20W7QuyjTclwJPgqXG11jNaulfS3nbVisID8rC+prfgq0gbZE0w9LBFd1OKFF03kgFzg==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/protobufjs-cli/-/protobufjs-cli-1.1.1.tgz", + "integrity": "sha512-VPWMgIcRNyQwWUv8OLPyGQ/0lQY/QTQAVN5fh+XzfDwsVw1FZ2L3DM/bcBf8WPiRz2tNpaov9lPZfNcmNo6LXA==", "dependencies": { "chalk": "^4.0.0", "escodegen": "^1.13.0", "espree": "^9.0.0", "estraverse": "^5.1.0", "glob": "^8.0.0", - "jsdoc": "^3.6.3", + "jsdoc": "^4.0.0", "minimist": "^1.2.0", "semver": "^7.1.2", "tmp": "^0.2.1", @@ -4130,6 +5550,11 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -4139,6 +5564,14 @@ "once": "^1.3.1" } }, + "node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "engines": { + "node": ">=6" + } + }, "node_modules/puppeteer": { "version": "13.7.0", "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-13.7.0.tgz", @@ -4231,6 +5664,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==" + }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -4265,6 +5703,14 @@ "node": ">=0.8" } }, + "node_modules/read-chunk": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-chunk/-/read-chunk-1.0.1.tgz", + "integrity": "sha512-5NLTTdX45dKFtG8CX5pKmvS9V5u9wBE+gkklN7xhDuhq3pA2I4O7ALfKxosCMcLHOhkxj6GNacZhfXtp5nlCdg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", @@ -4332,6 +5778,82 @@ "node": ">=8.10.0" } }, + "node_modules/real-require": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.1.0.tgz", + "integrity": "sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg==", + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", + "optional": true, + "peer": true + }, + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", + "dependencies": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/request/node_modules/form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/request/node_modules/qs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/request/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -4488,6 +6010,14 @@ } ] }, + "node_modules/safe-stable-stringify": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.4.2.tgz", + "integrity": "sha512-gMxvPJYhP0O9n2pvcfYfIuYgbledAOJFcqRThtPRmjscaipiwcwPPKLytpVzMkG2HAN87Qmo2d4PtGiri1dSLA==", + "engines": { + "node": ">=10" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -4496,8 +6026,7 @@ "node_modules/sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, "node_modules/saxes": { "version": "5.0.1", @@ -4612,15 +6141,15 @@ } }, "node_modules/socket.io": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.4.tgz", - "integrity": "sha512-m3GC94iK9MfIEeIBfbhJs5BqFibMtkRk8ZpKwG2QwxV0m/eEhPIV4ara6XCF1LWNAus7z58RodiZlAH71U3EhQ==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.6.0.tgz", + "integrity": "sha512-b65bp6INPk/BMMrIgVvX12x3Q+NqlGqSlTuvKQWt0BUJ3Hyy3JangBl7fEoWZTXbOKlCqNPbQ6MbWgok/km28w==", "dependencies": { "accepts": "~1.3.4", "base64id": "~2.0.0", "debug": "~4.3.2", - "engine.io": "~6.2.1", - "socket.io-adapter": "~2.4.0", + "engine.io": "~6.4.0", + "socket.io-adapter": "~2.5.2", "socket.io-parser": "~4.2.1" }, "engines": { @@ -4628,9 +6157,32 @@ } }, "node_modules/socket.io-adapter": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz", - "integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg==" + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.2.tgz", + "integrity": "sha512-87C3LO/NOMc+eMcpcxUBebGjkpMDkNBS9tf7KJqcDsmL936EChtVva71Dw2q4tQcuVC+hAUy4an2NO/sYXmwRA==", + "dependencies": { + "ws": "~8.11.0" + } + }, + "node_modules/socket.io-adapter/node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } }, "node_modules/socket.io-parser": { "version": "4.2.2", @@ -4743,6 +6295,14 @@ "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==", "dev": true }, + "node_modules/sonic-boom": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz", + "integrity": "sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -4762,6 +6322,14 @@ "source-map": "^0.6.0" } }, + "node_modules/split2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.1.0.tgz", + "integrity": "sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ==", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/sprintf-js": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", @@ -4787,6 +6355,30 @@ "node": ">=0.8" } }, + "node_modules/sshpk": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", + "integrity": "sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==", + "dependencies": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -4806,6 +6398,25 @@ "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", "integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==" }, + "node_modules/stream-to": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/stream-to/-/stream-to-0.2.2.tgz", + "integrity": "sha512-Kg1BSDTwgGiVMtTCJNlo7kk/xzL33ZuZveEBRt6rXw+f1WLK/8kmz2NVCT/Qnv0JkV85JOHcLhD82mnXsR3kPw==", + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/stream-to-buffer": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/stream-to-buffer/-/stream-to-buffer-0.1.0.tgz", + "integrity": "sha512-Da4WoKaZyu3nf+bIdIifh7IPkFjARBnBK+pYqn0EUJqksjV9afojjaCCHUemH30Jmu7T2qcKvlZm2ykN38uzaw==", + "dependencies": { + "stream-to": "~0.2.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -4889,9 +6500,9 @@ } }, "node_modules/systeminformation": { - "version": "5.17.7", - "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.17.7.tgz", - "integrity": "sha512-0eQA5IkDlP4njQm9b5LvApCXaD52zFLfu+Xte1VdfaMChu4DxCSCmCjr/jAQK63gtHJ63x5gstCW5y3oWh9n+A==", + "version": "5.17.8", + "resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.17.8.tgz", + "integrity": "sha512-kMQsCOFQXqEjoDWKpYkC+ezJImrOnyTL3FZnYDZdWLTZcMW7Gomdp8zH9ztGlSo2L1iCAQXZ8HlV1bI8/Ts64g==", "dev": true, "optional": true, "os": [ @@ -4915,11 +6526,6 @@ "url": "https://www.buymeacoffee.com/systeminfo" } }, - "node_modules/taffydb": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", - "integrity": "sha512-y3JaeRSplks6NYQuCOj3ZFMO3j60rTwbuKCvZxsAraGYH2epusatvZ0baZYA01WsGqJBq/Dl6vOrMUJqyMj8kA==" - }, "node_modules/tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", @@ -4946,11 +6552,31 @@ "node": ">=6" } }, + "node_modules/thread-stream": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", + "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", + "dependencies": { + "real-require": "^0.1.0" + } + }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, + "node_modules/timm": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/timm/-/timm-1.7.1.tgz", + "integrity": "sha512-IjZc9KIotudix8bMaBW6QvMuq64BrJWFs1+4V0lXwWGQZwH+LnX87doAYhem4caOEusRP9/g6jVDQmZ8XOk1nw==", + "optional": true, + "peer": true + }, + "node_modules/tinycolor2": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.6.0.tgz", + "integrity": "sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==" + }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", @@ -4998,6 +6624,18 @@ "url": "https://github.com/sponsors/Borewit" } }, + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dependencies": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -5017,6 +6655,17 @@ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, + "node_modules/tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", + "dependencies": { + "safe-buffer": "^5.0.1" + }, + "engines": { + "node": "*" + } + }, "node_modules/tv4": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/tv4/-/tv4-1.3.0.tgz", @@ -5026,6 +6675,11 @@ "node": ">= 0.8.0" } }, + "node_modules/tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + }, "node_modules/tx2": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tx2/-/tx2-1.0.5.tgz", @@ -5155,11 +6809,40 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/url-regex": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/url-regex/-/url-regex-3.2.0.tgz", + "integrity": "sha512-dQ9cJzMou5OKr6ZzfvwJkCq3rC72PNXhqz0v3EIhF4a3Np+ujr100AhUx2cKx5ei3iymoJpJrPB3sVSEMdqAeg==", + "dependencies": { + "ip-regex": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/url-template": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", "integrity": "sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw==" }, + "node_modules/utif": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/utif/-/utif-2.0.1.tgz", + "integrity": "sha512-Z/S1fNKCicQTf375lIP9G8Sa1H/phcysstNrrSdZKj1f9g58J4NMgb5IgiEZN9/nLMPDwF0W7hdOe9Qq2IYoLg==", + "optional": true, + "peer": true, + "dependencies": { + "pako": "^1.0.5" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -5194,6 +6877,24 @@ "node": ">= 0.8" } }, + "node_modules/verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", + "engines": [ + "node >=0.6.0" + ], + "dependencies": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, + "node_modules/verror/node_modules/core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==" + }, "node_modules/vizion": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/vizion/-/vizion-2.2.1.tgz", @@ -5219,9 +6920,9 @@ } }, "node_modules/vm2": { - "version": "3.9.13", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.13.tgz", - "integrity": "sha512-0rvxpB8P8Shm4wX2EKOiMp7H2zq+HUE/UwodY0pCZXs9IffIKZq6vUti5OgkVCTakKo9e/fgO4X1fkwfjWxE3Q==", + "version": "3.9.14", + "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.14.tgz", + "integrity": "sha512-HgvPHYHeQy8+QhzlFryvSteA4uQLBCOub02mgqdR+0bN/akRZ48TGB1v0aCv7ksyc0HXx16AZtMHKS38alc6TA==", "dev": true, "dependencies": { "acorn": "^8.7.0", @@ -5240,8 +6941,8 @@ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, "node_modules/whatsapp-web.js": { - "version": "1.19.2", - "resolved": "git+ssh://git@github.com/cheveguerra/whatsapp-web.js.git#025f9914c3ee090c760fe6f2218e68b8bc9225af", + "version": "1.19.3", + "resolved": "git+ssh://git@github.com/cheveguerra/whatsapp-web.js.git#29b61b396b7728c019cdebaf77916c705fbf8970", "license": "Apache-2.0", "dependencies": { "@pedroslopez/moduleraid": "^5.0.2", @@ -5393,6 +7094,17 @@ } } }, + "node_modules/xhr": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.6.0.tgz", + "integrity": "sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA==", + "dependencies": { + "global": "~4.4.0", + "is-function": "^1.0.1", + "parse-headers": "^2.0.0", + "xtend": "^4.0.0" + } + }, "node_modules/xlsx": { "version": "0.18.5", "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz", @@ -5413,6 +7125,31 @@ "node": ">=0.8" } }, + "node_modules/xml-parse-from-string": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml-parse-from-string/-/xml-parse-from-string-1.0.1.tgz", + "integrity": "sha512-ErcKwJTF54uRzzNMXq2X5sMIy88zJvfN2DmdoQvy7PAFJ+tPRU6ydWuOKNMyfmOjdyBQTFREi60s0Y0SyI0G0g==" + }, + "node_modules/xml2js": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz", + "integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "engines": { + "node": ">=4.0" + } + }, "node_modules/xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", @@ -5432,6 +7169,14 @@ "node": "*" } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index c77715a..49b86bc 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/provider/baileys.js b/provider/baileys.js new file mode 100644 index 0000000..96b0146 --- /dev/null +++ b/provider/baileys.js @@ -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 } \ No newline at end of file diff --git a/provider/download.js b/provider/download.js new file mode 100644 index 0000000..76e23a0 --- /dev/null +++ b/provider/download.js @@ -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 } diff --git a/provider/wwebjs.js b/provider/wwebjs.js new file mode 100644 index 0000000..8e7e412 --- /dev/null +++ b/provider/wwebjs.js @@ -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 } \ No newline at end of file