fix(bot): working callback Phase 1

This commit is contained in:
Leifer Mendez
2022-12-30 14:18:22 +01:00
parent c62af73c16
commit 952ce86ffa
4 changed files with 36 additions and 43 deletions

View File

@@ -1,4 +1,5 @@
const { toSerialize } = require('./methods/toSerialize')
const { flatObject } = require('../utils/flattener')
class FlowClass {
allCallbacks = []
@@ -8,7 +9,8 @@ class FlowClass {
if (!Array.isArray(_flow)) throw new Error('Esto debe ser un ARRAY')
this.flowRaw = _flow
this.allCallbacks = this.parseCallBacks(this.flowRaw)
this.allCallbacks = flatObject(_flow)
console.log('[🙌🙌🙌]', this.allCallbacks)
const mergeToJsonSerialize = Object.keys(_flow)
.map((indexObjectFlow) => _flow[indexObjectFlow].toJson())
@@ -17,16 +19,6 @@ class FlowClass {
this.flowSerialize = toSerialize(mergeToJsonSerialize)
}
/**
* Buscar y aplanar todos los callbacks
* @param {*} inFlow
*/
parseCallBacks = (inFlow) =>
inFlow
.map((cbIn) => cbIn.ctx.callbacks)
.flat(2)
.map((c, i) => ({ callback: c?.callback, index: i }))
find = (keyOrWord, symbol = false, overFlow = null) => {
keyOrWord = `${keyOrWord}`
let capture = false