mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-18 03:29:15 +00:00
fix(bot): ⚡ working callback Phase 1
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user