mirror of
https://github.com/cheveguerra/botLeiferAurik-Mod_2.0.git
synced 2026-04-19 12:19:19 +00:00
format
This commit is contained in:
@@ -35,7 +35,6 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
|||||||
elNum = num //MOD by CHV -
|
elNum = num //MOD by CHV -
|
||||||
if(siguientePaso.find(k => k.numero.includes(elNum))){
|
if(siguientePaso.find(k => k.numero.includes(elNum))){
|
||||||
console.log("siguientePaso="+siguientePaso.find(k => k.numero.includes(elNum))["numero"], siguientePaso.find(k => k.numero.includes(elNum))["va"])
|
console.log("siguientePaso="+siguientePaso.find(k => k.numero.includes(elNum))["numero"], siguientePaso.find(k => k.numero.includes(elNum))["va"])
|
||||||
// ultimoStep = siguientePaso.find(k => k.numero.includes(elNum))["va"]
|
|
||||||
pasoAnterior[elNum] = siguientePaso.find(k => k.numero.includes(elNum))["va"] //Asignamos pasoAnterior al número.
|
pasoAnterior[elNum] = siguientePaso.find(k => k.numero.includes(elNum))["va"] //Asignamos pasoAnterior al número.
|
||||||
siguientePaso.splice(siguientePaso.indexOf(elNum), 1)
|
siguientePaso.splice(siguientePaso.indexOf(elNum), 1)
|
||||||
console.log("******************** "+siguientePaso.find(k => k.numero.includes(elNum)))
|
console.log("******************** "+siguientePaso.find(k => k.numero.includes(elNum)))
|
||||||
@@ -103,31 +102,30 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
|||||||
var logRegEx = false
|
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 (si=0; si<stepsInitial.length;si++){
|
||||||
if(!Array.isArray(stepsInitial[i].keywords)){// Si "Keywords" NO es arreglo entonces ...
|
if(!Array.isArray(stepsInitial[si].keywords)){// Si "Keywords" NO es arreglo entonces ...
|
||||||
var coincideKeyword = null;
|
var coincideKeyword = null;
|
||||||
if(logRegEx) console.log("*** PASO=" + stepsInitial[i].key.toString() + " - REQUERIDO=" + resps[stepsInitial[i].key.toString()].pasoRequerido + " - ANTERIOR=" + pasoAnterior[elNum])
|
if(logRegEx) console.log("*** PASO=" + stepsInitial[si].key.toString() + " - REQUERIDO=" + resps[stepsInitial[si].key.toString()].pasoRequerido + " - ANTERIOR=" + pasoAnterior[elNum])
|
||||||
//Si NO hay paso requerido, o el paso requerido es IGUAL al paso anterior, entonces ...
|
//Si NO hay paso requerido, o el paso requerido es IGUAL al paso anterior, entonces ...
|
||||||
if(resps[stepsInitial[i].key.toString()].pasoRequerido == undefined || resps[stepsInitial[i].key.toString()].pasoRequerido == pasoAnterior[elNum]){
|
if(resps[stepsInitial[si].key.toString()].pasoRequerido == undefined || resps[stepsInitial[si].key.toString()].pasoRequerido == pasoAnterior[elNum]){
|
||||||
var tempKeyword = "";
|
var tempKeyword = "";
|
||||||
if(logRegEx) console.log(" - El paso requerido COINCIDE con el anterior, o NO hay paso requerido.")
|
if(logRegEx) console.log(" - El paso requerido COINCIDE con el anterior, o NO hay paso requerido.")
|
||||||
if (stepsInitial[i].keywords == "%solo_correos%"){
|
if (stepsInitial[si].keywords == "%solo_correos%"){
|
||||||
if(logRegEx) console.log("solo_correos")
|
if(logRegEx) console.log("solo_correos")
|
||||||
tempKeyword = "[a-zA-Z0-9]+[_a-zA-Z0-9\.-]*[a-zA-Z0-9]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+[\.][a-zA-Z]{2,12})"}
|
tempKeyword = "[a-zA-Z0-9]+[_a-zA-Z0-9\.-]*[a-zA-Z0-9]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+[\.][a-zA-Z]{2,12})"}
|
||||||
else {
|
else {
|
||||||
tempKeyword = stepsInitial[i].keywords.toString().replaceAll("*",".*")
|
tempKeyword = stepsInitial[si].keywords.toString().replaceAll("*",".*")
|
||||||
}
|
}
|
||||||
coincideKeyword = message.match(tempKeyword); // Verdadero cuando el mensaje COINCIDE con la palabre clave.
|
coincideKeyword = message.match(tempKeyword); // Verdadero cuando el mensaje COINCIDE con la palabre clave.
|
||||||
if (coincideKeyword != null){ //Si el mensaje COINCIDE con la palabra clave.
|
if (coincideKeyword != null){ //Si el mensaje COINCIDE con la palabra clave.
|
||||||
if(logRegEx) console.log(" - - El mensaje COINCIDE con el keyword")
|
if(logRegEx) console.log(" - - El mensaje COINCIDE con el keyword")
|
||||||
key = stepsInitial[i].key;
|
key = stepsInitial[si].key;
|
||||||
//Si HAY paso requerido, y el paso requerido es DIFERENTE del paso anterior, entonces ...
|
//Si HAY paso requerido, y el paso requerido es DIFERENTE del paso anterior, entonces ...
|
||||||
if(resps[stepsInitial[i].key].pasoRequerido != null && resps[stepsInitial[i].key].pasoRequerido != pasoAnterior[elNum]){
|
if(resps[stepsInitial[si].key].pasoRequerido != null && resps[stepsInitial[si].key].pasoRequerido != pasoAnterior[elNum]){
|
||||||
key=null
|
key=null
|
||||||
if(logRegEx) console.log(" - - - Hay paso requerido y NO coincide con en paso anterior")
|
if(logRegEx) console.log(" - - - Hay paso requerido y NO COINCIDE con en paso anterior")
|
||||||
}
|
}
|
||||||
// console.log("KEY="+key+" - coincideKeyword="+coincideKeyword);
|
if(resps[stepsInitial[si].key].replyMessage.toString().search("/URL") > -1){
|
||||||
if(resps[stepsInitial[i].key].replyMessage.toString().search("/URL") > -1){
|
|
||||||
if(logRegEx) console.log("**************** HAY URL ****************")
|
if(logRegEx) console.log("**************** HAY URL ****************")
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -151,16 +149,12 @@ const get = (message, num) => new Promise((resolve, reject) => { //MOD by CHV -
|
|||||||
if(resps[key]!=undefined){VA = resps[key].goto}else{VA=null}
|
if(resps[key]!=undefined){VA = resps[key].goto}else{VA=null}
|
||||||
cumplePasoRequerido(key);
|
cumplePasoRequerido(key);
|
||||||
_vamosA = VA;
|
_vamosA = VA;
|
||||||
console.log("cumplePasoPrevio[elNum]=", cumplePasoPrevio[elNum])
|
if(logRegEx) console.log("cumplePasoPrevio[elNum]=", cumplePasoPrevio[elNum], "_vamosA=", _vamosA)
|
||||||
|
|
||||||
if(_vamosA != "" && _vamosA != undefined && cumplePasoPrevio[elNum] == true){
|
if(_vamosA != "" && _vamosA != undefined && cumplePasoPrevio[elNum] == true){
|
||||||
console.log("ASIGNAMOS _VAMOSA = " + _vamosA);
|
if(logRegEx) console.log("ASIGNAMOS _VAMOSA = " + _vamosA);
|
||||||
pasoAnterior[elNum] = _vamosA;
|
pasoAnterior[elNum] = _vamosA;
|
||||||
}
|
}
|
||||||
_vamosA = "";
|
_vamosA = "";
|
||||||
// console.log("MESSAGE: "+message);
|
|
||||||
// console.log("KEY: "+key);
|
|
||||||
// console.log("RESPONSE: "+response);
|
|
||||||
if(cumplePasoPrevio[elNum]) {resolve(response);}
|
if(cumplePasoPrevio[elNum]) {resolve(response);}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +404,7 @@ function remplazos(elTexto, extraInfo){
|
|||||||
cumplePasoPrevio[elNum] = true;
|
cumplePasoPrevio[elNum] = true;
|
||||||
}
|
}
|
||||||
pasoAnterior[elNum] = step
|
pasoAnterior[elNum] = step
|
||||||
ultimoPaso = pasoRequerido;
|
// ultimoPaso = pasoRequerido;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
17
app.js
17
app.js
@@ -179,7 +179,7 @@ listenMessage = () => client.on('message', async msg => {
|
|||||||
const step = await getMessages(message, from);
|
const step = await getMessages(message, from);
|
||||||
client.theMsg['step'] = step
|
client.theMsg['step'] = step
|
||||||
if (step) {
|
if (step) {
|
||||||
console.log("Entramos a STEP")
|
// console.log("Entramos a STEP")
|
||||||
const response = await responseMessages(step);
|
const response = await responseMessages(step);
|
||||||
client.theMsg['trigger'] = response.trigger
|
client.theMsg['trigger'] = response.trigger
|
||||||
var resps = require('./flow/response.json');
|
var resps = require('./flow/response.json');
|
||||||
@@ -604,16 +604,15 @@ listenMessage = () => client.on('message', async msg => {
|
|||||||
/**
|
/**
|
||||||
* Si quieres enviar botones o listas
|
* Si quieres enviar botones o listas
|
||||||
*/
|
*/
|
||||||
if(response.hasOwnProperty('actions')){
|
if(response.hasOwnProperty('actions')){
|
||||||
const { actions } = response;
|
const { actions } = response;
|
||||||
// console.log("++++++++++++++++++++++++++++ SEND MESG BUTTON/LIST +++++++++++++++++++++++++++++++++++");
|
// console.log("++++++++++++++++++++++++++++ SEND MESG BUTTON/LIST +++++++++++++++++++++++++++++++++++");
|
||||||
if(actions['sections'] === undefined){ //Botones
|
if(actions['sections'] === undefined){ //Botones
|
||||||
console.log("Botones")
|
// console.log("Botones")
|
||||||
await sendMessageButton(client, from, null, actions);
|
await sendMessageButton(client, from, null, actions);
|
||||||
}
|
}
|
||||||
else { //Listas
|
else { //Listas
|
||||||
console.log("Listas")
|
// console.log("Listas")
|
||||||
// console.log(actions)
|
|
||||||
await sendMessageList(client, from, null, actions);
|
await sendMessageList(client, from, null, actions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user