mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
Merge branch 'codigoencasa:dev' into dev
This commit is contained in:
@@ -2,5 +2,6 @@
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 4,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
"singleQuote": true,
|
||||
"printWidth": 120
|
||||
}
|
||||
|
||||
30
CHANGELOG.md
30
CHANGELOG.md
@@ -2,6 +2,36 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.1.19](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.18...v0.1.19) (2023-01-29)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* :fire: bailey add media ([eab39e4](https://github.com/leifermendez/bot-whatsapp/commit/eab39e4ac06fd46f1a4671f8c15d1456b4400b97))
|
||||
* :zap: more feature ([e19c3a2](https://github.com/leifermendez/bot-whatsapp/commit/e19c3a25a40259c74b4add9635af4844907eed26))
|
||||
* **provider:** :rocket: fix issues in providers venom and wwebjs ([cbe438b](https://github.com/leifermendez/bot-whatsapp/commit/cbe438b77854e8df48b9dafaf7a837d21124ac5f))
|
||||
* **provider:** :rocket: fix provider ([0ad4c58](https://github.com/leifermendez/bot-whatsapp/commit/0ad4c58457b548dc41c0f9e8470d59c48de7b95a))
|
||||
* **provider:** :rocket: fix provider ([f8c7184](https://github.com/leifermendez/bot-whatsapp/commit/f8c7184487065443ab10f77aaf585e8bd63ca441))
|
||||
* **provider:** :rocket: fix provider ([b2afa45](https://github.com/leifermendez/bot-whatsapp/commit/b2afa45352a7ab1f5d9775f3c1fde475bd8ca204))
|
||||
* **provider:** :rocket: fix provider venom and wwebjs ([dcb0566](https://github.com/leifermendez/bot-whatsapp/commit/dcb0566d2bc3da40cd0c71554bb5ea0ec115d9ca))
|
||||
* **provider:** :rocket: implements all send media to venom provider ([9dd7c02](https://github.com/leifermendez/bot-whatsapp/commit/9dd7c02b6a5474aff063f7d6be0ca8519504b93c))
|
||||
* **provider:** :rocket: send file wwebjs ([6ff1a3a](https://github.com/leifermendez/bot-whatsapp/commit/6ff1a3a980196c01c66ed04ee07d0e7e57256504))
|
||||
* **provider:** :zap: bailey add send file video audio ([14d1a61](https://github.com/leifermendez/bot-whatsapp/commit/14d1a61fa259c09135c37c55bd79e97c9c8367e4))
|
||||
* **provider:** :zap: venom wweb ([fd2847a](https://github.com/leifermendez/bot-whatsapp/commit/fd2847aea0db17a0bdf33b5bca67a4cb8db2da16))
|
||||
* **provider:** :zap: venom wweb ([f95331d](https://github.com/leifermendez/bot-whatsapp/commit/f95331d3dc70e76a3dfbe4c8d24059f0e7a164ef))
|
||||
* **provider:** 🚀 implements all send media to venom provider ([bd7d150](https://github.com/leifermendez/bot-whatsapp/commit/bd7d150c047af41fdbb47f0a50a21e82cd79ee85))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bot:** :fire: endFlow with ctx ([f6114af](https://github.com/leifermendez/bot-whatsapp/commit/f6114affadfbc324536a86167d1fdfe8da3c8de6))
|
||||
* **bot:** :fire: endFlow with ctx ([b655ae4](https://github.com/leifermendez/bot-whatsapp/commit/b655ae449e7958ea940d8cc3c678fd66f60b6385))
|
||||
* **bot:** :zap: endFlow butons ([87a4203](https://github.com/leifermendez/bot-whatsapp/commit/87a4203cd5b88f566387a76d586248e4265d6e4e))
|
||||
* **bot:** :zap: fix fallback refactor ([e22780d](https://github.com/leifermendez/bot-whatsapp/commit/e22780d3faba94f71a70f1f201a20690608fa5bf))
|
||||
* **cli:** :zap: endflow ([1c66f17](https://github.com/leifermendez/bot-whatsapp/commit/1c66f178a56d284bb8cb9df5ca17685c7e5d1ddd))
|
||||
* **cli:** :zap: refactor fallback in child flow ([b33e346](https://github.com/leifermendez/bot-whatsapp/commit/b33e34692d3abcb6874308a9be79f74be4a2c3a8))
|
||||
* **cli:** :zap: refactor fallback in child flow ([8da4b20](https://github.com/leifermendez/bot-whatsapp/commit/8da4b204b41125b5d0fa0aee4fa87c1f5faf5568))
|
||||
|
||||
### [0.1.18](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.17...v0.1.18) (2023-01-24)
|
||||
|
||||
|
||||
|
||||
81
README.md
81
README.md
@@ -1,8 +1,7 @@
|
||||
# Chatbot Library
|
||||

|
||||
[](http://commitizen.github.io/cz-cli/)
|
||||
[](https://github.com/codigoencasa/bot-whatsapp/actions/workflows/releases.yml)
|
||||
|
||||
[](https://link.codigoencasa.com/DISCORD)
|
||||
|
||||
<p align="center">
|
||||
<img width="300" src="https://i.imgur.com/Oauef6t.png">
|
||||
@@ -34,6 +33,13 @@ Entiende más a fondo sus funcionalidades explicadas en nuestra documentación.
|
||||
<!-- readme: collaborators,contributors -start -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/cheveguerra">
|
||||
<img src="https://avatars.githubusercontent.com/u/5891114?v=4" width="50;" alt="cheveguerra"/>
|
||||
<br />
|
||||
<sub><b>Jose Alberto Guerra Ugalde</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/leifermendez">
|
||||
<img src="https://avatars.githubusercontent.com/u/15802366?v=4" width="50;" alt="leifermendez"/>
|
||||
@@ -62,6 +68,21 @@ Entiende más a fondo sus funcionalidades explicadas en nuestra documentación.
|
||||
<sub><b>Leifer Mendez</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/danielcasta0398">
|
||||
<img src="https://avatars.githubusercontent.com/u/98791147?v=4" width="50;" alt="danielcasta0398"/>
|
||||
<br />
|
||||
<sub><b>Juan Daniel Castaño</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/marianarolfo">
|
||||
<img src="https://avatars.githubusercontent.com/u/68322254?v=4" width="50;" alt="marianarolfo"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/HKong31">
|
||||
<img src="https://avatars.githubusercontent.com/u/113340082?v=4" width="50;" alt="HKong31"/>
|
||||
@@ -75,8 +96,14 @@ Entiende más a fondo sus funcionalidades explicadas en nuestra documentación.
|
||||
<br />
|
||||
<sub><b>Zvi</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/JosephVTX">
|
||||
<img src="https://avatars.githubusercontent.com/u/91026290?v=4" width="50;" alt="JosephVTX"/>
|
||||
<br />
|
||||
<sub><b>Joseph Vega Callupe</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Gonzalito87">
|
||||
<img src="https://avatars.githubusercontent.com/u/100331586?v=4" width="50;" alt="Gonzalito87"/>
|
||||
@@ -84,6 +111,42 @@ Entiende más a fondo sus funcionalidades explicadas en nuestra documentación.
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/devrlbusiness">
|
||||
<img src="https://avatars.githubusercontent.com/u/66280283?v=4" width="50;" alt="devrlbusiness"/>
|
||||
<br />
|
||||
<sub><b>Developer RL Business</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Gregoriotecnico">
|
||||
<img src="https://avatars.githubusercontent.com/u/118696506?v=4" width="50;" alt="Gregoriotecnico"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/jlferrete">
|
||||
<img src="https://avatars.githubusercontent.com/u/36698913?v=4" width="50;" alt="jlferrete"/>
|
||||
<br />
|
||||
<sub><b>Jose Luis Ferrete Olarte</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/lisandroprada">
|
||||
<img src="https://avatars.githubusercontent.com/u/7232326?v=4" width="50;" alt="lisandroprada"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/6rak0">
|
||||
<img src="https://avatars.githubusercontent.com/u/12260031?v=4" width="50;" alt="6rak0"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/tonyvazgar">
|
||||
<img src="https://avatars.githubusercontent.com/u/21047090?v=4" width="50;" alt="tonyvazgar"/>
|
||||
@@ -91,20 +154,14 @@ Entiende más a fondo sus funcionalidades explicadas en nuestra documentación.
|
||||
<sub><b>Luis Antonio Vázquez García</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/ulisesvina">
|
||||
<img src="https://avatars.githubusercontent.com/u/20508563?v=4" width="50;" alt="ulisesvina"/>
|
||||
<br />
|
||||
<sub><b>Ulises Viña</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/rrruuuyyy">
|
||||
<img src="https://avatars.githubusercontent.com/u/33061671?v=4" width="50;" alt="rrruuuyyy"/>
|
||||
<br />
|
||||
<sub><b>Rodrigo Mendoza Cabrera</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/yond1994">
|
||||
<img src="https://avatars.githubusercontent.com/u/47557263?v=4" width="50;" alt="yond1994"/>
|
||||
|
||||
118
__test__/05-case.test.js
Normal file
118
__test__/05-case.test.js
Normal file
@@ -0,0 +1,118 @@
|
||||
const { test } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const MOCK_DB = require('../packages/database/src/mock')
|
||||
const PROVIDER_DB = require('../packages/provider/src/mock')
|
||||
const {
|
||||
addKeyword,
|
||||
createBot,
|
||||
createFlow,
|
||||
createProvider,
|
||||
} = require('../packages/bot/index')
|
||||
|
||||
/**
|
||||
* Falsear peticion async
|
||||
* @param {*} fakeData
|
||||
* @returns
|
||||
*/
|
||||
const fakeHTTP = async (fakeData = []) => {
|
||||
await delay(5)
|
||||
const data = fakeData.map((u, i) => ({ body: `${i + 1} ${u}` }))
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
|
||||
test(`[Caso - 05] Continuar Flujo (continueFlow)`, async () => {
|
||||
const MOCK_VALUES = [
|
||||
'¿CUal es tu email?',
|
||||
'Continuamos....',
|
||||
'¿Cual es tu edad?',
|
||||
]
|
||||
const provider = createProvider(PROVIDER_DB)
|
||||
const database = new MOCK_DB()
|
||||
|
||||
const flujoPrincipal = addKeyword(['hola'])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[0],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic, fallBack }) => {
|
||||
const validation = ctx.body.includes('@')
|
||||
|
||||
if (validation) {
|
||||
const getDataFromApi = await fakeHTTP([
|
||||
'Gracias por tu email se ha validado de manera correcta',
|
||||
])
|
||||
return flowDynamic(getDataFromApi)
|
||||
}
|
||||
return fallBack(validation)
|
||||
}
|
||||
)
|
||||
.addAnswer(MOCK_VALUES[1])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[2],
|
||||
{ capture: true },
|
||||
async (ctx, { flowDynamic, fallBack }) => {
|
||||
if (ctx.body !== '18') {
|
||||
await delay(50)
|
||||
return fallBack(false, 'Ups creo que no eres mayor de edad')
|
||||
}
|
||||
return flowDynamic('Bien tu edad es correcta!')
|
||||
}
|
||||
)
|
||||
.addAnswer('Puedes pasar')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
flow: createFlow([flujoPrincipal]),
|
||||
provider,
|
||||
})
|
||||
|
||||
provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'this is not email value',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(20, 'message', {
|
||||
from: '000',
|
||||
body: 'test@test.com',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(90, 'message', {
|
||||
from: '000',
|
||||
body: '20',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(200, 'message', {
|
||||
from: '000',
|
||||
body: '18',
|
||||
})
|
||||
|
||||
await delay(1200)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
assert.is('this is not email value', getHistory[1])
|
||||
assert.is(MOCK_VALUES[0], getHistory[2])
|
||||
assert.is('test@test.com', getHistory[3])
|
||||
assert.is(
|
||||
'1 Gracias por tu email se ha validado de manera correcta',
|
||||
getHistory[4]
|
||||
)
|
||||
assert.is(MOCK_VALUES[1], getHistory[5])
|
||||
assert.is(MOCK_VALUES[2], getHistory[6])
|
||||
assert.is('20', getHistory[7])
|
||||
assert.is('Ups creo que no eres mayor de edad', getHistory[8])
|
||||
assert.is('18', getHistory[9])
|
||||
assert.is('Bien tu edad es correcta!', getHistory[10])
|
||||
assert.is('Puedes pasar', getHistory[11])
|
||||
})
|
||||
|
||||
test.run()
|
||||
|
||||
function delay(ms) {
|
||||
return new Promise((res) => setTimeout(res, ms))
|
||||
}
|
||||
111
__test__/06-case.test.js
Normal file
111
__test__/06-case.test.js
Normal file
@@ -0,0 +1,111 @@
|
||||
const { test } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const MOCK_DB = require('../packages/database/src/mock')
|
||||
const PROVIDER_DB = require('../packages/provider/src/mock')
|
||||
const {
|
||||
addKeyword,
|
||||
createBot,
|
||||
createFlow,
|
||||
createProvider,
|
||||
} = require('../packages/bot/index')
|
||||
|
||||
/**
|
||||
* Falsear peticion async
|
||||
* @param {*} fakeData
|
||||
* @returns
|
||||
*/
|
||||
const fakeHTTP = async (fakeData = []) => {
|
||||
await delay(5)
|
||||
const data = fakeData.map((u, i) => ({ body: `${i + 1} ${u}` }))
|
||||
return Promise.resolve(data)
|
||||
}
|
||||
|
||||
test(`[Caso - 06] Finalizar Flujo (endFlow)`, async () => {
|
||||
const MOCK_VALUES = [
|
||||
'¿CUal es tu email?',
|
||||
'Continuamos....',
|
||||
'¿Cual es tu edad?',
|
||||
]
|
||||
const provider = createProvider(PROVIDER_DB)
|
||||
const database = new MOCK_DB()
|
||||
|
||||
const flujoPrincipal = addKeyword(['hola'])
|
||||
.addAnswer(
|
||||
MOCK_VALUES[0],
|
||||
{
|
||||
capture: true,
|
||||
},
|
||||
async (ctx, { flowDynamic, fallBack }) => {
|
||||
const validation = ctx.body.includes('@')
|
||||
|
||||
if (validation) {
|
||||
const getDataFromApi = await fakeHTTP([
|
||||
'Gracias por tu email se ha validado de manera correcta',
|
||||
])
|
||||
return flowDynamic(getDataFromApi)
|
||||
}
|
||||
return fallBack(validation)
|
||||
}
|
||||
)
|
||||
.addAnswer(MOCK_VALUES[1], null, async (_, { endFlow }) => {
|
||||
return endFlow()
|
||||
})
|
||||
.addAnswer(
|
||||
MOCK_VALUES[2],
|
||||
{ capture: true },
|
||||
async (ctx, { flowDynamic, fallBack }) => {
|
||||
if (ctx.body !== '18') {
|
||||
await delay(50)
|
||||
return fallBack(false, 'Ups creo que no eres mayor de edad')
|
||||
}
|
||||
return flowDynamic('Bien tu edad es correcta!')
|
||||
}
|
||||
)
|
||||
.addAnswer('Puedes pasar')
|
||||
|
||||
createBot({
|
||||
database,
|
||||
flow: createFlow([flujoPrincipal]),
|
||||
provider,
|
||||
})
|
||||
|
||||
provider.delaySendMessage(0, 'message', {
|
||||
from: '000',
|
||||
body: 'hola',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(10, 'message', {
|
||||
from: '000',
|
||||
body: 'this is not email value',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(20, 'message', {
|
||||
from: '000',
|
||||
body: 'test@test.com',
|
||||
})
|
||||
|
||||
provider.delaySendMessage(90, 'message', {
|
||||
from: '000',
|
||||
body: '20',
|
||||
})
|
||||
|
||||
await delay(1200)
|
||||
const getHistory = database.listHistory.map((i) => i.answer)
|
||||
assert.is(MOCK_VALUES[0], getHistory[0])
|
||||
assert.is('this is not email value', getHistory[1])
|
||||
assert.is(MOCK_VALUES[0], getHistory[2])
|
||||
assert.is('test@test.com', getHistory[3])
|
||||
assert.is(
|
||||
'1 Gracias por tu email se ha validado de manera correcta',
|
||||
getHistory[4]
|
||||
)
|
||||
assert.is(MOCK_VALUES[1], getHistory[5])
|
||||
assert.is('20', getHistory[6])
|
||||
assert.is(undefined, getHistory[7])
|
||||
})
|
||||
|
||||
test.run()
|
||||
|
||||
function delay(ms) {
|
||||
return new Promise((res) => setTimeout(res, ms))
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/root",
|
||||
"version": "0.1.18",
|
||||
"version": "0.1.19",
|
||||
"description": "Bot de wahtsapp open source para MVP o pequeños negocios",
|
||||
"main": "app.js",
|
||||
"private": true,
|
||||
@@ -81,6 +81,7 @@
|
||||
"fs-extra": "^11.1.0",
|
||||
"git-cz": "^4.9.0",
|
||||
"husky": "^8.0.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"only-allow": "^1.1.1",
|
||||
"prettier": "^2.8.0",
|
||||
"pretty-quick": "^3.1.3",
|
||||
|
||||
@@ -71,8 +71,8 @@ class CoreClass {
|
||||
logger.log(`[handleMsg]: `, messageCtxInComming)
|
||||
const { body, from } = messageCtxInComming
|
||||
let msgToSend = []
|
||||
let fallBackFlag = false
|
||||
let endFlowFlag = false
|
||||
let fallBackFlag = false
|
||||
if (this.generalArgs.blackList.includes(from)) return
|
||||
if (!body) return
|
||||
if (!body.length) return
|
||||
@@ -91,6 +91,25 @@ class CoreClass {
|
||||
this.databaseClass.save(ctxByNumber)
|
||||
}
|
||||
|
||||
// 📄 Crar CTX de mensaje (uso private)
|
||||
const createCtxMessage = (payload = {}, index = 0) => {
|
||||
const body =
|
||||
typeof payload === 'string'
|
||||
? payload
|
||||
: payload?.body ?? payload?.answer
|
||||
const media = payload?.media ?? null
|
||||
const buttons = payload?.buttons ?? []
|
||||
const capture = payload?.capture ?? false
|
||||
|
||||
return toCtx({
|
||||
body,
|
||||
from,
|
||||
keyword: null,
|
||||
index,
|
||||
options: { media, buttons, capture },
|
||||
})
|
||||
}
|
||||
|
||||
// 📄 Limpiar cola de procesos
|
||||
const clearQueue = () => {
|
||||
QueuePrincipal.pendingPromise = false
|
||||
@@ -98,18 +117,32 @@ class CoreClass {
|
||||
}
|
||||
|
||||
// 📄 Finalizar flujo
|
||||
const endFlow = async () => {
|
||||
const endFlow = async (message = null) => {
|
||||
prevMsg = null
|
||||
endFlowFlag = true
|
||||
if (message)
|
||||
this.sendProviderAndSave(from, createCtxMessage(message))
|
||||
clearQueue()
|
||||
return
|
||||
}
|
||||
|
||||
// 📄 Esta funcion se encarga de enviar un array de mensajes dentro de este ctx
|
||||
const sendFlow = async (messageToSend, numberOrId) => {
|
||||
// [1 Paso] esto esta bien!
|
||||
// 📄 Continuar con el siguiente flujo
|
||||
const continueFlow = async () => {
|
||||
const cotinueMessage =
|
||||
this.flowClass.find(refToContinue?.ref, true) || []
|
||||
sendFlow(cotinueMessage, from, { continue: true })
|
||||
return
|
||||
}
|
||||
|
||||
// 📄 Esta funcion se encarga de enviar un array de mensajes dentro de este ctx
|
||||
const sendFlow = async (
|
||||
messageToSend,
|
||||
numberOrId,
|
||||
options = { continue: false }
|
||||
) => {
|
||||
if (!options.continue && prevMsg?.options?.capture)
|
||||
await cbEveryCtx(prevMsg?.ref)
|
||||
|
||||
if (prevMsg?.options?.capture) await cbEveryCtx(prevMsg?.ref)
|
||||
const queue = []
|
||||
for (const ctxMessage of messageToSend) {
|
||||
if (endFlowFlag) return
|
||||
@@ -127,45 +160,37 @@ class CoreClass {
|
||||
}
|
||||
|
||||
// 📄 [options: fallBack]: esta funcion se encarga de repetir el ultimo mensaje
|
||||
const fallBack = async () => {
|
||||
fallBackFlag = true
|
||||
await this.sendProviderAndSave(from, refToContinue)
|
||||
const fallBack = async (next = false, message = null) => {
|
||||
QueuePrincipal.queue = []
|
||||
return refToContinue
|
||||
if (next) return continueFlow()
|
||||
return this.sendProviderAndSave(from, {
|
||||
...prevMsg,
|
||||
answer:
|
||||
typeof message === 'string'
|
||||
? message
|
||||
: message?.body ?? prevMsg.answer,
|
||||
options: {
|
||||
...prevMsg.options,
|
||||
buttons: message?.buttons ?? prevMsg.options?.buttons,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 📄 [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 }
|
||||
) => {
|
||||
if (!Array.isArray(listMsg))
|
||||
throw new Error('Esto debe ser un ARRAY')
|
||||
const flowDynamic = async (listMsg = []) => {
|
||||
if (!Array.isArray(listMsg)) listMsg = [listMsg]
|
||||
|
||||
fallBackFlag = optListMsg.fallback
|
||||
const parseListMsg = listMsg
|
||||
.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)
|
||||
const parseListMsg = listMsg.map((opt, index) =>
|
||||
createCtxMessage(opt, index)
|
||||
)
|
||||
|
||||
if (endFlowFlag) return
|
||||
for (const msg of parseListMsg) {
|
||||
await this.sendProviderAndSave(from, msg)
|
||||
}
|
||||
return
|
||||
return continueFlow()
|
||||
}
|
||||
|
||||
// 📄 Se encarga de revisar si el contexto del mensaje tiene callback o fallback
|
||||
@@ -181,11 +206,12 @@ class CoreClass {
|
||||
fallBack,
|
||||
flowDynamic,
|
||||
endFlow,
|
||||
continueFlow,
|
||||
})
|
||||
}
|
||||
|
||||
// 📄🤘(tiene return) [options: nested(array)]: Si se tiene flujos hijos los implementa
|
||||
if (!fallBackFlag && 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),
|
||||
@@ -197,12 +223,11 @@ class CoreClass {
|
||||
return
|
||||
}
|
||||
|
||||
// 📄🤘(tiene return) [options: capture (boolean)]: Si se tiene option boolean
|
||||
if (!fallBackFlag && !prevMsg?.options?.nested?.length) {
|
||||
// 📄🤘(tiene return) Si el mensaje previo implementa capture
|
||||
if (!endFlowFlag && !prevMsg?.options?.nested?.length) {
|
||||
const typeCapture = typeof prevMsg?.options?.capture
|
||||
const valueCapture = prevMsg?.options?.capture
|
||||
|
||||
if (['string', 'boolean'].includes(typeCapture) && valueCapture) {
|
||||
if (typeCapture === 'boolean' && fallBackFlag) {
|
||||
msgToSend = this.flowClass.find(refToContinue?.ref, true) || []
|
||||
sendFlow(msgToSend, from)
|
||||
return
|
||||
@@ -228,6 +253,7 @@ class CoreClass {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @private
|
||||
* @param {*} message
|
||||
* @param {*} ref
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@bot-whatsapp/bot",
|
||||
"version": "0.0.73-alpha.0",
|
||||
"version": "0.0.91-alpha.0",
|
||||
"description": "",
|
||||
"main": "./lib/bundle.bot.cjs",
|
||||
"scripts": {
|
||||
|
||||
BIN
packages/docs/src/assets/images/digital-ocean.png
Normal file
BIN
packages/docs/src/assets/images/digital-ocean.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
213
packages/docs/src/components/atoms/DigitalOcean.tsx
Normal file
213
packages/docs/src/components/atoms/DigitalOcean.tsx
Normal file
@@ -0,0 +1,213 @@
|
||||
export const DigitalOcean = () => (
|
||||
<svg
|
||||
version="1.1"
|
||||
id="Layer_1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 604 129"
|
||||
style="enable-background:new 0 0 604 129;"
|
||||
xml:space="preserve"
|
||||
>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path
|
||||
class="st0"
|
||||
d="M174.3,3c4.9,0,8.7,2.9,8.7,8.6c0,5.6-3.8,8.5-8.7,8.5h-7.6v11.1h-3.5V3H174.3z M166.7,17.1h7.2
|
||||
c3,0,5.6-1.8,5.6-5.5c0-3.8-2.5-5.5-5.6-5.5h-7.2V17.1z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M208.8,21.7c0,6.1-4.3,10-9.9,10c-5.6,0-9.9-3.9-9.9-10c0-6.1,4.3-10,9.9-10
|
||||
C204.5,11.7,208.8,15.6,208.8,21.7z M192.3,21.7c0,4.5,2.9,7.2,6.6,7.2c3.7,0,6.6-2.7,6.6-7.2c0-4.5-2.9-7.1-6.6-7.1
|
||||
C195.2,14.5,192.3,17.2,192.3,21.7z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M234.4,31.3l-5.2-13.8L224,31.3h-2.6L214.1,12h3.6l5.2,14l5.2-14h2.3l5.3,14l5.2-14h3.5L237,31.3H234.4z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M253,22.9c0.2,3.7,2.6,5.9,6,5.9c2.8,0,4.8-1.3,5.4-3.4l3.2,0.2c-0.8,3.5-4.1,6.1-8.6,6.1
|
||||
c-5.5,0-9.6-3.7-9.6-10c0-6.3,4-10,9.5-10c5.5,0,8.8,3.7,8.8,9.4v1.8H253z M253,20.3h11.6c-0.1-3.4-2-5.7-5.6-5.7
|
||||
C255.6,14.5,253.2,16.5,253,20.3z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M285.4,14.9c-3.4,0-5.6,2.3-5.6,5.3v11.1h-3.2V12h3.2v2.9c0.7-1.6,2.5-3.1,5.7-3.1V14.9z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M294.7,22.9c0.2,3.7,2.6,5.9,6,5.9c2.8,0,4.8-1.3,5.4-3.4l3.2,0.2c-0.8,3.5-4.1,6.1-8.6,6.1
|
||||
c-5.5,0-9.6-3.7-9.6-10c0-6.3,4-10,9.5-10c5.5,0,8.8,3.7,8.8,9.4v1.8H294.7z M294.7,20.3h11.6c-0.1-3.4-2-5.7-5.6-5.7
|
||||
C297.4,14.5,294.9,16.5,294.7,20.3z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M333.1,31.3v-3.1c-1.1,2-3.6,3.5-6.8,3.5c-5.3,0-9.3-3.8-9.3-10c0-6.2,4-10,9.3-10c3.2,0,5.6,1.4,6.6,3.2V2
|
||||
h3.2v29.4H333.1z M320.3,21.7c0,4.6,2.8,7.2,6.5,7.2c3.6,0,6.2-2.2,6.2-6.6v-1.1c0-4.3-2.6-6.6-6.2-6.6
|
||||
C323.1,14.5,320.3,17.1,320.3,21.7z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M361.8,14.9c1.1-1.9,3.4-3.2,6.7-3.2c5.3,0,9.3,3.8,9.3,10c0,6.2-4,10-9.3,10c-3.3,0-5.7-1.5-6.8-3.5v3.1
|
||||
h-3.1V2h3.2V14.9z M361.9,21.1v1.1c0,4.4,2.6,6.6,6.2,6.6c3.7,0,6.5-2.5,6.5-7.2c0-4.6-2.8-7.1-6.5-7.1
|
||||
C364.5,14.5,361.9,16.8,361.9,21.1z"
|
||||
/>
|
||||
<path
|
||||
class="st0"
|
||||
d="M386.3,40.9l4.6-10.7L383.2,12h3.6l5.8,14.5l5.8-14.5h3.6l-12.2,28.9H386.3z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="XMLID_2369_">
|
||||
<g>
|
||||
<g id="XMLID_281_">
|
||||
<g id="XMLID_282_">
|
||||
<g>
|
||||
<g id="XMLID_283_">
|
||||
<g id="XMLID_287_">
|
||||
<path
|
||||
id="XMLID_288_"
|
||||
class="st0"
|
||||
d="M64.4,127l0-24.2c25.6,0,45.5-25.4,35.7-52.3c-3.6-10-11.6-17.9-21.6-21.6
|
||||
c-27-9.8-52.3,10-52.3,35.7c0,0,0,0,0,0L2,64.7C2,23.8,41.5-8,84.3,5.4c18.7,5.8,33.6,20.7,39.4,39.4
|
||||
C137,87.6,105.2,127,64.4,127z"
|
||||
/>
|
||||
</g>
|
||||
<polygon
|
||||
id="XMLID_286_"
|
||||
class="st1"
|
||||
points="64.4,102.9 40.4,102.9 40.4,78.9 40.4,78.9 64.4,78.9 64.4,78.9 "
|
||||
/>
|
||||
<polygon
|
||||
id="XMLID_285_"
|
||||
class="st1"
|
||||
points="40.3,121.5 21.8,121.5 21.8,121.5 21.8,102.9 40.4,102.9 40.4,121.5 "
|
||||
/>
|
||||
<path
|
||||
id="XMLID_284_"
|
||||
class="st1"
|
||||
d="M21.9,102.9H6.3c0,0,0,0,0,0V87.4c0,0,0,0,0,0h15.5c0,0,0,0,0,0V102.9z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="XMLID_254_">
|
||||
<path
|
||||
id="XMLID_278_"
|
||||
class="st0"
|
||||
d="M200.9,52.4c-5.5-3.8-12.4-5.8-20.5-5.8h-17.5v55.5h17.5c8,0,14.9-2.1,20.5-6.1
|
||||
c3-2.1,5.4-5.1,7.1-8.9c1.7-3.7,2.5-8.2,2.5-13.1c0-4.9-0.8-9.3-2.5-13C206.3,57.4,203.9,54.4,200.9,52.4z M173.1,56h5.5
|
||||
c6.1,0,11.1,1.2,15,3.6c4.2,2.6,6.4,7.4,6.4,14.4c0,7.2-2.2,12.3-6.4,15.1h0c-3.7,2.4-8.7,3.6-14.9,3.6h-5.6V56z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_277_"
|
||||
class="st0"
|
||||
d="M222.6,45.9c-1.7,0-3.1,0.6-4.3,1.8c-1.2,1.1-1.8,2.6-1.8,4.2c0,1.7,0.6,3.1,1.8,4.3
|
||||
c1.2,1.2,2.6,1.8,4.3,1.8c1.7,0,3.1-0.6,4.3-1.8c1.2-1.2,1.8-2.6,1.8-4.3c0-1.7-0.6-3.1-1.8-4.2
|
||||
C225.7,46.5,224.3,45.9,222.6,45.9z"
|
||||
/>
|
||||
<rect
|
||||
id="XMLID_276_"
|
||||
x="217.6"
|
||||
y="63"
|
||||
class="st0"
|
||||
width="9.8"
|
||||
height="39.1"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_273_"
|
||||
class="st0"
|
||||
d="M263.2,66.3c-3-2.6-6.3-4.2-9.9-4.2c-5.4,0-9.9,1.9-13.4,5.6c-3.5,3.7-5.3,8.4-5.3,14.1
|
||||
c0,5.5,1.8,10.2,5.2,14c3.5,3.7,8,5.5,13.5,5.5c3.8,0,7.1-1.1,9.7-3.1V99c0,3.2-0.9,5.8-2.6,7.5c-1.7,1.7-4.1,2.6-7.1,2.6
|
||||
c-4.5,0-7.4-1.8-10.9-6.5l-6.7,6.4l0.2,0.3c1.4,2,3.7,4,6.6,5.9c2.9,1.9,6.6,2.8,10.9,2.8c5.8,0,10.6-1.8,14.1-5.4
|
||||
c3.5-3.6,5.3-8.4,5.3-14.2V63h-9.7V66.3z M260.6,89.4c-1.7,2-3.9,2.9-6.8,2.9c-2.8,0-5-0.9-6.7-2.9c-1.7-1.9-2.5-4.5-2.5-7.7
|
||||
c0-3.2,0.9-5.8,2.5-7.7c1.7-1.9,3.9-2.9,6.7-2.9c2.8,0,5,1,6.8,2.9c1.7,2,2.6,4.6,2.6,7.7C263.2,84.9,262.3,87.5,260.6,89.4z"
|
||||
/>
|
||||
<rect
|
||||
id="XMLID_272_"
|
||||
x="281.3"
|
||||
y="63"
|
||||
class="st0"
|
||||
width="9.8"
|
||||
height="39.1"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_271_"
|
||||
class="st0"
|
||||
d="M286.3,45.9c-1.7,0-3.1,0.6-4.3,1.8c-1.2,1.1-1.8,2.6-1.8,4.2c0,1.7,0.6,3.1,1.8,4.3
|
||||
c1.2,1.2,2.6,1.8,4.3,1.8c1.7,0,3.1-0.6,4.3-1.8c1.2-1.2,1.8-2.6,1.8-4.3c0-1.7-0.6-3.1-1.8-4.2C289.4,46.5,288,45.9,286.3,45.9
|
||||
z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_270_"
|
||||
class="st0"
|
||||
d="M312.7,52.5H303V63h-5.6v9h5.6v16.2c0,5.1,1,8.7,3,10.8c2,2.1,5.6,3.2,10.6,3.2
|
||||
c1.6,0,3.2-0.1,4.8-0.2l0.4,0v-9l-3.4,0.2c-2.3,0-3.9-0.4-4.7-1.2c-0.8-0.8-1.1-2.6-1.1-5.2V72h9.2v-9h-9.2V52.5z"
|
||||
/>
|
||||
<rect
|
||||
id="XMLID_269_"
|
||||
x="368"
|
||||
y="46.6"
|
||||
class="st0"
|
||||
width="9.8"
|
||||
height="55.5"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_268_"
|
||||
class="st0"
|
||||
d="M477.3,88.2c-1.8,2-3.6,3.7-4.9,4.6v0c-1.4,0.9-3.1,1.3-5.1,1.3c-2.9,0-5.2-1.1-7.1-3.2
|
||||
c-1.9-2.2-2.8-4.9-2.8-8.3s0.9-6.1,2.8-8.2c1.9-2.2,4.2-3.2,7.1-3.2c3.2,0,6.5,2,9.4,5.4l6.5-6.2l0,0c-4.2-5.5-9.7-8.1-16.1-8.1
|
||||
c-5.4,0-10.1,2-13.9,5.8c-3.8,3.9-5.7,8.8-5.7,14.6s1.9,10.7,5.7,14.6c3.8,3.9,8.5,5.9,13.9,5.9c7.1,0,12.9-3.1,16.8-8.7
|
||||
L477.3,88.2z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_265_"
|
||||
class="st0"
|
||||
d="M517.7,68.5c-1.4-1.9-3.3-3.5-5.7-4.7c-2.3-1.1-5.1-1.7-8.1-1.7c-5.5,0-10,2-13.4,6
|
||||
c-3.3,4-4.9,8.9-4.9,14.7c0,5.9,1.8,10.8,5.4,14.6c3.6,3.7,8.4,5.6,14.2,5.6c6.6,0,12.1-2.7,16.2-8l0.2-0.3l-6.4-6.2l0,0
|
||||
c-0.6,0.7-1.4,1.5-2.2,2.3c-1,0.9-1.9,1.6-2.9,2.1c-1.5,0.7-3.1,1.1-5,1.1c-2.7,0-5-0.8-6.7-2.4c-1.6-1.5-2.6-3.5-2.8-5.9h26.1
|
||||
l0.1-3.6c0-2.5-0.3-5-1-7.3C520.1,72.6,519.1,70.4,517.7,68.5z M496.2,77.7c0.5-1.9,1.3-3.4,2.6-4.6c1.3-1.3,3.1-2,5.2-2
|
||||
c2.4,0,4.2,0.7,5.5,2c1.2,1.2,1.8,2.8,2,4.6H496.2z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_262_"
|
||||
class="st0"
|
||||
d="M555.5,66L555.5,66c-3-2.5-7.1-3.8-12.3-3.8c-3.3,0-6.3,0.7-9.1,2.1
|
||||
c-2.6,1.3-5.1,3.5-6.7,6.3l0.1,0.1l6.3,6c2.6-4.1,5.5-5.6,9.3-5.6c2.1,0,3.8,0.6,5.1,1.6c1.3,1.1,1.9,2.5,1.9,4.2v1.9
|
||||
c-2.4-0.7-4.9-1.1-7.2-1.1c-4.9,0-8.9,1.2-11.8,3.4c-3,2.3-4.5,5.6-4.5,9.8c0,3.7,1.3,6.7,3.8,8.9c2.6,2.1,5.8,3.2,9.5,3.2
|
||||
c3.7,0,7.3-1.5,10.4-4.1v3.2h9.7V77C560,72.2,558.5,68.5,555.5,66z M538,87.2c1.1-0.8,2.7-1.2,4.7-1.2c2.4,0,4.9,0.5,7.5,1.4
|
||||
v3.8c-2.1,2-5,3-8.5,3c-1.7,0-3-0.4-3.9-1.1c-0.9-0.7-1.3-1.7-1.3-2.8C536.4,89,536.9,88,538,87.2z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_261_"
|
||||
class="st0"
|
||||
d="M597.9,66.7c-2.7-3.1-6.6-4.6-11.5-4.6c-3.9,0-7.1,1.1-9.4,3.3V63h-9.7v39.1h9.8V80.6
|
||||
c0-3,0.7-5.3,2.1-7c1.4-1.7,3.3-2.5,5.8-2.5c2.2,0,3.9,0.7,5.2,2.2c1.3,1.5,1.9,3.6,1.9,6.2v22.7h9.8V79.5
|
||||
C602,74.1,600.6,69.8,597.9,66.7z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_258_"
|
||||
class="st0"
|
||||
d="M355.6,66L355.6,66c-3-2.5-7.1-3.8-12.3-3.8c-3.3,0-6.3,0.7-9.1,2.1
|
||||
c-2.6,1.3-5.1,3.5-6.7,6.3l0.1,0.1l6.3,6c2.6-4.1,5.5-5.6,9.3-5.6c2.1,0,3.8,0.6,5.1,1.6c1.3,1.1,1.9,2.5,1.9,4.2v1.9
|
||||
c-2.4-0.7-4.9-1.1-7.2-1.1c-4.9,0-8.9,1.2-11.8,3.4c-3,2.3-4.5,5.6-4.5,9.8c0,3.7,1.3,6.7,3.8,8.9c2.6,2.1,5.8,3.2,9.5,3.2
|
||||
c3.7,0,7.3-1.5,10.4-4.1v3.2h9.7V77C360.2,72.2,358.7,68.5,355.6,66z M338.2,87.2c1.1-0.8,2.7-1.2,4.7-1.2
|
||||
c2.4,0,4.9,0.5,7.5,1.4v3.8c-2.1,2-5,3-8.5,3c-1.7,0-3-0.4-3.9-1.1c-0.9-0.7-1.3-1.7-1.3-2.8C336.6,89,337.1,88,338.2,87.2z"
|
||||
/>
|
||||
<path
|
||||
id="XMLID_255_"
|
||||
class="st0"
|
||||
d="M413.6,103c-15.8,0-28.6-12.8-28.6-28.6s12.8-28.6,28.6-28.6s28.6,12.8,28.6,28.6
|
||||
S429.4,103,413.6,103z M413.6,55.8c-10.2,0-18.5,8.3-18.5,18.5s8.3,18.5,18.5,18.5s18.5-8.3,18.5-18.5S423.8,55.8,413.6,55.8z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
)
|
||||
@@ -7,6 +7,8 @@ import { src as qwik } from '~/assets/images/qwik.png?width=100&metadata'
|
||||
import { src as leanga } from '~/assets/images/leanga.png?width=40&metadata'
|
||||
// @ts-ignore
|
||||
import { src as netlify } from '~/assets/images/full-logo-light.png?width=100&metadata'
|
||||
// @ts-ignore
|
||||
import { src as digitalOcean } from '~/assets/images/digital-ocean.png?width=100&metadata'
|
||||
|
||||
/**
|
||||
* options = [] array con la lista de opciones de la documentacion
|
||||
@@ -41,7 +43,20 @@ export default component$(() => {
|
||||
<img
|
||||
src={netlify}
|
||||
class="border border-slate-200 rounded my-2 p-1 bg-gray-50 dark:border-gray-600 dark:bg-gray-700"
|
||||
alt="Qwind Hero Image (Cool dog)"
|
||||
alt="Netlify"
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
/>
|
||||
</picture>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a target={'_blank'} href="https://m.do.co/c/140291d21736">
|
||||
<picture>
|
||||
<img
|
||||
src={digitalOcean}
|
||||
class="border border-slate-200 rounded my-2 p-1 bg-gray-50 dark:border-gray-600 dark:bg-gray-700"
|
||||
alt="DigitalOcean"
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
/>
|
||||
|
||||
@@ -29,13 +29,16 @@ const flowPrincipal = addKeyword(['hola', 'alo'])
|
||||
Es importante que el número **vaya acompañado de su prefijo**, en el caso de España "34".
|
||||
|
||||
```js
|
||||
createBot({
|
||||
createBot(
|
||||
{
|
||||
flow: adapterFlow,
|
||||
provider: adapterProvider,
|
||||
database: adapterDB,
|
||||
},{
|
||||
blackList:['34XXXXXXXXX','34XXXXXXXXX','34XXXXXXXXX','34XXXXXXXXX']
|
||||
})
|
||||
},
|
||||
{
|
||||
blackList: ['34XXXXXXXXX', '34XXXXXXXXX', '34XXXXXXXXX', '34XXXXXXXXX'],
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
@@ -175,65 +178,75 @@ const flowString = addKeyword('hola')
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## endFlow()
|
||||
|
||||
Esta funcion se utliza para finalizar un flujo con dos o más addAnswer. Un ejemplo de uso sería registrar 3 datos de un usuario en 3 preguntas distinas y
|
||||
Esta funcion se utliza para finalizar un flujo con dos o más addAnswer. Un ejemplo de uso sería registrar 3 datos de un usuario en 3 preguntas distinas y
|
||||
que el usuario pueda finalizar por él mismo el flujo.
|
||||
Como podrás comprobar en el ejemplo siguiente, se puede vincular flowDynamic y todas sus funciones; como por ejemplo botones.
|
||||
|
||||
|
||||
|
||||
```js
|
||||
const flowFormulario = addKeyword(['Hola'])
|
||||
|
||||
.addAnswer(['Hola!','Escriba su *Nombre* para generar su solicitud'],
|
||||
{capture: true,buttons:[{body:'❌ Cancelar solicitud'}]},
|
||||
async (ctx,{flowDynamic, endFlow})=>{
|
||||
if(ctx.body == '❌ Cancelar solicitud'){
|
||||
await flowDynamic([{body: "❌ *Su solicitud de cita ha sido cancelada* ❌", buttons:[{body:'⬅️ Volver al Inicio'}]}])
|
||||
return endFlow()
|
||||
}
|
||||
})
|
||||
.addAnswer(['También necesito tus dos apellidos'],
|
||||
{capture: true,buttons:[{body:'❌ Cancelar solicitud'}]},
|
||||
async (ctx,{flowDynamic, endFlow})=>{
|
||||
if(ctx.body == '❌ Cancelar solicitud'){
|
||||
await flowDynamic([{body: "❌ *Su solicitud de cita ha sido cancelada* ❌", buttons:[{body:'⬅️ Volver al Inicio'}]}])
|
||||
return endFlow()
|
||||
}
|
||||
})
|
||||
.addAnswer(['Dejeme su número de teléfono y le llamaré lo antes posible.'],
|
||||
{capture: true,buttons:[{body:'❌ Cancelar solicitud'}]},
|
||||
async (ctx,{flowDynamic, endFlow})=>{
|
||||
if(ctx.body == '❌ Cancelar solicitud'){
|
||||
await flowDynamic([{body: "❌ *Su solicitud de cita ha sido cancelada* ❌", buttons:[{body:'⬅️ Volver al Inicio'}]}])
|
||||
return endFlow()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
.addAnswer(
|
||||
['Hola!', 'Escriba su *Nombre* para generar su solicitud'],
|
||||
{ capture: true, buttons: [{ body: '❌ Cancelar solicitud' }] },
|
||||
async (ctx, { flowDynamic, endFlow }) => {
|
||||
if (ctx.body == '❌ Cancelar solicitud') {
|
||||
await flowDynamic([
|
||||
{
|
||||
body: '❌ *Su solicitud de cita ha sido cancelada* ❌',
|
||||
buttons: [{ body: '⬅️ Volver al Inicio' }],
|
||||
},
|
||||
])
|
||||
return endFlow()
|
||||
}
|
||||
}
|
||||
)
|
||||
.addAnswer(
|
||||
['También necesito tus dos apellidos'],
|
||||
{ capture: true, buttons: [{ body: '❌ Cancelar solicitud' }] },
|
||||
async (ctx, { flowDynamic, endFlow }) => {
|
||||
if (ctx.body == '❌ Cancelar solicitud') {
|
||||
await flowDynamic([
|
||||
{
|
||||
body: '❌ *Su solicitud de cita ha sido cancelada* ❌',
|
||||
buttons: [{ body: '⬅️ Volver al Inicio' }],
|
||||
},
|
||||
])
|
||||
return endFlow()
|
||||
}
|
||||
}
|
||||
)
|
||||
.addAnswer(
|
||||
['Dejeme su número de teléfono y le llamaré lo antes posible.'],
|
||||
{ capture: true, buttons: [{ body: '❌ Cancelar solicitud' }] },
|
||||
async (ctx, { flowDynamic, endFlow }) => {
|
||||
if (ctx.body == '❌ Cancelar solicitud') {
|
||||
await flowDynamic([
|
||||
{
|
||||
body: '❌ *Su solicitud de cita ha sido cancelada* ❌',
|
||||
buttons: [{ body: '⬅️ Volver al Inicio' }],
|
||||
},
|
||||
])
|
||||
return endFlow()
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# QRPortalWeb
|
||||
|
||||
Argumento para asignar nombre y puerto al BOT
|
||||
|
||||
```js
|
||||
QRPortalWeb({name:BOTNAME, port:3005 });
|
||||
|
||||
const BOTNAME = 'bot'
|
||||
QRPortalWeb({ name: BOTNAME, port: 3005 })
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
<Navigation
|
||||
pages={[
|
||||
{ name: 'Conceptos', link: '/docs/essential' },
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { DocumentHead } from '@builder.io/qwik-city'
|
||||
import ExtraBar from '~/components/widgets/ExtraBar'
|
||||
import Header from '~/components/widgets/Header'
|
||||
import NavBar from '~/components/widgets/NavBar'
|
||||
import { SearchModal } from '~/components/widgets/SearchModal'
|
||||
// import { SearchModal } from '~/components/widgets/SearchModal'
|
||||
import SponsorBar from '~/components/widgets/SponsorBar'
|
||||
import { GlobalStore } from '~/contexts'
|
||||
// import Navigation from '~/components/widgets/Navigation'
|
||||
@@ -15,7 +15,7 @@ export default component$(() => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchModal />
|
||||
{/* <SearchModal /> */}
|
||||
<Header />
|
||||
<main class={'overflow-hidden'}>
|
||||
<div class={'max-w-8xl'}>
|
||||
|
||||
65
packages/provider/common/download.js
Normal file
65
packages/provider/common/download.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const mimeDep = require('mime-types')
|
||||
const { tmpdir } = require('os')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
const { rename, createWriteStream } = require('fs')
|
||||
|
||||
/**
|
||||
* Extrar el mimetype from buffer
|
||||
* @param {string} response
|
||||
* @returns
|
||||
*/
|
||||
const fileTypeFromFile = async (response) => {
|
||||
const type = response.headers['content-type'] ?? null
|
||||
const ext = mimeDep.extension(type)
|
||||
return {
|
||||
type,
|
||||
ext,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Descargar archivo binay en tmp
|
||||
* @param {*} url
|
||||
* @returns
|
||||
*/
|
||||
const generalDownload = async (url) => {
|
||||
const handleDownload = () => {
|
||||
const checkProtocol = url.includes('https:')
|
||||
const handleHttp = checkProtocol ? https : http
|
||||
const name = `tmp-${Date.now()}-dat`
|
||||
const fullPath = `${tmpdir()}/${name}`
|
||||
const file = createWriteStream(fullPath)
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
handleHttp.get(url, function (response) {
|
||||
response.pipe(file)
|
||||
file.on('finish', async function () {
|
||||
file.close()
|
||||
res({ response, fullPath })
|
||||
})
|
||||
file.on('error', function () {
|
||||
file.close()
|
||||
rej(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const handleFile = (pathInput, ext) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const fullPath = `${pathInput}.${ext}`
|
||||
rename(pathInput, fullPath, (err) => {
|
||||
if (err) reject(null)
|
||||
resolve(fullPath)
|
||||
})
|
||||
})
|
||||
|
||||
const httpResponse = await handleDownload()
|
||||
const { ext } = await fileTypeFromFile(httpResponse.response)
|
||||
const getPath = await handleFile(httpResponse.fullPath, ext)
|
||||
|
||||
return getPath
|
||||
}
|
||||
|
||||
module.exports = { generalDownload }
|
||||
@@ -4,7 +4,7 @@ const pino = require('pino')
|
||||
const rimraf = require('rimraf')
|
||||
const mime = require('mime-types')
|
||||
const { join } = require('path')
|
||||
const { existsSync, createWriteStream, readFileSync } = require('fs')
|
||||
const { createWriteStream, readFileSync } = require('fs')
|
||||
const { Console } = require('console')
|
||||
|
||||
const {
|
||||
@@ -13,13 +13,15 @@ const {
|
||||
Browsers,
|
||||
DisconnectReason,
|
||||
} = require('@adiwajshing/baileys')
|
||||
|
||||
const {
|
||||
baileyGenerateImage,
|
||||
baileyCleanNumber,
|
||||
baileyIsValidNumber,
|
||||
baileyDownloadMedia,
|
||||
} = require('./utils')
|
||||
|
||||
const { generalDownload } = require('../../common/download')
|
||||
|
||||
const logger = new Console({
|
||||
stdout: createWriteStream(`${process.cwd()}/baileys.log`),
|
||||
})
|
||||
@@ -169,14 +171,50 @@ class BaileysProvider extends ProviderClass {
|
||||
*/
|
||||
|
||||
sendMedia = async (number, imageUrl, text) => {
|
||||
const fileDownloaded = await baileyDownloadMedia(imageUrl)
|
||||
const fileDownloaded = await generalDownload(imageUrl)
|
||||
const mimeType = mime.lookup(fileDownloaded)
|
||||
|
||||
if (mimeType.includes('image'))
|
||||
return this.sendImage(number, fileDownloaded, text)
|
||||
if (mimeType.includes('video'))
|
||||
return this.sendVideo(number, fileDownloaded, text)
|
||||
if (mimeType.includes('audio'))
|
||||
return this.sendAudio(number, fileDownloaded, text)
|
||||
|
||||
return this.sendFile(number, fileDownloaded)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendImage = async (number, filePath, text) => {
|
||||
return this.vendor.sendMessage(number, {
|
||||
image: readFileSync(fileDownloaded),
|
||||
image: readFileSync(filePath),
|
||||
caption: text,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar video
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendVideo = async (number, filePath, text) => {
|
||||
return this.vendor.sendMessage(number, {
|
||||
video: readFileSync(filePath),
|
||||
caption: text,
|
||||
gifPlayback: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar audio
|
||||
* @alpha
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
@@ -185,8 +223,7 @@ class BaileysProvider extends ProviderClass {
|
||||
*/
|
||||
|
||||
sendAudio = async (number, audioUrl, voiceNote = false) => {
|
||||
const numberClean = number.replace('+', '')
|
||||
await this.vendor.sendMessage(`${numberClean}@c.us`, {
|
||||
return this.vendor.sendMessage(number, {
|
||||
audio: { url: audioUrl },
|
||||
ptt: voiceNote,
|
||||
})
|
||||
@@ -210,17 +247,13 @@ class BaileysProvider extends ProviderClass {
|
||||
*/
|
||||
|
||||
sendFile = async (number, filePath) => {
|
||||
if (existsSync(filePath)) {
|
||||
const mimeType = mime.lookup(filePath)
|
||||
const numberClean = number.replace('+', '')
|
||||
const fileName = filePath.split('/').pop()
|
||||
|
||||
await this.vendor.sendMessage(`${numberClean}@c.us`, {
|
||||
document: { url: filePath },
|
||||
mimetype: mimeType,
|
||||
fileName: fileName,
|
||||
})
|
||||
}
|
||||
const mimeType = mime.lookup(filePath)
|
||||
const fileName = filePath.split('/').pop()
|
||||
return this.vendor.sendMessage(number, {
|
||||
document: { url: filePath },
|
||||
mimetype: mimeType,
|
||||
fileName: fileName,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"@adiwajshing/baileys": "4.4.0",
|
||||
"mime-types": "2.1.35",
|
||||
"wa-sticker-formatter": "4.3.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
const { createWriteStream } = require('fs')
|
||||
const combineImage = require('combine-image')
|
||||
const qr = require('qr-image')
|
||||
const { tmpdir } = require('os')
|
||||
const http = require('http')
|
||||
const https = require('https')
|
||||
|
||||
const baileyCleanNumber = (number, full = false) => {
|
||||
number = number.replace('@s.whatsapp.net', '')
|
||||
@@ -41,38 +38,8 @@ const baileyIsValidNumber = (rawNumber) => {
|
||||
return !exist
|
||||
}
|
||||
|
||||
/**
|
||||
* Incompleta
|
||||
* Descargar archivo multimedia para enviar
|
||||
* @param {*} url
|
||||
* @returns
|
||||
*/
|
||||
const baileyDownloadMedia = (url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const ext = url.split('.').pop()
|
||||
const checkProtocol = url.includes('https:')
|
||||
const handleHttp = checkProtocol ? https : http
|
||||
const name = `tmp-${Date.now()}.${ext}`
|
||||
const fullPath = `${tmpdir()}/${name}`
|
||||
const file = createWriteStream(fullPath)
|
||||
handleHttp.get(url, function (response) {
|
||||
response.pipe(file)
|
||||
file.on('finish', function () {
|
||||
file.close()
|
||||
resolve(fullPath)
|
||||
})
|
||||
file.on('error', function () {
|
||||
console.log('errro')
|
||||
file.close()
|
||||
reject(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
baileyCleanNumber,
|
||||
baileyGenerateImage,
|
||||
baileyIsValidNumber,
|
||||
baileyDownloadMedia,
|
||||
}
|
||||
|
||||
@@ -2,18 +2,20 @@ const { ProviderClass } = require('@bot-whatsapp/bot')
|
||||
const venom = require('venom-bot')
|
||||
const { createWriteStream } = require('fs')
|
||||
const { Console } = require('console')
|
||||
const mime = require('mime-types')
|
||||
|
||||
const {
|
||||
venomCleanNumber,
|
||||
venomGenerateImage,
|
||||
venomisValidNumber,
|
||||
venomDownloadMedia,
|
||||
} = require('./utils')
|
||||
|
||||
const logger = new Console({
|
||||
stdout: createWriteStream(`${process.cwd()}/venom.log`),
|
||||
})
|
||||
|
||||
const { generalDownload } = require('../../common/download')
|
||||
|
||||
/**
|
||||
* ⚙️ VenomProvider: Es una clase tipo adaptor
|
||||
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
||||
@@ -134,6 +136,53 @@ class VenomProvider extends ProviderClass {
|
||||
// return this.vendor.sendButtons(number, "Title", buttons1, "Description");
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar audio
|
||||
* @alpha
|
||||
* @param {string} number
|
||||
* @param {string} message
|
||||
* @param {boolean} voiceNote optional
|
||||
* @example await sendMessage('+XXXXXXXXXXX', 'audio.mp3')
|
||||
*/
|
||||
|
||||
sendAudio = async (number, audioPath) => {
|
||||
return this.vendor.sendVoice(number, audioPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendImage = async (number, filePath, text) => {
|
||||
return this.vendor.sendImage(number, filePath, 'image-name', text)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} number
|
||||
* @param {string} filePath
|
||||
* @example await sendMessage('+XXXXXXXXXXX', './document/file.pdf')
|
||||
*/
|
||||
|
||||
sendFile = async (number, filePath, text) => {
|
||||
const fileName = filePath.split('/').pop()
|
||||
return this.vendor.sendFile(number, filePath, fileName, text)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar video
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendVideo = async (number, filePath, text) => {
|
||||
return this.vendor.sendVideoAsGif(number, filePath, 'video.gif', text)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen o multimedia
|
||||
* @param {*} number
|
||||
@@ -141,10 +190,18 @@ class VenomProvider extends ProviderClass {
|
||||
* @param {*} message
|
||||
* @returns
|
||||
*/
|
||||
sendMedia = async (number, mediaInput, message) => {
|
||||
if (!mediaInput) throw new Error(`NO_SE_ENCONTRO: ${mediaInput}`)
|
||||
const fileDownloaded = await venomDownloadMedia(mediaInput)
|
||||
return this.vendor.sendImage(number, fileDownloaded, '.', message)
|
||||
sendMedia = async (number, mediaUrl, text) => {
|
||||
const fileDownloaded = await generalDownload(mediaUrl)
|
||||
const mimeType = mime.lookup(fileDownloaded)
|
||||
|
||||
if (mimeType.includes('image'))
|
||||
return this.sendImage(number, fileDownloaded, text)
|
||||
if (mimeType.includes('video'))
|
||||
return this.sendVideo(number, fileDownloaded, text)
|
||||
if (mimeType.includes('audio'))
|
||||
return this.sendAudio(number, fileDownloaded)
|
||||
|
||||
return this.sendFile(number, fileDownloaded, text)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
const { Client, LocalAuth, MessageMedia, Buttons } = require('whatsapp-web.js')
|
||||
const { ProviderClass } = require('@bot-whatsapp/bot')
|
||||
const { Console } = require('console')
|
||||
const { createWriteStream } = require('fs')
|
||||
const { createWriteStream, readFileSync } = require('fs')
|
||||
const {
|
||||
wwebCleanNumber,
|
||||
wwebDownloadMedia,
|
||||
wwebGenerateImage,
|
||||
wwebIsValidNumber,
|
||||
} = require('./utils')
|
||||
@@ -13,6 +12,9 @@ const logger = new Console({
|
||||
stdout: createWriteStream('./log'),
|
||||
})
|
||||
|
||||
const { generalDownload } = require('../../common/download')
|
||||
const mime = require('mime-types')
|
||||
|
||||
/**
|
||||
* ⚙️ WebWhatsappProvider: Es una clase tipo adaptor
|
||||
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
|
||||
@@ -35,6 +37,7 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
'--disable-setuid-sandbox',
|
||||
'--unhandled-rejections=strict',
|
||||
],
|
||||
//executablePath: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
|
||||
},
|
||||
})
|
||||
|
||||
@@ -103,23 +106,6 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
},
|
||||
]
|
||||
|
||||
/**
|
||||
* Enviar un archivo multimedia
|
||||
* https://docs.wwebjs.dev/MessageMedia.html
|
||||
* @private
|
||||
* @param {*} number
|
||||
* @param {*} mediaInput
|
||||
* @returns
|
||||
*/
|
||||
sendMedia = async (number, mediaInput = null) => {
|
||||
if (!mediaInput) throw new Error(`NO_SE_ENCONTRO: ${mediaInput}`)
|
||||
const fileDownloaded = await wwebDownloadMedia(mediaInput)
|
||||
const media = MessageMedia.fromFilePath(fileDownloaded)
|
||||
return this.vendor.sendMessage(number, media, {
|
||||
sendAudioAsVoice: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar botones
|
||||
* https://docs.wwebjs.dev/Buttons.html
|
||||
@@ -170,6 +156,86 @@ class WebWhatsappProvider extends ProviderClass {
|
||||
return this.vendor.sendMessage(number, message)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendImage = async (number, filePath, caption) => {
|
||||
const base64 = readFileSync(filePath, { encoding: 'base64' })
|
||||
const mimeType = mime.lookup(filePath)
|
||||
const media = new MessageMedia(mimeType, base64)
|
||||
return this.vendor.sendMessage(number, media, { caption })
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar audio
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
|
||||
sendAudio = async (number, filePath, caption) => {
|
||||
const base64 = readFileSync(filePath, { encoding: 'base64' })
|
||||
const mimeType = mime.lookup(filePath)
|
||||
const media = new MessageMedia(mimeType, base64)
|
||||
return this.vendor.sendMessage(number, media, { caption })
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar video
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendVideo = async (number, filePath) => {
|
||||
const base64 = readFileSync(filePath, { encoding: 'base64' })
|
||||
const mimeType = mime.lookup(filePath)
|
||||
const media = new MessageMedia(mimeType, base64)
|
||||
return this.vendor.sendMessage(number, media, {
|
||||
sendMediaAsDocument: true,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar Arhivos/pdf
|
||||
* @param {*} number
|
||||
* @param {*} imageUrl
|
||||
* @param {*} text
|
||||
* @returns
|
||||
*/
|
||||
sendFile = async (number, filePath) => {
|
||||
const base64 = readFileSync(filePath, { encoding: 'base64' })
|
||||
const mimeType = mime.lookup(filePath)
|
||||
const media = new MessageMedia(mimeType, base64)
|
||||
return this.vendor.sendMessage(number, media)
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviar imagen o multimedia
|
||||
* @param {*} number
|
||||
* @param {*} mediaInput
|
||||
* @param {*} message
|
||||
* @returns
|
||||
*/
|
||||
sendMedia = async (number, mediaUrl, text) => {
|
||||
const fileDownloaded = await generalDownload(mediaUrl)
|
||||
const mimeType = mime.lookup(fileDownloaded)
|
||||
|
||||
if (mimeType.includes('image'))
|
||||
return this.sendImage(number, fileDownloaded, text)
|
||||
if (mimeType.includes('video'))
|
||||
return this.sendVideo(number, fileDownloaded)
|
||||
if (mimeType.includes('audio'))
|
||||
return this.sendAudio(number, fileDownloaded, text)
|
||||
|
||||
return this.sendFile(number, fileDownloaded)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} userId
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"whatsapp-web.js": "1.19.2"
|
||||
"whatsapp-web.js": "1.19.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1113,6 +1113,7 @@ __metadata:
|
||||
fs-extra: ^11.1.0
|
||||
git-cz: ^4.9.0
|
||||
husky: ^8.0.2
|
||||
mime-types: ^2.1.35
|
||||
only-allow: ^1.1.1
|
||||
prettier: ^2.8.0
|
||||
pretty-quick: ^3.1.3
|
||||
@@ -13443,7 +13444,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"mime-types@npm:^2.1.12, mime-types@npm:~2.1.19, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34":
|
||||
"mime-types@npm:^2.1.12, mime-types@npm:^2.1.35, mime-types@npm:~2.1.19, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34":
|
||||
version: 2.1.35
|
||||
resolution: "mime-types@npm:2.1.35"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user