mirror of
https://github.com/cheveguerra/botLeiferAurik-Mod_2.0.git
synced 2026-04-17 19:36:17 +00:00
pequeños camios
This commit is contained in:
@@ -49,9 +49,10 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (process.env.DATABASE === 'none') {
|
if (process.env.DATABASE === 'none') {
|
||||||
|
// console.log(message)
|
||||||
var { key } = stepsInitial.find(k => k.keywords.includes(message)) || { key: null }
|
var { key } = stepsInitial.find(k => k.keywords.includes(message)) || { key: null }
|
||||||
console.log("KEY="+key)
|
// console.log(stepsInitial)
|
||||||
|
// console.log("KEY="+key)
|
||||||
|
|
||||||
/* ############################################### * REGEXP * ####################################################
|
/* ############################################### * REGEXP * ####################################################
|
||||||
Si queremos usar RegExp, en los "keywords" de inital.json, en lugar de un arreglo usamos un string (quitamos los [])
|
Si queremos usar RegExp, en los "keywords" de inital.json, en lugar de un arreglo usamos un string (quitamos los [])
|
||||||
@@ -71,7 +72,7 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
|||||||
var {keywords} = stepsInitial.find(k => k.key.includes(key)) || { keywords: null }
|
var {keywords} = stepsInitial.find(k => k.key.includes(key)) || { keywords: null }
|
||||||
if(!Array.isArray(keywords)){key=null;}//Si "keywords" no es arreglo entonces ponemos "key" en null y usamos REGEXP para buscar reglas.
|
if(!Array.isArray(keywords)){key=null;}//Si "keywords" no es arreglo entonces ponemos "key" en null y usamos REGEXP para buscar reglas.
|
||||||
if(key == null && message.length > 0){
|
if(key == null && message.length > 0){
|
||||||
var logRegEx = true
|
var logRegEx = false
|
||||||
console.log("======= KEY ES NULO, USAMOS REGEXP =======");
|
console.log("======= KEY ES NULO, USAMOS REGEXP =======");
|
||||||
for (i=0; i<stepsInitial.length;i++){
|
for (i=0; i<stepsInitial.length;i++){
|
||||||
if(!Array.isArray(stepsInitial[i].keywords)){// Si "Keywords" NO es arreglo entonces ...
|
if(!Array.isArray(stepsInitial[i].keywords)){// Si "Keywords" NO es arreglo entonces ...
|
||||||
@@ -220,8 +221,8 @@ module.exports = { get, reply, getIA, saveMessage, remplazos, stepsInitial, vamo
|
|||||||
/**
|
/**
|
||||||
* Asigna el valor especificado a la variable pasoAnterior.
|
* Asigna el valor especificado a la variable pasoAnterior.
|
||||||
* Esta hace que el flujo se redirija al paso siguente al especificado.
|
* Esta hace que el flujo se redirija al paso siguente al especificado.
|
||||||
* @param {elNum} El numero del remitente.
|
* @param {elNum} string - El numero del remitente.
|
||||||
* @param {elPaso} El paso al que se va redirigir el flujo.
|
* @param {elPaso} string - El paso al que se va redirigir el flujo.
|
||||||
*/
|
*/
|
||||||
function vamosA (elNum, elPaso){
|
function vamosA (elNum, elPaso){
|
||||||
pasoAnterior[elNum] = elPaso;
|
pasoAnterior[elNum] = elPaso;
|
||||||
@@ -305,7 +306,7 @@ function remplazos(elTexto, extraInfo){
|
|||||||
let rawdata = fs.readFileSync(`./chats/${elNum}.json`);
|
let rawdata = fs.readFileSync(`./chats/${elNum}.json`);
|
||||||
let elHistorial0 = JSON.parse(rawdata);
|
let elHistorial0 = JSON.parse(rawdata);
|
||||||
elHistorial = elHistorial0["messages"];
|
elHistorial = elHistorial0["messages"];
|
||||||
|
elHistorial = elHistorial.filter(x => x.message != "") //Quitamos mensajes en blanco.
|
||||||
var inicio = laLista[i].search('%msjant_');
|
var inicio = laLista[i].search('%msjant_');
|
||||||
var final = laLista[i].indexOf("%", inicio+1);
|
var final = laLista[i].indexOf("%", inicio+1);
|
||||||
var subStr = laLista[i].substring(inicio, final+1);
|
var subStr = laLista[i].substring(inicio, final+1);
|
||||||
|
|||||||
185
app.js
185
app.js
@@ -31,7 +31,7 @@ app.use(express.json())
|
|||||||
const MULTI_DEVICE = process.env.MULTI_DEVICE || 'true';
|
const MULTI_DEVICE = process.env.MULTI_DEVICE || 'true';
|
||||||
const server = require('http').Server(app)
|
const server = require('http').Server(app)
|
||||||
const port = process.env.PORT || 3000
|
const port = process.env.PORT || 3000
|
||||||
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve,ms))
|
||||||
var client;
|
var client;
|
||||||
var dialogflowFilter = false;
|
var dialogflowFilter = false;
|
||||||
var totalMsjs; //MOD by CHV -
|
var totalMsjs; //MOD by CHV -
|
||||||
@@ -40,11 +40,12 @@ var newBody; //MOD by CHV -
|
|||||||
var nuevaRespuesta; //MOD by CHV - Se agrego para los remplazos
|
var nuevaRespuesta; //MOD by CHV - Se agrego para los remplazos
|
||||||
var vars = []
|
var vars = []
|
||||||
app.use('/', require('./routes/web'))
|
app.use('/', require('./routes/web'))
|
||||||
|
let blackList = ['34692936038', '34678310819', '34660962689', '34649145761','34630283553','34648827637','34630255646','14178973313']
|
||||||
/**
|
|
||||||
* Escuchamos cuando entre un mensaje
|
/**
|
||||||
*/
|
* Escuchamos cuando entre un mensaje
|
||||||
const listenMessage = () => client.on('message', async msg => {
|
*/
|
||||||
|
listenMessage = () => client.on('message', async msg => {
|
||||||
const { from, body, hasMedia } = msg;
|
const { from, body, hasMedia } = msg;
|
||||||
if (vars[from] === undefined) vars[from] = []
|
if (vars[from] === undefined) vars[from] = []
|
||||||
// console.log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
// console.log("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||||
@@ -63,6 +64,12 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
if (from === 'status@broadcast') {
|
if (from === 'status@broadcast') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Blacklist, los telefonos inlcuidos en este arreglo son ignorados por el bot.
|
||||||
|
*/
|
||||||
|
console.log('BlackListed: ',blackList.includes(from.replace("@c.us","")))
|
||||||
|
if (blackList.includes(from.replace("@c.us",""))) return
|
||||||
message = newBody.toLowerCase();
|
message = newBody.toLowerCase();
|
||||||
const number = cleanNumber(from)
|
const number = cleanNumber(from)
|
||||||
client.theMsg['numero'] = number
|
client.theMsg['numero'] = number
|
||||||
@@ -223,13 +230,13 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
// console.log('RES=', RES)
|
// console.log('RES=', RES)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Llama el API para traer categorias de Guna.
|
* Llama el API para traer categorias de Guna.
|
||||||
* @param {*} ctx El objeto del mensaje.
|
* @param {*} ctx El objeto del mensaje.
|
||||||
*/
|
*/
|
||||||
async function getGunaCats(ctx) {
|
async function getGunaCats(ctx) {
|
||||||
let par1 = ctx.theMsg.body
|
let theUrl = `http://localhost:8888/dbrquery?j={"query":"selectTipoFerreroMty","exec":"ExecuteQuery","params":{"par1":"xxx"}}`
|
||||||
let theUrl = `http://localhost:8888/dbrquery?j={"query":"selectTipoFerreroMty","exec":"ExecuteQuery","params":{"par1":"${par1}"}}`
|
|
||||||
const RES = await axios.get(theUrl).then(function (response) {
|
const RES = await axios.get(theUrl).then(function (response) {
|
||||||
let lasOpciones = []
|
let lasOpciones = []
|
||||||
for(reg=0;reg<response.data.respuesta.length;reg++) {
|
for(reg=0;reg<response.data.respuesta.length;reg++) {
|
||||||
@@ -303,12 +310,14 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
return error
|
return error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Llama el API para traer productos de Guna.
|
* Llama el API para traer productos de Guna.
|
||||||
* @param {*} ctx El objeto del mensaje.
|
* @param {*} ctx El objeto del mensaje.
|
||||||
*/
|
*/
|
||||||
async function getGunaProds(ctx) {
|
async function getGunaProds(ctx) {
|
||||||
if(vars[from]['recompra'] === undefined) vars[from]['subtipo'] = ctx.theMsg.body
|
if(vars[from]['recompra'] === undefined) vars[from]['subtipo'] = ctx.theMsg.body
|
||||||
|
console.log(vars[from]['tipo'], vars[from]['subtipo'])
|
||||||
let theUrl = `http://localhost:8888/dbrquery?j={"query":"selectProdsFerreroMty","exec":"ExecuteQuery","params":{"par1":"${vars[from]['tipo']}", "par2":"${vars[from]['subtipo']}"}}`
|
let theUrl = `http://localhost:8888/dbrquery?j={"query":"selectProdsFerreroMty","exec":"ExecuteQuery","params":{"par1":"${vars[from]['tipo']}", "par2":"${vars[from]['subtipo']}"}}`
|
||||||
const RES = await axios.get(theUrl).then(function (response) {
|
const RES = await axios.get(theUrl).then(function (response) {
|
||||||
let elMensaje = "Gracias,\nAhora un producto:\n\n"
|
let elMensaje = "Gracias,\nAhora un producto:\n\n"
|
||||||
@@ -327,7 +336,7 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
rows: lasOpciones,
|
rows: lasOpciones,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
`SUBCATEGORÍA ${body}`,
|
`SUBCATEGORÍA ${vars[from]['subtipo']}`,
|
||||||
"Footer"
|
"Footer"
|
||||||
)
|
)
|
||||||
client.sendMessage(from, productList)
|
client.sendMessage(from, productList)
|
||||||
@@ -337,6 +346,7 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
return error
|
return error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Llama el API para traer productos de Guna.
|
* Llama el API para traer productos de Guna.
|
||||||
* @param {*} ctx El objeto del mensaje.
|
* @param {*} ctx El objeto del mensaje.
|
||||||
@@ -345,20 +355,34 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
// vars[from]['subtipo'] = ctx.theMsg.body
|
// vars[from]['subtipo'] = ctx.theMsg.body
|
||||||
if(vars[from]['prods'] === undefined) { vars[from]['prods'] = [] }
|
if(vars[from]['prods'] === undefined) { vars[from]['prods'] = [] }
|
||||||
let elProd = ctx.theMsg.body
|
let elProd = ctx.theMsg.body
|
||||||
elProd = elProd.substring(0, elProd.indexOf(' $')).trim().toLowerCase()
|
let elMensaje = ""
|
||||||
var precio = ctx.theMsg.body.substring(ctx.theMsg.body.indexOf(' $')+2)
|
if(elProd.indexOf(' $') > -1){ // Producto con formato correcto.
|
||||||
console.log("precio",precio)
|
vars[from]['ultimoProd'] = elProd
|
||||||
precio = precio.substring(0, precio.indexOf(','))
|
elProd = elProd.substring(0, elProd.indexOf(' $')).trim().toLowerCase()
|
||||||
console.log("precio",precio)
|
var precio = ctx.theMsg.body.substring(ctx.theMsg.body.indexOf(' $')+2)
|
||||||
vars[from]['prods'][elProd] = {"cant":0, "precio":precio}
|
console.log("precio",precio)
|
||||||
console.log("EL_PROD=", elProd)
|
precio = precio.substring(0, precio.indexOf(','))
|
||||||
console.log(vars[from]['prods'][elProd])
|
console.log("precio",precio)
|
||||||
let elMensaje = ctx.theMsg.replyMessage
|
vars[from]['prods'][elProd] = {"cant":0, "precio":precio}
|
||||||
let re = ctx.theMsg.body.trim().toLowerCase()
|
console.log("EL_PROD=", elProd)
|
||||||
elMensaje = elMensaje.replace(re, elProd.toLowerCase())
|
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);
|
sendMessage(client, from, elMensaje, ctx.theMsg.trigger, ctx.theMsg.step);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tomamos la cantidad del producto seleccionado.
|
* Tomamos la cantidad del producto seleccionado.
|
||||||
* @param {*} ctx El objeto del mensaje.
|
* @param {*} ctx El objeto del mensaje.
|
||||||
@@ -366,33 +390,39 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
async function prodCantidad(ctx) {
|
async function prodCantidad(ctx) {
|
||||||
// console.log("Entramos a prodCantidad")
|
// console.log("Entramos a prodCantidad")
|
||||||
let laCant = ctx.theMsg.body.trim()
|
let laCant = ctx.theMsg.body.trim()
|
||||||
const reg = new RegExp('^[0-9]+$')
|
const reg = new RegExp(/^\d+$/)
|
||||||
let elProd = remplazos("%msjant_2%").toLowerCase()
|
let elProd = vars[from]['ultimoProd'].toLowerCase()
|
||||||
elProd = elProd.substring(0, elProd.indexOf(' $')).trim()
|
elProd = elProd.substring(0, elProd.indexOf(' $')).trim()
|
||||||
|
console.log("SOLO NUMS |" + laCant + "|", reg.test(laCant))
|
||||||
if(reg.test(laCant)){
|
if(reg.test(laCant)){
|
||||||
|
console.log(vars)
|
||||||
console.log("Recibimos cant = " + laCant)
|
console.log("Recibimos cant = " + laCant)
|
||||||
console.log("EL_PROD=", vars[from]['prods'][elProd])
|
console.log("EL_PROD=", vars[from]['prods'][elProd])
|
||||||
console.log("precio=", vars[from]['prods'][elProd].precio)
|
console.log("precio=", vars[from]['prods'][elProd].precio)
|
||||||
console.log("precio=", vars[from]['prods'][elProd]['precio'])
|
|
||||||
vars[from]['prods'][elProd] = {"cant":laCant, "precio":vars[from]['prods'][elProd]['precio']}
|
vars[from]['prods'][elProd] = {"cant":laCant, "precio":vars[from]['prods'][elProd]['precio']}
|
||||||
console.log(vars[from]['prods'])
|
var elMensaje = ""
|
||||||
var elMensaje = ""
|
const prods = Object.keys(vars[from]['prods']);
|
||||||
const prods = Object.keys(vars[from]['prods']);
|
var total = 0
|
||||||
prods.forEach((prod, index) => {
|
prods.forEach((prod, index) => {
|
||||||
elMensaje = elMensaje + `${vars[from]['prods'][prod].cant} - ${prod[0].toUpperCase() + prod.substring(1)}\n`
|
if( vars[from]['prods'][prod] !== undefined && prod[0] !== undefined ){
|
||||||
console.log(`${prod}: ${vars[from]['prods'][prod]}`);
|
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)
|
||||||
elMensaje = elMensaje + "\n¿Quieres agregar mas productos a tu orden?"
|
if(reg.test(vars[from]['prods'][prod].cant) && vars[from]['prods'][prod].precio != ""){
|
||||||
// for(pr=0;pr<vars[from]['prods'].length;pr++){
|
total = total + (vars[from]['prods'][prod].cant * vars[from]['prods'][prod].precio)
|
||||||
// elMensaje = elMensaje + vars[from]['prods'][pr]
|
}
|
||||||
// }
|
}
|
||||||
// sendMessage(client, from, elMensaje, response.trigger, step);
|
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 = {
|
var bts = {
|
||||||
"title":"Tu orden",
|
"title":"Tu orden",
|
||||||
"message":elMensaje,
|
"message":elMensaje,
|
||||||
"buttons":[
|
"buttons":[
|
||||||
{"body":"Terminar"},
|
{"body":"➕ Agregar productos"},
|
||||||
{"body":"Agregar productos"}
|
{"body":"⬅️ Cambiar categoría"},
|
||||||
|
{"body":"✖️ Terminar"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
sendMessageButton(client, from, "xxx", bts)
|
sendMessageButton(client, from, "xxx", bts)
|
||||||
@@ -412,11 +442,22 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
async function comprarMas(ctx) {
|
async function comprarMas(ctx) {
|
||||||
console.log("Entramos a comprarMas")
|
console.log("Entramos a comprarMas")
|
||||||
vars[from]['recompra'] = true
|
vars[from]['recompra'] = true
|
||||||
|
vamosA(from, "gunaProds")
|
||||||
await getGunaProds(ctx)
|
await getGunaProds(ctx)
|
||||||
vars[from]['recompra'] = false
|
vars[from]['recompra'] = false
|
||||||
return "1"
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -448,7 +489,7 @@ const listenMessage = () => client.on('message', async msg => {
|
|||||||
console.log("############# Encontramos función, ejecutamos la función '" + response.funcion + "'")
|
console.log("############# Encontramos función, ejecutamos la función '" + response.funcion + "'")
|
||||||
laFuncion = response.funcion + "(client)"
|
laFuncion = response.funcion + "(client)"
|
||||||
eval(laFuncion)
|
eval(laFuncion)
|
||||||
return
|
// return
|
||||||
}
|
}
|
||||||
if(response.hasOwnProperty('urlXXXXXXX') && response.hasOwnProperty('values')){
|
if(response.hasOwnProperty('urlXXXXXXX') && response.hasOwnProperty('values')){
|
||||||
let theURL = response.url;
|
let theURL = response.url;
|
||||||
@@ -568,35 +609,35 @@ if(message=='/spam'){
|
|||||||
const masivo = require('./spam.json')
|
const masivo = require('./spam.json')
|
||||||
var saludo;
|
var saludo;
|
||||||
var caritas;
|
var caritas;
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
async function retardo() {
|
||||||
|
for (sp=0;sp<masivo.length;sp++) {
|
||||||
|
console.log(masivo[sp].numero+"@c.us");
|
||||||
|
var rnd = getRandomInt(1,7); // Random entre 1 y 6 segundos.
|
||||||
|
if(rnd==1||rnd==4){saludo = "Hola ";}
|
||||||
|
else if(rnd==2||rnd==5){saludo = "Saludos ";}
|
||||||
|
else {saludo = "%saludo% ";}
|
||||||
|
if(rnd==1){caritas = "👨🏻🦰👩🏻🦰";}
|
||||||
|
else if(rnd==2){caritas = "👩🏻🦰👨🏻🦰";}
|
||||||
|
else if(rnd==3){caritas = "🧔🏽👧🏽";}
|
||||||
|
else if(rnd==4){caritas = "👧🏽🧔🏽";}
|
||||||
|
else if(rnd==5){caritas = "👩🏻🦰🧔🏽";}
|
||||||
|
else if(rnd==6){caritas = "🧔🏽👩🏻🦰";}
|
||||||
|
if(sp % 15 === 0){console.log("******** VAN 15, HACEMOS PAUSA DE 10 SEGUNDOS ********"); await sleep(10000);} //
|
||||||
|
console.log(`============= Mandamos el mensaje ${sp} ==============`);
|
||||||
|
var elTextoDelMensaje = caritas + " *" + saludo + "amigo tendero* ❗❗👋🏻\n🕊️ *GUNA* trae para ti dinámicas digitales, con las que podrás participar para ganar increíbles premios. 🏆💸💰\nSigue los siguientes pasos: 😃\n*1.* 📲Sigue la página de Yo Soy Guna en Facebook en la siguiente liga ➡️ https://www.facebook.com/yosoyguna\n*2.* 👉🏻Es importante des click en el botón Me Gusta 👍\n*3.* 🧐Sigue la dinámica que publicaremos , subiendo tu foto 📸 con los siguientes #yosoyguna #gunatenderos #gunachampions\n*4.* 🥳🎉En esta misma página , podrás ver publicados los ganadores🏅 y el tiempo en que serán elegidos. 💲 Además de tener acceso a increíbles promociones 🤑";
|
||||||
|
sendMedia(client, masivo[sp].numero+"@c.us", "envioMasivoGuna.jpg");
|
||||||
|
await sleep(500);
|
||||||
|
client.sendMessage(masivo[sp].numero+"@c.us", remplazos(elTextoDelMensaje, client));
|
||||||
|
// client.sendMessage(masivo[i].numero+"@c.us", "Este es un mensaje de prueba para *"+masivo[i].numero+"*, HORA:*"+new Date().toLocaleTimeString()+"*");
|
||||||
|
console.log(`Esperamos ${rnd} segundos...`);
|
||||||
|
await sleep(rnd*1000);
|
||||||
}
|
}
|
||||||
async function retardo() {
|
console.log('Done');
|
||||||
for (sp=0;sp<masivo.length;sp++) {
|
}
|
||||||
console.log(masivo[sp].numero+"@c.us");
|
retardo();
|
||||||
var rnd = getRandomInt(1,7); // Random entre 1 y 6 segundos.
|
|
||||||
if(rnd==1||rnd==4){saludo = "Hola ";}
|
|
||||||
else if(rnd==2||rnd==5){saludo = "Saludos ";}
|
|
||||||
else {saludo = "%saludo% ";}
|
|
||||||
if(rnd==1){caritas = "👨🏻🦰👩🏻🦰";}
|
|
||||||
else if(rnd==2){caritas = "👩🏻🦰👨🏻🦰";}
|
|
||||||
else if(rnd==3){caritas = "🧔🏽👧🏽";}
|
|
||||||
else if(rnd==4){caritas = "👧🏽🧔🏽";}
|
|
||||||
else if(rnd==5){caritas = "👩🏻🦰🧔🏽";}
|
|
||||||
else if(rnd==6){caritas = "🧔🏽👩🏻🦰";}
|
|
||||||
if(sp % 15 === 0){console.log("******** VAN 15, HACEMOS PAUSA DE 10 SEGUNDOS ********"); await sleep(10000);} //
|
|
||||||
console.log(`============= Mandamos el mensaje ${sp} ==============`);
|
|
||||||
var elTextoDelMensaje = caritas + " *" + saludo + "amigo tendero* ❗❗👋🏻\n🕊️ *GUNA* trae para ti dinámicas digitales, con las que podrás participar para ganar increíbles premios. 🏆💸💰\nSigue los siguientes pasos: 😃\n*1.* 📲Sigue la página de Yo Soy Guna en Facebook en la siguiente liga ➡️ https://www.facebook.com/yosoyguna\n*2.* 👉🏻Es importante des click en el botón Me Gusta 👍\n*3.* 🧐Sigue la dinámica que publicaremos , subiendo tu foto 📸 con los siguientes #yosoyguna #gunatenderos #gunachampions\n*4.* 🥳🎉En esta misma página , podrás ver publicados los ganadores🏅 y el tiempo en que serán elegidos. 💲 Además de tener acceso a increíbles promociones 🤑";
|
|
||||||
sendMedia(client, masivo[sp].numero+"@c.us", "envioMasivoGuna.jpg");
|
|
||||||
await sleep(500);
|
|
||||||
client.sendMessage(masivo[sp].numero+"@c.us", remplazos(elTextoDelMensaje, client));
|
|
||||||
// client.sendMessage(masivo[i].numero+"@c.us", "Este es un mensaje de prueba para *"+masivo[i].numero+"*, HORA:*"+new Date().toLocaleTimeString()+"*");
|
|
||||||
console.log(`Esperamos ${rnd} segundos...`);
|
|
||||||
await sleep(rnd*1000);
|
|
||||||
}
|
|
||||||
console.log('Done');
|
|
||||||
}
|
|
||||||
retardo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomInt(min, max) {
|
function getRandomInt(min, max) {
|
||||||
@@ -632,8 +673,6 @@ if(message=='/spam'){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Este evento es necesario para el filtro de Dialogflow
|
* Este evento es necesario para el filtro de Dialogflow
|
||||||
*/
|
*/
|
||||||
@@ -745,6 +784,10 @@ function chkFile(theFile){ //MOD by CHV - Agregamos para revisar que exista el a
|
|||||||
function traeMensajes(from){ //MOD by CHV - Agregamos para traer el historial de mensajes
|
function traeMensajes(from){ //MOD by CHV - Agregamos para traer el historial de mensajes
|
||||||
var histlMsjs = {};
|
var histlMsjs = {};
|
||||||
var hayHistorial = (chkFile(`${__dirname}/chats/`+from+".json"));
|
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){
|
if(hayHistorial){
|
||||||
let rawdata = fs.readFileSync(`./chats/${from}.json`);
|
let rawdata = fs.readFileSync(`./chats/${from}.json`);
|
||||||
let elHistorial = JSON.parse(rawdata);
|
let elHistorial = JSON.parse(rawdata);
|
||||||
@@ -755,6 +798,10 @@ function traeMensajes(from){ //MOD by CHV - Agregamos para traer el historial de
|
|||||||
// console.log("Mensajes:"+totalMsjs+", Ultimo:"+JSON.stringify(ultimoMensaje));
|
// console.log("Mensajes:"+totalMsjs+", Ultimo:"+JSON.stringify(ultimoMensaje));
|
||||||
// console.log("Anterior:"+JSON.stringify(mensajeAnterior));
|
// 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;
|
return histlMsjs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -351,7 +351,7 @@
|
|||||||
"pasoRequerido":"soporte"
|
"pasoRequerido":"soporte"
|
||||||
},
|
},
|
||||||
"gunaCats":{
|
"gunaCats":{
|
||||||
"keywords": ["/guna", "/demoventa", "/demoguna"],
|
"keywords": ["/guna", "/demoventa", "/demoguna", "⬅️ cambiar categoria"],
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
"Mensaje de getGunaCats"
|
"Mensaje de getGunaCats"
|
||||||
],
|
],
|
||||||
@@ -400,7 +400,7 @@
|
|||||||
"pasoRequerido":"gunaProdsAgrega"
|
"pasoRequerido":"gunaProdsAgrega"
|
||||||
},
|
},
|
||||||
"gunaComprarMas":{
|
"gunaComprarMas":{
|
||||||
"keywords": ["Agregar productos"],
|
"keywords": "*agregar productos",
|
||||||
"replyMessage":[
|
"replyMessage":[
|
||||||
"Quiero comprar mas."
|
"Quiero comprar mas."
|
||||||
],
|
],
|
||||||
@@ -408,5 +408,15 @@
|
|||||||
"media":null,
|
"media":null,
|
||||||
"trigger":null,
|
"trigger":null,
|
||||||
"pasoRequerido":"gunaProdsCantidad"
|
"pasoRequerido":"gunaProdsCantidad"
|
||||||
|
},
|
||||||
|
"gunaTerminaCompra":{
|
||||||
|
"keywords": "*terminar",
|
||||||
|
"replyMessage":[
|
||||||
|
"Termina la compra"
|
||||||
|
],
|
||||||
|
"funcion":"terminaCompra",
|
||||||
|
"media":null,
|
||||||
|
"trigger":null,
|
||||||
|
"pasoRequerido":"gunaProdsCantidad"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user