fix(bot): 🚑 fix callback functions

This commit is contained in:
Leifer Mendez
2022-12-19 11:45:39 +01:00
parent b4aea18b63
commit 964a074aa4
3 changed files with 41 additions and 10 deletions

View File

@@ -92,14 +92,25 @@ class CoreClass {
return refToContinue
}
// 📄 [options: callback]: Si se tiene un callback se ejecuta
if (!fallBackFlag && refToContinue && prevMsg?.options?.callback) {
const indexFlow = this.flowClass.findIndexByRef(refToContinue?.ref)
// 📄 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(messageInComming, {
fallBack,
})
}
// 📄 [options: callback]: Si se tiene un callback se ejecuta
if (!fallBackFlag) {
if (refToContinue && prevMsg?.options?.callback) {
cbEveryCtx(refToContinue?.ref)
} else {
for (const ite of this.flowClass.find(body)) {
cbEveryCtx(ite?.ref)
}
}
}
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
if (!fallBackFlag && prevMsg?.options?.nested?.length) {
const nestedRef = prevMsg.options.nested