Skip to content

Commit

Permalink
Merge pull request #895 from codigoencasa/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
leifermendez authored Oct 31, 2023
2 parents 0b800a5 + bdf4206 commit 52b438c
Show file tree
Hide file tree
Showing 145 changed files with 3,254 additions and 878 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Por favor agrega una descripción de tu aporte para tener más contexto y poder
> Forma parte de este proyecto.
- [Discord](https://link.codigoencasa.com/DISCORD)
- [Twitter](https://twitter.com/leifermendez)
- [𝕏 (Twitter)](https://twitter.com/leifermendez)
- [Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)
- [Telegram](https://t.me/leifermendez)
3 changes: 3 additions & 0 deletions .github/workflows/releases-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ jobs:

- name: Release @bot-whatsapp/portal
run: node ./scripts/release.js --name=portal --version= --token="${{ secrets.NPM_TOKEN }}"

- name: Release eslint-plugin-bot-whatsapp
run: node ./scripts/release.js --name=eslint-plugin-bot-whatsapp --version= --token="${{ secrets.NPM_TOKEN }}"
3 changes: 3 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,8 @@ jobs:
- name: Release @bot-whatsapp/portal
run: node ./scripts/release.js --name=portal --version="${{ steps.package-version.outputs.current-version}}" --token="${{ secrets.NPM_TOKEN }}"

- name: Release eslint-plugin-bot-whatsapp
run: node ./scripts/release.js --name=eslint-plugin-bot-whatsapp --version="${{ steps.package-version.outputs.current-version}}" --token="${{ secrets.NPM_TOKEN }}"

- name: Release Github
run: node ./scripts/github.js --version="${{ steps.package-version.outputs.current-version}}" --token="${{ secrets.OCTO_TOKEN }}"
15 changes: 7 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,34 @@ El lenguaje principal que se utilizó para desarrollar este proyecto fue __JavaS


__Requerimientos:__
- Node v16 o superior __[descargar node](https://nodejs.org/es/download/)__
- __[Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable)__ como gestor de paquetes. En el link conseguirás las intrucciones para instalar yarn.
- Node v18 o superior __[descargar node](https://nodejs.org/es/download/)__
- __[pnpm](https://pnpm.io/cli/install)__ como gestor de paquetes. En el link conseguirás las intrucciones para instalar `pnmp`.
- __[VSCode](https://code.visualstudio.com/download)__ (recomendado): Editor de código con plugins.
- __[Conventional Commits](https://marketplace.visualstudio.com/items?itemName=vivaxy.vscode-conventional-commits&ssr=false#overview)__ (plugin-vscode) este plugin te ayudará a crear commit semántico.
- Se usará la rama __dev__ *(https://github.com/leifermendez/bot-whatsapp/tree/dev)* como rama principal hasta que se haga oficialmente el lanzamiento de la V2.

### 🚀 Iniciando

__Clonar repo rama dev__
__Clona repositorio (desde tu fork)__
```
git clone --branch dev https://github.com/codigoencasa/bot-whatsapp
git clone https://github.com/codigoencasa/bot-whatsapp
```
__Instalar dependencias__
```
cd bot-whatsapp
yarn install
pnpm install
```

__Compilar (build)__
Para compilar la aplicación es necesario ejecutar este comando, el cual genera un directorio `lib` dentro de los paquetes del monorepo.

```
yarn build
pnpm run build
```

__Example-app__
Se ejecuta el CLI (Command Line Interface) para ayudarte a crear un app-bot de ejemplo.
```
yarn run cli
pnpm run cli
```

Selecionas (mediante las flechas arriba y abajo) el proveedor que quieras usar y cuando estes sobre el presiona la barra de espacio, igualmente selecciona la base de datos que quieras usar.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Entiende más a fondo sus funcionalidades explicadas en nuestra documentación.
- [📄 Documentación](https://bot-whatsapp.netlify.app/)
- [🚀 Roadmap](https://github.com/orgs/codigoencasa/projects/1)
- [💻 Discord](https://link.codigoencasa.com/DISCORD)
- [👌 Twitter](https://twitter.com/leifermendez)
- [👌 𝕏 (Twitter)](https://twitter.com/leifermendez)
- [🎥 Youtube](https://www.youtube.com/watch?v=5lEMCeWEJ8o&list=PL_WGMLcL4jzWPhdhcUyhbFU6bC0oJd2BR)

## Comunidad
Expand Down
12 changes: 5 additions & 7 deletions __mocks__/mock.provider.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
const ProviderClass = require('../packages/bot/provider/provider.class')
const { delay } = require('./env')
class MockProvider extends ProviderClass {
constructor() {
super()
}

delaySendMessage = (miliseconds, eventName, payload) =>
new Promise((res) =>
setTimeout(() => {
this.emit(eventName, payload)
res
}, miliseconds)
)
delaySendMessage = async (miliseconds, eventName, payload) => {
await delay(miliseconds)
this.emit(eventName, payload)
}

sendMessage = async (userId, message) => {
console.log(`Enviando... ${userId}, ${message}`)
Expand Down
2 changes: 1 addition & 1 deletion __test__/0.0.0-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suiteCase(`Responder a "hola"`, async ({ database, provider }) => {
suiteCase(`NO reponder a "pepe"`, async ({ database, provider }) => {
const flow = addKeyword('hola').addAnswer('Buenas!').addAnswer('Como vamos!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down
8 changes: 4 additions & 4 deletions __test__/0.0.1-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ suiteCase.after.each(clear)
suiteCase(`Responder a "EVENTS.LOCATION"`, async ({ database, provider }) => {
const flow = addKeyword(EVENTS.LOCATION).addAnswer('Gracias por tu location')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down Expand Up @@ -51,7 +51,7 @@ suiteCase(`Responder a "EVENTS.DOCUMENT"`, async ({ database, provider }) => {
suiteCase(`Responder a "EVENTS.WELCOME"`, async ({ database, provider }) => {
const flow = addKeyword(EVENTS.WELCOME).addAnswer('Bienvenido!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -71,7 +71,7 @@ suiteCase(`Responder a "EVENTS.WELCOME"`, async ({ database, provider }) => {
suiteCase(`Responder a "EVENTS.MEDIA"`, async ({ database, provider }) => {
const flow = addKeyword(EVENTS.MEDIA).addAnswer('gracias por la imagen o video!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -91,7 +91,7 @@ suiteCase(`Responder a "EVENTS.MEDIA"`, async ({ database, provider }) => {
suiteCase(`Responder a "EVENTS.VOICE_NOTE"`, async ({ database, provider }) => {
const flow = addKeyword(EVENTS.VOICE_NOTE).addAnswer('gracias por la nota de voz!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down
8 changes: 4 additions & 4 deletions __test__/0.0.2-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ suiteCase(`Debe saltar de flujo`, async ({ database, provider }) => {
})
.addAnswer('este mensaje no deberia existir')

createBot({
await createBot({
database,
flow: createFlow([flujoBienvenida]),
provider,
})

await provider.delaySendMessage(0, 'message', {
await provider.delaySendMessage(50, 'message', {
from: '000',
body: 'hola',
})
Expand All @@ -52,7 +52,7 @@ suiteCase(`Debe saltar de flujo con capture sin flowDynamic`, async ({ database,
})
.addAnswer('este mensaje no deberia existir')

createBot({
await createBot({
database,
flow: createFlow([flujoBienvenida]),
provider,
Expand Down Expand Up @@ -90,7 +90,7 @@ suiteCase(`Debe saltar de flujo con capture con flowDynamic`, async ({ database,
})
.addAnswer('este mensaje no deberia existir')

createBot({
await createBot({
database,
flow: createFlow([flujoBienvenida]),
provider,
Expand Down
4 changes: 2 additions & 2 deletions __test__/0.1.0-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ suiteCase.after.each(clear)
suiteCase(`Responder a "ole" en minuscula`, async ({ database, provider }) => {
const flow = addKeyword(['ola', 'ole'], { sensitive: true }).addAnswer('Bienvenido a la OLA')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -31,7 +31,7 @@ suiteCase(`Responder a "ole" en minuscula`, async ({ database, provider }) => {
suiteCase(`NO Responder a "ole" en minuscula`, async ({ database, provider }) => {
const flow = addKeyword(['ola', 'ole'], { sensitive: true }).addAnswer('Bienvenido a la OLA')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down
3 changes: 3 additions & 0 deletions __test__/0.1.1-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ suiteCase(`Debe continuar el flujo del hijo`, async ({ database, provider }) =>
body: 'hola',
})

await delay(0)
await provider.delaySendMessage(30, 'message', {
from: '000',
body: 'test@test.com',
})

await delay(0)
await provider.delaySendMessage(60, 'message', {
from: '000',
body: 'paypal',
Expand All @@ -66,6 +68,7 @@ suiteCase(`Debe continuar el flujo del hijo`, async ({ database, provider }) =>
body: 'continue!',
})

await delay(0)
await delay(800)
const getHistory = database.listHistory.map((i) => i.answer)

Expand Down
4 changes: 2 additions & 2 deletions __test__/0.1.2-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ suiteCase(`Responder a una expresion regular`, async ({ database, provider }) =>
.addAnswer(`Gracias por proporcionar un numero de tarjeta valido`)
.addAnswer('Fin!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -39,7 +39,7 @@ suiteCase(`NO Responder a una expresion regular`, async ({ database, provider })
.addAnswer(`Gracias por proporcionar un numero de tarjeta valido`)
.addAnswer('Fin!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down
2 changes: 1 addition & 1 deletion __test__/0.1.3-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ suiteCase(`Responder a "pregunta"`, async ({ database, provider }) => {
.addAnswer(['Hola como estas?', '¿Cual es tu edad?'], { capture: true })
.addAnswer('Gracias por tu respuesta')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down
22 changes: 11 additions & 11 deletions __test__/0.1.4-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ suiteCase(`Responder con un "string"`, async ({ database, provider }) => {
})
.addAnswer('y vos?')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -113,7 +113,7 @@ suiteCase(`Responder con un "array"`, async ({ database, provider }) => {
})
.addAnswer('y vos?')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -140,7 +140,7 @@ suiteCase(`Responder con un "object"`, async ({ database, provider }) => {
})
.addAnswer('y vos?')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down Expand Up @@ -171,23 +171,23 @@ suiteCase(`FlowDynamic con capture`, async ({ database, provider }) => {
)
.addAnswer('fin!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
})

await provider.delaySendMessage(0, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'hola',
})

await provider.delaySendMessage(10, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'mal',
})

await provider.delaySendMessage(20, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'bien',
})
Expand Down Expand Up @@ -232,7 +232,7 @@ suiteCase(`FlowDynamic con capture en hijo`, async ({ database, provider }) => {
[flowDos]
)

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand All @@ -243,17 +243,17 @@ suiteCase(`FlowDynamic con capture en hijo`, async ({ database, provider }) => {
body: 'hola',
})

await provider.delaySendMessage(10, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'flowDos',
})

await provider.delaySendMessage(20, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'flow3',
})

await provider.delaySendMessage(30, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'flow4',
})
Expand Down
16 changes: 8 additions & 8 deletions __test__/0.1.5-case.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ suiteCase(`Detener el flujo`, async ({ database, provider }) => {
return flowDynamic(data)
})

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down Expand Up @@ -70,7 +70,7 @@ suiteCase(`Detener el flujo flowDynamic`, async ({ database, provider }) => {
})
.addAnswer('Como estas!')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
Expand Down Expand Up @@ -117,33 +117,33 @@ suiteCase(`flowDynamic con capture`, async ({ database, provider }) => {
})
.addAnswer('Puedes pasar')

createBot({
await createBot({
database,
provider,
flow: createFlow([flow]),
})

await provider.delaySendMessage(0, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'hola',
})

await provider.delaySendMessage(10, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'this is not email value',
})

await provider.delaySendMessage(20, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: 'test@test.com',
})

await provider.delaySendMessage(90, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: '20',
})

await provider.delaySendMessage(200, 'message', {
await provider.delaySendMessage(100, 'message', {
from: '000',
body: '18',
})
Expand Down
Loading

0 comments on commit 52b438c

Please sign in to comment.