Skip to content

Commit

Permalink
chore(release): 0.1.27
Browse files Browse the repository at this point in the history
chore(release): 0.1.27
  • Loading branch information
leifermendez committed May 28, 2023
2 parents a74dadd + 122a7e1 commit d05d1b1
Show file tree
Hide file tree
Showing 27 changed files with 2,867 additions and 2,959 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

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.27](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.25...v0.1.27) (2023-05-28)


### Features

* **adapter:** :zap: added that it automatically generates the date when the data is added to the db ([889cbfa](https://github.com/leifermendez/bot-whatsapp/commit/889cbfab8abfb76ed8e111e702bdad93483ae611))
* **provider:** :sparkles: the image, video, document, stickers, location and vcard events are added ([0705aeb](https://github.com/leifermendez/bot-whatsapp/commit/0705aeb6077fd151ccf7a37582f7afe64e089b36))


### Bug Fixes

* **bot:** :zap: hot fix `fotoFlow` and download ([dced080](https://github.com/leifermendez/bot-whatsapp/commit/dced08017c823791131a29ef4a5e81090800794c))
* **provider:** :zap: version is added ([d4818f2](https://github.com/leifermendez/bot-whatsapp/commit/d4818f289d7e559fa46076c34c6ddfb1deaf427d))
* **provider:** meta improved 🔥 ([2f21dfd](https://github.com/leifermendez/bot-whatsapp/commit/2f21dfd2b9092736a190a0a1ce4a4fa3762999e0))

### [0.1.25](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.23...v0.1.25) (2023-04-07)


Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/root",
"version": "0.1.25",
"version": "0.1.26",
"description": "Bot de wahtsapp open source para MVP o pequeños negocios",
"main": "app.js",
"private": true,
Expand Down Expand Up @@ -84,12 +84,12 @@
"standard-version": "^9.5.0",
"uvu": "^0.5.6"
},
"packageManager": "pnpm@7.25.1",
"packageManager": "pnpm@8.5.0",
"engines": {
"node": ">=16",
"npm": "please-use-pnpm",
"yarn": "please-use-pnpm",
"pnpm": ">=7.18.0"
"pnpm": ">=8.5.0"
},
"author": "Leifer Mendez <leifer.contacto@gmail.com>"
}
4 changes: 3 additions & 1 deletion packages/bot/core/core.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ class CoreClass {
const parseListMsg = await this.flowClass.find(flowParentId?.ref, true, flowTree)
if (endFlowFlag) return
for (const msg of parseListMsg) {
await this.sendProviderAndSave(from, msg)
const msgParse = this.flowClass.findSerializeByRef(msg?.ref)
const ctxMessage = { ...msgParse, ...msg }
await this.sendProviderAndSave(from, ctxMessage).then(() => resolveCbEveryCtx(ctxMessage))
}
await endFlow(flag)()
return
Expand Down
10 changes: 7 additions & 3 deletions packages/bot/io/flow.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class FlowClass {

const mapSensitive = (str, mapOptions = { sensitive: false, regex: false }) => {
if (mapOptions.regex) return new RegExp(str)
const regexSensitive = mapOptions.sensitive ? 'g' : 'i'
const regexSensitive = mapOptions.sensitive ? 'g' : 'gi'
if (Array.isArray(str)) {
return new RegExp(str.join('|'), regexSensitive)
const patterns = mapOptions.sensitive ? str.map((item) => `\\b${item}\\b`) : str
return new RegExp(patterns.join('|'), regexSensitive)
}
return new RegExp(str, regexSensitive)
const pattern = mapOptions.sensitive ? `\\b${str}\\b` : str
return new RegExp(pattern, regexSensitive)
}

const findIn = (keyOrWord, symbol = false, flow = overFlow) => {
Expand Down Expand Up @@ -60,6 +62,8 @@ class FlowClass {

findIndexByRef = (ref) => this.flowSerialize.findIndex((r) => r.ref === ref)

findSerializeByRef = (ref) => this.flowSerialize.find((r) => r.ref === ref)

getRefToContinueChild = (keyword) => {
try {
const flowChilds = this.flowSerialize
Expand Down
1 change: 0 additions & 1 deletion packages/bot/io/methods/addAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const addAnswer =
},
])

getCbFromNested()
const callbacks = {
...inCtx.callbacks,
...getCbFromNested(),
Expand Down
7 changes: 6 additions & 1 deletion packages/database/src/mongo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ class MongoAdapter {
}

save = async (ctx) => {
await this.db.collection('history').insert(ctx)
const ctxWithDate = {
...ctx,
date: new Date(),
}
await this.db.collection('history').insertOne(ctxWithDate)

this.listHistory.push(ctx)
}
}
Expand Down
10 changes: 6 additions & 4 deletions packages/database/src/mysql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ class MyslAdapter {
})

save = (ctx) => {
const values = [[ctx.ref, ctx.keyword, ctx.answer, ctx.refSerialize, ctx.from, JSON.stringify(ctx.options)]]
const sql = 'INSERT INTO history (ref, keyword, answer, refSerialize, phone, options ) values ?'
const values = [
[ctx.ref, ctx.keyword, ctx.answer, ctx.refSerialize, ctx.from, JSON.stringify(ctx.options), null],
]
const sql = 'INSERT INTO history (ref, keyword, answer, refSerialize, phone, options, created_at) values ?'

this.db.query(sql, [values], (err) => {
if (err) throw err
console.log('Guardado en DB...', values)
})
this.listHistory.push(ctx)
}

createTable = () =>
Expand All @@ -67,7 +68,8 @@ class MyslAdapter {
answer longtext NOT NULL,
refSerialize varchar(255) NOT NULL,
phone varchar(255) NOT NULL,
options longtext NOT NULL)
options longtext NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
CHARACTER SET utf8mb4 COLLATE utf8mb4_General_ci`

this.db.query(sql, (err) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/docs/essential/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Los proveedores disponibles hasta el momento son los siguientes:

[Venom](https://github.com/orkestral/venom) `require('@bot-whatsapp/provider/venom')`

[Baileys](https://github.com/adiwajshing/Baileys) `require('@bot-whatsapp/provider/baileys')`
[Baileys](https://github.com/whiskeysockets/Baileys) `require('@bot-whatsapp/provider/baileys')`

[Meta Official](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages) `require('@bot-whatsapp/provider/meta')`

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/docs/install/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Cada plantilla tiene sus dependencias necesarias basadas en tu previa selección
"@bot-whatsapp/cli": "latest",
"@bot-whatsapp/database": "latest",
"@bot-whatsapp/provider": "latest",
"@adiwajshing/baileys": "4.4.0",
"@adiwajshing/baileys": "github:WhiskeySockets/Baileys",
"mysql2": "^2.3.3", 👈
},
```
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/src/routes/docs/layout!.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default component$(() => {
<div class={'max-w-8xl'}>
<div
class={
'hidden lg:block fixed z-20 inset-0 top-[4rem] left-[max(0px,calc(50%-48rem))] right-auto w-[14.5rem] py-5 px-8 overflow-y-auto'
'hidden lg:block fixed z-20 inset-0 top-[4rem] right-auto w-[14.5rem] py-5 px-8 overflow-y-auto'
}
>
<NavBar options={store} />
Expand All @@ -33,7 +33,7 @@ export default component$(() => {
</div>
<div
class={
'hidden lg:block fixed z-20 inset-0 top-[4rem] right-[max(0px,calc(50%-48rem))] left-auto w-[14.5rem] py-5 px-8 overflow-y-auto'
'hidden lg:block fixed z-20 inset-0 top-[4rem] left-auto w-[14.5rem] py-5 px-8 overflow-y-auto'
}
>
<ExtraBar />
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/docs/providers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Los proveedores disponibles hasta el momento son los siguientes:

[Venom](https://github.com/orkestral/venom) `require('@bot-whatsapp/provider/venom')`

[Baileys](https://github.com/adiwajshing/Baileys) `require('@bot-whatsapp/provider/baileys')`
[Baileys](https://github.com/whiskeysockets/Baileys) `require('@bot-whatsapp/provider/baileys')`

[Meta Official](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages) `require('@bot-whatsapp/provider/meta')`

Expand Down
3 changes: 2 additions & 1 deletion packages/docs/src/routes/docs/providers/meta/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const main = async () => {
const adapterProvider = createProvider(MetaProvider, {
jwtToken: process.env.JWTOKEN, //EAARBW3ZBGU0UBAACDjtQIzI8JuEa.............
numberId: process.env.NUMBER_ID, //103975305758520
verifyToken: process.env.VERIFY_TOKEN, //LO_QUE_SEA
verifyToken: process.env.VERIFY_TOKEN, //LO_QUE_SEA,
version:'v16.0'
})

createBot({
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/docs/requirements/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ v18.12.1

- **Windows**: [Ver video](https://youtu.be/xRXHQlqA3Ak?t=376). Si necesitas ayuda para instalar Node en Windows. A continuación te comparto un video en el minuto exacto donde explico como instalar.
- **Ubuntu**: Te comparto un recurso de **[Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-20-04-es)** donde explica como instalar node en Ubuntu.
- **Mac-Os**: Te comparto un recurso de **[Digital Ocean] (https://www.digitalocean.com/community/tutorials/how-to-install-node-js-and-create-a-local-development-environment-on-macos)** donde explica como instalar node en Mac-Os.
- **Mac-Os**: Te comparto un recurso de **[Digital Ocean](https://www.digitalocean.com/community/tutorials/how-to-install-node-js-and-create-a-local-development-environment-on-macos)** donde explica como instalar node en Mac-Os.

---

Expand Down
2 changes: 1 addition & 1 deletion packages/provider/common/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const generalDownload = async (url) => {

const handleFile = (pathInput, ext) =>
new Promise((resolve, reject) => {
const fullPath = `${pathInput}.${ext}`
const fullPath = checkIsLocal ? `${pathInput}` : `${pathInput}.${ext}`
rename(pathInput, fullPath, (err) => {
if (err) reject(null)
resolve(fullPath)
Expand Down
2 changes: 1 addition & 1 deletion packages/provider/src/baileys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const logger = new Console({
/**
* ⚙️ BaileysProvider: Es una clase tipo adaptor
* que extiende clases de ProviderClass (la cual es como interfaz para sber que funciones rqueridas)
* https://github.com/adiwajshing/Baileys
* https://github.com/whiskeysockets/Baileys
*/
class BaileysProvider extends ProviderClass {
globalVendorArgs = { name: `bot`, gifPlayback: false }
Expand Down
2 changes: 1 addition & 1 deletion packages/provider/src/baileys/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@adiwajshing/baileys": "4.4.0",
"@adiwajshing/baileys": "github:WhiskeySockets/Baileys",
"wa-sticker-formatter": "4.3.2"
}
}
47 changes: 47 additions & 0 deletions packages/provider/src/meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class MetaProvider extends ProviderClass {
sendtext = async (number, message) => {
const body = {
messaging_product: 'whatsapp',
recipient_type: 'individual',
to: number,
type: 'text',
text: {
Expand Down Expand Up @@ -120,6 +121,52 @@ class MetaProvider extends ProviderClass {
}
return this.sendMessageMeta(body)
}

/**
* Enviar listas alternativo
* @param {*} number
* @param {*} header
* @param {*} text
* @param {*} footer
* @param {*} button
* @param {*} list
* @returns
*/
sendList = async (number, header, text, footer, button, list) => {
const parseList = list.map((list) => ({
title: list.title,
rows: list.rows.map((row) => ({
id: row.id,
title: row.title,
description: row.description,
})),
}))

const body = {
messaging_product: 'whatsapp',
recipient_type: 'individual',
to: number,
type: 'interactive',
interactive: {
type: 'list',
header: {
type: 'text',
text: header,
},
body: {
text: text,
},
footer: {
text: footer,
},
action: {
button: button,
sections: parseList,
},
},
}
return this.sendMessageMeta(body)
}
/**
* Enviar buttons
* @param {*} number
Expand Down
Loading

0 comments on commit d05d1b1

Please sign in to comment.