mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
Merge pull request #526 from codigoencasa/506-concatenación-flowdynamic
506 concatenación flowdynamic
This commit is contained in:
@@ -117,6 +117,7 @@ class CoreClass {
|
||||
|
||||
// 📄 [options: flowDynamic]: esta funcion se encarga de responder un array de respuesta esta limitado a 5 mensajes
|
||||
// para evitar bloque de whatsapp
|
||||
|
||||
const flowDynamic = async (
|
||||
listMsg = [],
|
||||
optListMsg = { limit: 5, fallback: false }
|
||||
@@ -126,15 +127,21 @@ class CoreClass {
|
||||
|
||||
fallBackFlag = optListMsg.fallback
|
||||
const parseListMsg = listMsg
|
||||
.map(({ body }, index) =>
|
||||
toCtx({
|
||||
.map((opt, index) => {
|
||||
const body = typeof opt === 'string' ? opt : opt.body
|
||||
const media = opt?.media ?? null
|
||||
const buttons = opt?.buttons ?? []
|
||||
|
||||
return toCtx({
|
||||
body,
|
||||
from,
|
||||
keyword: null,
|
||||
index,
|
||||
options: { media, buttons },
|
||||
})
|
||||
)
|
||||
})
|
||||
.slice(0, optListMsg.limit)
|
||||
|
||||
for (const msg of parseListMsg) {
|
||||
await this.sendProviderAndSave(from, msg)
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ const { generateRef, generateRefSerialize } = require('../../utils/hash')
|
||||
* @param options {media:string, buttons:[], capture:true default false}
|
||||
* @returns
|
||||
*/
|
||||
const toCtx = ({ body, from, prevRef, index }) => {
|
||||
const toCtx = ({ body, from, prevRef, options = {}, index }) => {
|
||||
return {
|
||||
ref: generateRef(),
|
||||
keyword: prevRef,
|
||||
answer: body,
|
||||
options: {},
|
||||
options: options ?? {},
|
||||
from,
|
||||
refSerialize: generateRefSerialize({ index, answer: body }),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user