@bot-whatsapp/bot
Advanced tools
Comparing version 0.0.24-alpha.0 to 0.0.25-alpha.0
@@ -61,9 +61,9 @@ const { toCtx } = require('../io/methods') | ||
/** | ||
* | ||
* @param {*} messageInComming | ||
* GLOSSARY.md | ||
* @param {*} messageCtxInComming | ||
* @returns | ||
*/ | ||
handleMsg = async (messageInComming) => { | ||
logger.log(`[handleMsg]: `, messageInComming) | ||
const { body, from } = messageInComming | ||
handleMsg = async (messageCtxInComming) => { | ||
logger.log(`[handleMsg]: `, messageCtxInComming) | ||
const { body, from } = messageCtxInComming | ||
let msgToSend = [] | ||
@@ -96,8 +96,22 @@ let fallBackFlag = false | ||
// 📄 Se encarga de revisar si el contexto del mensaje tiene callback y ejecutarlo | ||
const cbEveryCtx = (inRef) => { | ||
const indexFlow = this.flowClass.findIndexByRef(inRef) | ||
this.flowClass.allCallbacks[indexFlow].callback( | ||
messageCtxInComming, | ||
{ | ||
fallBack, | ||
} | ||
) | ||
} | ||
// 📄 [options: callback]: Si se tiene un callback se ejecuta | ||
if (!fallBackFlag && refToContinue && prevMsg?.options?.callback) { | ||
const indexFlow = this.flowClass.findIndexByRef(refToContinue?.ref) | ||
this.flowClass.allCallbacks[indexFlow].callback(messageInComming, { | ||
fallBack, | ||
}) | ||
if (!fallBackFlag) { | ||
if (refToContinue && prevMsg?.options?.callback) { | ||
cbEveryCtx(refToContinue?.ref) | ||
} else { | ||
for (const ite of this.flowClass.find(body)) { | ||
cbEveryCtx(ite?.ref) | ||
} | ||
} | ||
} | ||
@@ -104,0 +118,0 @@ |
@@ -34,6 +34,3 @@ const { generateRef } = require('../../utils/hash') | ||
const callback = | ||
typeof cb === 'function' | ||
? cb | ||
: () => console.log('Callback no definida') | ||
const callback = typeof cb === 'function' ? cb : () => null | ||
@@ -40,0 +37,0 @@ const lastCtx = inCtx.hasOwnProperty('ctx') ? inCtx.ctx : inCtx |
{ | ||
"name": "@bot-whatsapp/bot", | ||
"version": "0.0.24-alpha.0", | ||
"version": "0.0.25-alpha.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/bundle.bot.cjs", |
Sorry, the diff of this file is not supported yet
36863
1103