Skip to content

Commit

Permalink
chore: 🚀 next release 0.1.25
Browse files Browse the repository at this point in the history
chore: 🚀 next release 0.1.25
  • Loading branch information
leifermendez committed Mar 5, 2023
2 parents bb8cd2c + c9565bc commit f573720
Show file tree
Hide file tree
Showing 24 changed files with 705 additions and 142 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,3 @@ jobs:

- name: Release Github
run: node ./scripts/github.js --version="${{ steps.package-version.outputs.current-version}}" --token="${{ secrets.OCTO_TOKEN }}"

- name: Commit & Push changes
uses: actions-js/push@master
with:
branch: release/production
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

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.24](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.23...v0.1.24) (2023-03-05)


### Features

* **bot:** :sparkles: feat ([d3f86db](https://github.com/leifermendez/bot-whatsapp/commit/d3f86db7df7f6807262cbbf26108ed3f233b239c))
* **bot:** :sparkles: `.addAction` feat ([f3d73cc](https://github.com/leifermendez/bot-whatsapp/commit/f3d73cc3ee7904e947a4ae502f1cfef14b92bf34))
* **bot:** :sparkles: `.addAction` feat ([d94459a](https://github.com/leifermendez/bot-whatsapp/commit/d94459a2b17db0503db560ef7336b090ad1f8628))
* **bot:** :sparkles: `.addAction` feat ([70a23b7](https://github.com/leifermendez/bot-whatsapp/commit/70a23b77ade4c38d20be89d2304d831e605e39d6))
* **bot:** :sparkles: `.addAction` feat ([6adbe32](https://github.com/leifermendez/bot-whatsapp/commit/6adbe323de5bfa56565f0b29c21c98dde968a886))
* **cli:** :fire: added new provider in the cli ([9c6db88](https://github.com/leifermendez/bot-whatsapp/commit/9c6db884ee5d6553a46260229cc4e98faeb2710a))
* **cli:** :fire: added new provider in the cli ([dbb1732](https://github.com/leifermendez/bot-whatsapp/commit/dbb1732e5ceb30664dd6d7b18b99b279b81d1b20))
* **provider:** :sparkles: update starte `wppconnect` ([021a842](https://github.com/leifermendez/bot-whatsapp/commit/021a842dc46f1943766f302799ee51acee384f75))
* **provider:** :zap: add `delay` general ([9f02ed5](https://github.com/leifermendez/bot-whatsapp/commit/9f02ed59a3b33d7a1b8ab52d443be2d5b3b31702))
* **provider:** :zap: redirect download ([371d210](https://github.com/leifermendez/bot-whatsapp/commit/371d210c6992ead6684bfd0dd19b0755963df034))


### Bug Fixes

* **adapter:** :zap: fix error mongo duplicate INDEX ([244c6fb](https://github.com/leifermendez/bot-whatsapp/commit/244c6fb833157788d59ac581502d178dc34daa49))
* **provider:** :bug: call event by list ([79d78af](https://github.com/leifermendez/bot-whatsapp/commit/79d78af63dbaf3df374bc1bf1cb5ef87a8c821c2))
* **provider:** redirect 306 ([cfd0200](https://github.com/leifermendez/bot-whatsapp/commit/cfd02002be3195568b41969140e254020702bc0d))

### [0.1.23](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.22...v0.1.23) (2023-02-27)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bot-whatsapp/root",
"version": "0.1.23",
"version": "0.1.24",
"description": "Bot de wahtsapp open source para MVP o pequeños negocios",
"main": "app.js",
"private": true,
Expand Down
16 changes: 10 additions & 6 deletions packages/bot/core/core.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CoreClass {
flowClass
databaseClass
providerClass
generalArgs = { blackList: [], listEvents: {} }
generalArgs = { blackList: [], listEvents: {}, delay: 0 }
constructor(_flow, _database, _provider, _args) {
this.flowClass = _flow
this.databaseClass = _database
Expand Down Expand Up @@ -77,12 +77,12 @@ class CoreClass {
let fallBackFlag = false
if (this.generalArgs.blackList.includes(from)) return
if (!body) return
if (!body.length) return

let prevMsg = await this.databaseClass.getPrevByNumber(from)
const refToContinue = this.flowClass.findBySerialize(prevMsg?.refSerialize)

if (prevMsg?.ref) {
delete prevMsg._id
const ctxByNumber = toCtx({
body,
from,
Expand Down Expand Up @@ -130,7 +130,7 @@ class CoreClass {
const queue = []
for (const ctxMessage of messageToSend) {
if (endFlowFlag) return
const delayMs = ctxMessage?.options?.delay || 0
const delayMs = ctxMessage?.options?.delay ?? this.generalArgs.delay ?? 0
if (delayMs) await delay(delayMs)
await QueuePrincipal.enqueue(() =>
this.sendProviderAndSave(numberOrId, ctxMessage).then(() => resolveCbEveryCtx(ctxMessage))
Expand Down Expand Up @@ -301,8 +301,12 @@ class CoreClass {
*/
sendProviderAndSave = async (numberOrId, ctxMessage) => {
const { answer } = ctxMessage
await this.providerClass.sendMessage(numberOrId, answer, ctxMessage)
await this.databaseClass.save({ ...ctxMessage, from: numberOrId })

if (answer && answer.length && answer !== '__call_action__') {
await this.providerClass.sendMessage(numberOrId, answer, ctxMessage)
await this.databaseClass.save({ ...ctxMessage, from: numberOrId })
}

return
}

Expand Down Expand Up @@ -331,7 +335,7 @@ class CoreClass {
sendFlowSimple = async (messageToSend, numberOrId) => {
const queue = []
for (const ctxMessage of messageToSend) {
const delayMs = ctxMessage?.options?.delay || 0
const delayMs = ctxMessage?.options?.delay ?? this.generalArgs.delay ?? 0
if (delayMs) await delay(delayMs)
QueuePrincipal.enqueue(() => this.sendProviderAndSave(numberOrId, ctxMessage))
}
Expand Down
3 changes: 3 additions & 0 deletions packages/bot/io/methods/addAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const addAction = () => async () => {}

module.exports = { addAction }
1 change: 1 addition & 0 deletions packages/bot/io/methods/addAnswer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const addAnswer =
ctx,
ref: ctx.ref,
addAnswer: addAnswer(ctx),
addAction: (cb = () => null) => addAnswer(ctx)('__call_action__', null, cb),
toJson: toJson(ctx),
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/bot/io/methods/addKeyword.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const addKeyword = (keyword, options) => {
ctx,
ref: ctx.ref,
addAnswer: addAnswer(ctx),
addAction: (cb = () => null) => addAnswer(ctx)('__call_action__', null, cb),
toJson: toJson(ctx),
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/configuration/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const PROVIDER_LIST = [
{ value: 'baileys', label: 'Baileys', hint: 'gratis' },
{ value: 'venom', label: 'Venom', hint: 'gratis' },
{ value: 'wweb', label: 'whatsapp-web.js', hint: 'gratis' },
{ value: 'wppconnect', label: 'WPPConnect', hint: 'gratis' },
{ value: 'wweb', label: 'Whatsapp-web.js', hint: 'gratis' },
{ value: 'twilio', label: 'Twilio' },
{ value: 'meta', label: 'Meta' },
]
Expand Down
4 changes: 2 additions & 2 deletions packages/provider/common/download.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mimeDep = require('mime-types')
const { tmpdir } = require('os')
const http = require('http')
const https = require('https')
const http = require('follow-redirects').http
const https = require('follow-redirects').https
const { rename, createWriteStream } = require('fs')

/**
Expand Down
8 changes: 6 additions & 2 deletions packages/provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
],
"dependencies": {
"@bot-whatsapp/bot": "*",
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"combine-image": "^1.0.3",
"fluent-ffmpeg": "^2.1.2",
"qr-image": "^3.2.0",
"rimraf": "^3.0.2",
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"fluent-ffmpeg": "^2.1.2"
"sharp": "^0.30.5"
},
"exports": {
"./mock": "./lib/mock/index.cjs",
Expand All @@ -29,5 +30,8 @@
"repository": {
"type": "git",
"url": "https://github.com/codigoencasa/bot-whatsapp/tree/main/packages/provider"
},
"devDependencies": {
"follow-redirects": "^1.15.2"
}
}
6 changes: 4 additions & 2 deletions packages/provider/src/baileys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class BaileysProvider extends ProviderClass {
}

//Detectar location
if (messageCtx.message.locationMessage) {
if (messageCtx.message?.locationMessage) {
const { degreesLatitude, degreesLongitude } = messageCtx.message.locationMessage
if (typeof degreesLatitude === 'number' && typeof degreesLongitude === 'number') {
payload = { ...payload, body: generateRefprovider('_event_location_') }
Expand Down Expand Up @@ -156,9 +156,11 @@ class BaileysProvider extends ProviderClass {
}

const btnCtx = payload?.message?.buttonsResponseMessage?.selectedDisplayText

if (btnCtx) payload.body = btnCtx

const listRowId = payload?.message?.listResponseMessage?.singleSelectReply?.selectedRowId
if (listRowId) payload.body = listRowId

payload.from = baileyCleanNumber(payload.from, true)
this.emit('message', payload)
},
Expand Down
Loading

0 comments on commit f573720

Please sign in to comment.