mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 04:29:16 +00:00
fix(bot): 🐛 flowDynamic stranger behaviour
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
|
/packages/repl
|
||||||
/packages/*/starters
|
/packages/*/starters
|
||||||
/packages/*/node_modules
|
/packages/*/node_modules
|
||||||
/packages/*/dist
|
/packages/*/dist
|
||||||
|
|||||||
@@ -89,14 +89,18 @@ class CoreClass {
|
|||||||
|
|
||||||
// 📄 Esta funcion se encarga de enviar un array de mensajes dentro de este ctx
|
// 📄 Esta funcion se encarga de enviar un array de mensajes dentro de este ctx
|
||||||
const sendFlow = async (messageToSend, numberOrId) => {
|
const sendFlow = async (messageToSend, numberOrId) => {
|
||||||
|
// [1 Paso] esto esta bien!
|
||||||
|
if (prevMsg?.options?.capture) await cbEveryCtx(prevMsg?.ref)
|
||||||
|
|
||||||
const queue = []
|
const queue = []
|
||||||
for (const ctxMessage of messageToSend) {
|
for (const ctxMessage of messageToSend) {
|
||||||
const delayMs = ctxMessage?.options?.delay || 0
|
const delayMs = ctxMessage?.options?.delay || 0
|
||||||
if (delayMs) await delay(delayMs)
|
if (delayMs) await delay(delayMs)
|
||||||
QueuePrincipal.enqueue(() =>
|
QueuePrincipal.enqueue(() =>
|
||||||
Promise.all([
|
Promise.all([
|
||||||
this.sendProviderAndSave(numberOrId, ctxMessage),
|
this.sendProviderAndSave(numberOrId, ctxMessage).then(
|
||||||
resolveCbEveryCtx(ctxMessage),
|
() => resolveCbEveryCtx(ctxMessage)
|
||||||
|
),
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -139,7 +143,6 @@ class CoreClass {
|
|||||||
|
|
||||||
// 📄 Se encarga de revisar si el contexto del mensaje tiene callback o fallback
|
// 📄 Se encarga de revisar si el contexto del mensaje tiene callback o fallback
|
||||||
const resolveCbEveryCtx = async (ctxMessage) => {
|
const resolveCbEveryCtx = async (ctxMessage) => {
|
||||||
if (prevMsg?.options?.capture) return cbEveryCtx(prevMsg?.ref)
|
|
||||||
if (!ctxMessage?.options?.capture)
|
if (!ctxMessage?.options?.capture)
|
||||||
return await cbEveryCtx(ctxMessage?.ref)
|
return await cbEveryCtx(ctxMessage?.ref)
|
||||||
}
|
}
|
||||||
@@ -153,17 +156,6 @@ class CoreClass {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prevMsg?.ref) resolveCbEveryCtx(prevMsg)
|
|
||||||
|
|
||||||
// 📄 [options: callback]: Si se tiene un callback se ejecuta
|
|
||||||
//TODO AQUI
|
|
||||||
// if (!fallBackFlag) {
|
|
||||||
// if (prevMsg?.options?.capture) cbEveryCtx(prevMsg?.ref)
|
|
||||||
// for (const ite of this.flowClass.find(body)) {
|
|
||||||
// if (!ite?.options?.capture) cbEveryCtx(ite?.ref)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
|
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
|
||||||
if (!fallBackFlag && prevMsg?.options?.nested?.length) {
|
if (!fallBackFlag && prevMsg?.options?.nested?.length) {
|
||||||
const nestedRef = prevMsg.options.nested
|
const nestedRef = prevMsg.options.nested
|
||||||
@@ -173,11 +165,6 @@ class CoreClass {
|
|||||||
|
|
||||||
msgToSend = this.flowClass.find(body, false, flowStandalone) || []
|
msgToSend = this.flowClass.find(body, false, flowStandalone) || []
|
||||||
|
|
||||||
// //TODO AQUI
|
|
||||||
// for (const ite of msgToSend) {
|
|
||||||
// cbEveryCtx(ite?.ref)
|
|
||||||
// }
|
|
||||||
|
|
||||||
sendFlow(msgToSend, from)
|
sendFlow(msgToSend, from)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user