fix(cli): endflow

This commit is contained in:
Leifer Mendez
2023-01-28 18:41:58 +01:00
parent f201c5097b
commit 1c66f178a5
3 changed files with 120 additions and 4 deletions

View File

@@ -98,10 +98,15 @@ class CoreClass {
}
// 📄 Finalizar flujo
const endFlow = async () => {
const endFlow = async (message = null) => {
prevMsg = null
endFlowFlag = true
clearQueue()
if (message)
this.sendProviderAndSave(from, {
...prevMsg,
answer: message ?? prevMsg.answer,
})
return
}
@@ -199,7 +204,7 @@ class CoreClass {
}
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
if (prevMsg?.options?.nested?.length) {
if (!endFlowFlag && prevMsg?.options?.nested?.length) {
const nestedRef = prevMsg.options.nested
const flowStandalone = nestedRef.map((f) => ({
...nestedRef.find((r) => r.refSerialize === f.refSerialize),
@@ -212,7 +217,7 @@ class CoreClass {
}
// 📄🤘(tiene return) Si el mensaje previo implementa capture
if (!prevMsg?.options?.nested?.length) {
if (!endFlowFlag && !prevMsg?.options?.nested?.length) {
const typeCapture = typeof prevMsg?.options?.capture
if (typeCapture === 'boolean' && fallBackFlag) {

View File

@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/bot",
"version": "0.0.84-alpha.0",
"version": "0.0.86-alpha.0",
"description": "",
"main": "./lib/bundle.bot.cjs",
"scripts": {