diff --git a/CHANGELOG.md b/CHANGELOG.md index a50ddea5a..c90b755aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,104 @@ 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.36](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.25...v0.1.36) (2024-01-22) + + +### Features + +* :art: next-version ([70d75ed](https://github.com/leifermendez/bot-whatsapp/commit/70d75edf8265be83a19259091ef98de5bbf56639)) +* :art: update + endflow default ([bdf4206](https://github.com/leifermendez/bot-whatsapp/commit/bdf420602b6dc596383f960df26bdce37a2b109f)) +* :fire: delay -> `flowDynamic` ([cb6d11b](https://github.com/leifermendez/bot-whatsapp/commit/cb6d11b3242d9ed8ea42d25e457123c52992c8b1)) +* :fire: delay -> `flowDynamic` ([8c23eae](https://github.com/leifermendez/bot-whatsapp/commit/8c23eaee69b117e6be276c48b96946cf512b8c33)) +* :zap: beta new features ([c34b207](https://github.com/leifermendez/bot-whatsapp/commit/c34b207e3fbb38130b036ba960d07600e606573f)) +* :zap: idle concat ([2d23d39](https://github.com/leifermendez/bot-whatsapp/commit/2d23d3907283cf2d64e0f004d9177810dcf787d9)) +* :zap: lot improvments ([2a1726b](https://github.com/leifermendez/bot-whatsapp/commit/2a1726bc41862e360e5066ac9ab7ed8dd17cb7c0)) +* :zap: lot improvments ([21a0730](https://github.com/leifermendez/bot-whatsapp/commit/21a0730c12bb8ffdd2d79a9c7cf5cbdfc5d5cb50)) +* :zap: queue by from ([8b43036](https://github.com/leifermendez/bot-whatsapp/commit/8b43036d85ba5bed3803d524ca71fc97886d66b1)) +* **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)) +* add eslint-plugin ([2df14e6](https://github.com/leifermendez/bot-whatsapp/commit/2df14e6f8923a4e640cf06ff8a83c50095a40e79)) +* add eslint-plugin ([5ca3313](https://github.com/leifermendez/bot-whatsapp/commit/5ca331334388c6bd59827a4cd3f5f9ecc5f8e22e)) +* add eslint-plugin ([769b7e8](https://github.com/leifermendez/bot-whatsapp/commit/769b7e812b9f47c5375b1e04ad0a35f2441380a3)) +* **bot:** :sparkles: feat ([589f96e](https://github.com/leifermendez/bot-whatsapp/commit/589f96efc26d03d622c85619656757f3dfb8c39e)) +* **bot:** :zap: add dynamic BlackList ([5a05414](https://github.com/leifermendez/bot-whatsapp/commit/5a054146b6a46cbe7e4a36865425eb0f8209eaf6)) +* **bot:** :zap: handler state ctx ([7f3f156](https://github.com/leifermendez/bot-whatsapp/commit/7f3f156c0c05c5f638ed521cb20613aa2243e863)) +* **bot:** :zap: idle feature ([e2a6cbd](https://github.com/leifermendez/bot-whatsapp/commit/e2a6cbd7091544907a4c6e5911ea351c4d1d8a42)) +* **database:** Se agrego sp para guardar y actualizar contactos en postgres ([574b0d3](https://github.com/leifermendez/bot-whatsapp/commit/574b0d35d1306c935ccb6490018e7c8dfbb73bbe)) +* fix gotoFlow addAction ([4ce4dbf](https://github.com/leifermendez/bot-whatsapp/commit/4ce4dbff0e23422cd4c82777b25de0b758b960be)) +* idle state ([a39c9d2](https://github.com/leifermendez/bot-whatsapp/commit/a39c9d2c954f167eb8768e4787d440b33cf4f7d0)) +* Integrate 'capture_only_intended' flag for silent execution in 'addAnswer' function ([e298b54](https://github.com/leifermendez/bot-whatsapp/commit/e298b546f4e91c2142ca09f4281a0faf694bfa7b)) +* meta add fileUrl image ([7b5f8fd](https://github.com/leifermendez/bot-whatsapp/commit/7b5f8fd9577ffb26feeaa670a5bfca84281b20e8)) +* next release ([158849f](https://github.com/leifermendez/bot-whatsapp/commit/158849fe99a80096719e09f348ba66d10c97d183)) +* next-release ([3f50a05](https://github.com/leifermendez/bot-whatsapp/commit/3f50a0577b82c493ae3b6c85af26e9f2f63b34c7)) +* **provider:** :fire: add tmp file twilio ([c99ab6c](https://github.com/leifermendez/bot-whatsapp/commit/c99ab6c6ea5a69790b3229a9700fea1a0d45d222)) +* **provider:** :memo: se actualizó el contexto (ctx) para incluir la url ([043b33c](https://github.com/leifermendez/bot-whatsapp/commit/043b33c860c489fed0b5251d06535cea42b75b01)) +* **provider:** :sparkles: the image, video, document, stickers, location and vcard events are added ([0705aeb](https://github.com/leifermendez/bot-whatsapp/commit/0705aeb6077fd151ccf7a37582f7afe64e089b36)) +* **provider:** :zap: meta fix ([dd849d6](https://github.com/leifermendez/bot-whatsapp/commit/dd849d63571bcd896d9cf9e47eee02dff784558f)) +* **provider:** :zap: meta fix ([f50acf2](https://github.com/leifermendez/bot-whatsapp/commit/f50acf2975fe5adb9bdb090f8bd6c056e171f3cb)) +* **provider:** ✨ WPPConnect added poll ([564d6bb](https://github.com/leifermendez/bot-whatsapp/commit/564d6bb31b972f2fdd559a1379cc54e64468e8fd)) +* **provider:** ✨Baileys added auth with Pairing Code ([a2622cc](https://github.com/leifermendez/bot-whatsapp/commit/a2622cc3a7388138034bd41722f812e552dfbf53)) +* **provider:** ✨Baileys added polls in baileys ([6374503](https://github.com/leifermendez/bot-whatsapp/commit/637450351baf32395c719d7a09d47ed0ef3e1fa1)) +* se adiciona la funcionalidad de enviar reacciones para el proveedor meta sendReaction ([abf89ff](https://github.com/leifermendez/bot-whatsapp/commit/abf89ff9d5f5ca8005fc738fda8d2fb56b044d31)) +* se adiciona la funcionalidad de enviar ubicacion para provedor meta ([73f0c69](https://github.com/leifermendez/bot-whatsapp/commit/73f0c6908405a18d3ae87e564ce00d441c92943a)) +* se adiciona la funcionalidad de enviar una ubicacion para el proveedor meta ([3f9942b](https://github.com/leifermendez/bot-whatsapp/commit/3f9942b53cd614c5a601f102d3f2ed52752e8acc)) + + +### Bug Fixes + +* :art: more ([35d1279](https://github.com/leifermendez/bot-whatsapp/commit/35d12792ec1b692abcc4aeedb0c7d640b776ee6b)) +* :art: pnpm ([122a7e1](https://github.com/leifermendez/bot-whatsapp/commit/122a7e1ab6b0288accba620f410ee7920ed3ff5d)) +* :art: pnpm ([bca9826](https://github.com/leifermendez/bot-whatsapp/commit/bca98268f84f033f8bb64d9146d7ccadea39a50c)) +* :art: working gotoFlow and capture ([baa7429](https://github.com/leifermendez/bot-whatsapp/commit/baa7429c73675c673850666fc58f0036cac8e66d)) +* :zap: bug ([28b3240](https://github.com/leifermendez/bot-whatsapp/commit/28b3240d4f1313356da393832fe616b9f06baa7d)) +* :zap: change quueu ([f43c236](https://github.com/leifermendez/bot-whatsapp/commit/f43c2363d5d6df49b16ba9a1f0c6643e9970c622)) +* :zap: core properties ([cff223b](https://github.com/leifermendez/bot-whatsapp/commit/cff223ba5839b961fea10316269d16a7b4c39a54)) +* :zap: delay after gotoFlow [#877](https://github.com/leifermendez/bot-whatsapp/issues/877) ([1eda39a](https://github.com/leifermendez/bot-whatsapp/commit/1eda39aa7756d7a8f62050775ded20709ad5faad)) +* :zap: issue [#865](https://github.com/leifermendez/bot-whatsapp/issues/865) ([2fe6bd5](https://github.com/leifermendez/bot-whatsapp/commit/2fe6bd569791f3481183bc9000145f9f48b07673)) +* :zap: issue [#910](https://github.com/leifermendez/bot-whatsapp/issues/910) ([6edf373](https://github.com/leifermendez/bot-whatsapp/commit/6edf3730e143c58b3bb36e1d748a6730e6392168)) +* :zap: meta video ([6cef90a](https://github.com/leifermendez/bot-whatsapp/commit/6cef90ad21913634ac3a50e5096eac8242645268)) +* :zap: next version ([fbce48f](https://github.com/leifermendez/bot-whatsapp/commit/fbce48f91c76ef44b87a10f60cd922a35fafb45e)) +* :zap: other queue ([54ad1d6](https://github.com/leifermendez/bot-whatsapp/commit/54ad1d65826ac78bd5da7e863bd56baafbeff362)) +* :zap: prevent queued process ([bbd744b](https://github.com/leifermendez/bot-whatsapp/commit/bbd744b09ee27692ac87888695c54b9ced02a410)) +* :zap: queue ([c380f06](https://github.com/leifermendez/bot-whatsapp/commit/c380f061926983a953b0f297f38003b98f02133a)) +* :zap: some ([d2d1409](https://github.com/leifermendez/bot-whatsapp/commit/d2d140993a2a4a6be6d55e8de7300decaf2613ab)) +* "provider twilio media & document " ([c3b2738](https://github.com/leifermendez/bot-whatsapp/commit/c3b273843afa0141e78e662fe1534f83287bc6e6)) +* **bot:** :fire: fix ([894edde](https://github.com/leifermendez/bot-whatsapp/commit/894eddefe161e7c87f049faa40e91ec1bc649a3f)) +* **bot:** :fire: se incorpora la funcionalidad de blacklist dinámica ([966834e](https://github.com/leifermendez/bot-whatsapp/commit/966834eb54967348fbb0bb88653add8c968ad121)) +* **bot:** :zap: hot fix `fotoFlow` and download ([dced080](https://github.com/leifermendez/bot-whatsapp/commit/dced08017c823791131a29ef4a5e81090800794c)) +* crypto url ([f8ff35e](https://github.com/leifermendez/bot-whatsapp/commit/f8ff35e401510e1614e6d6753b7ad42f5114fc16)) +* **database:** MySQL conection timeout ([8391037](https://github.com/leifermendez/bot-whatsapp/commit/8391037ff120265faeaa7277918b856d94294ff7)) +* default endFlow ([a522eeb](https://github.com/leifermendez/bot-whatsapp/commit/a522eeb2e92ed8c26ee4930e824ef95b7f863d2f)) +* fix ([085761a](https://github.com/leifermendez/bot-whatsapp/commit/085761abccac0647a05522d1373ff5c0da96f5f8)) +* fix ([a1eb16a](https://github.com/leifermendez/bot-whatsapp/commit/a1eb16a94689f30e0864f0f13f41c057b304d4d5)) +* fix twilio ([e122f67](https://github.com/leifermendez/bot-whatsapp/commit/e122f67751f49563dc2d0ea894da1da30dfa03e1)) +* fix twilio ([22112a3](https://github.com/leifermendez/bot-whatsapp/commit/22112a364d325aaa03b9ec27c438796cfb832e46)) +* fix twilio ([d9ff81c](https://github.com/leifermendez/bot-whatsapp/commit/d9ff81c539e2786fe1210bbd24f2c1da12d90058)) +* gloalState ([491e1f7](https://github.com/leifermendez/bot-whatsapp/commit/491e1f72974ce45f8d9a00145f3afb8dbe0e2189)) +* **hook:** :zap: event action ([e922dfc](https://github.com/leifermendez/bot-whatsapp/commit/e922dfce84a84a3c3ad00be6aa4e7758459e32bf)) +* idle ([07dd0fe](https://github.com/leifermendez/bot-whatsapp/commit/07dd0fe6dac2d18664e7b93e886dd7f5897e4e46)) +* idle second version ([79aa5e8](https://github.com/leifermendez/bot-whatsapp/commit/79aa5e8fdc1fff1d1e2b1d7590d3530b13bb31df)) +* idle second version ([924d029](https://github.com/leifermendez/bot-whatsapp/commit/924d029e0fcfe8eff5a26d0477343452f0a25204)) +* idle second version ([1f8f23c](https://github.com/leifermendez/bot-whatsapp/commit/1f8f23cbe26b91953d305ccc1bead6e7bf6a9b6f)) +* **io:** flow.Class some regular expressions don´t works ([a66d219](https://github.com/leifermendez/bot-whatsapp/commit/a66d2197432411634aebd0a1c31c900f731f625f)) +* **provider:** :bug: Fixed Puppeteer configuration ([f01bc76](https://github.com/leifermendez/bot-whatsapp/commit/f01bc76edababe8f57aced85db22f567477caf78)) +* **provider:** :fire: ([82d05aa](https://github.com/leifermendez/bot-whatsapp/commit/82d05aaad93bdba63cde3c7625b3b64274081ffc)) +* **provider:** :zap: change Bailey ([110a4b8](https://github.com/leifermendez/bot-whatsapp/commit/110a4b8d5fc25f2c11ea05c9d33d728830446fcc)) +* **provider:** :zap: change Bailey ([5d000af](https://github.com/leifermendez/bot-whatsapp/commit/5d000af98ff6a70613be7019dcfc9c638ea3d9aa)) +* **provider:** :zap: update GetMediaUrl and add audio url ([29a4f82](https://github.com/leifermendez/bot-whatsapp/commit/29a4f82b4beae705910d9cb1604b041e3169505a)) +* **provider:** :zap: version is added ([d4818f2](https://github.com/leifermendez/bot-whatsapp/commit/d4818f289d7e559fa46076c34c6ddfb1deaf427d)) +* **provider:** 🐛Fixed Baileys body Undefined sometimes ([8f90ee8](https://github.com/leifermendez/bot-whatsapp/commit/8f90ee8f2d8ccb396423af375819431ca772e486)) +* **provider:** 🐛Fixed get data mysql for baileys ([0f792da](https://github.com/leifermendez/bot-whatsapp/commit/0f792da5bdc668e82b31a061204ca1756614196d)) +* **provider:** 🐛Fixed get state message poll ([260c240](https://github.com/leifermendez/bot-whatsapp/commit/260c2406fc31fe8bacaa542dbc959e4618b82273)) +* **provider:** 🐛Fixed update version whatsapp-web.js ([464b34f](https://github.com/leifermendez/bot-whatsapp/commit/464b34f2e35d6cb7cdd0426179aec8f961d44f9c)) +* **provider:** meta improved 🔥 ([2f21dfd](https://github.com/leifermendez/bot-whatsapp/commit/2f21dfd2b9092736a190a0a1ce4a4fa3762999e0)) +* queue new ([e708dd9](https://github.com/leifermendez/bot-whatsapp/commit/e708dd9519b93cc0fd282800a78375224a6261da)) +* queue timer clear ([215ccfe](https://github.com/leifermendez/bot-whatsapp/commit/215ccfee6af38d54ada7636a2de59b13e667672c)) +* queue timer clear ([dab9e51](https://github.com/leifermendez/bot-whatsapp/commit/dab9e51a3b087cb6586f5fbdce0425979cc473f7)) +* release alpha ([99dba85](https://github.com/leifermendez/bot-whatsapp/commit/99dba8547024158ebaca76bb3d42b99dbbbc9897)) +* remove map ([e13f912](https://github.com/leifermendez/bot-whatsapp/commit/e13f9127c5c016192f98ef6d8aa923ea08755e23)) +* se soluciona problemas con sendContacts para el provider meta ([3bcbb97](https://github.com/leifermendez/bot-whatsapp/commit/3bcbb97979ccc144bc52e5edb5f74e3826909987)) +* some fix ([be07912](https://github.com/leifermendez/bot-whatsapp/commit/be079123587a50f490fd7b8addbd48bb528dfb6d)) + ### [0.1.27](https://github.com/leifermendez/bot-whatsapp/compare/v0.1.25...v0.1.27) (2023-05-28) diff --git a/package.json b/package.json index 9dffa403b..d8f12159d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/root", - "version": "0.1.34", + "version": "0.1.37", "description": "Bot de wahtsapp open source para MVP o pequeños negocios", "main": "app.js", "private": true, @@ -24,7 +24,7 @@ "build:full": "pnpm run build:portal-web && pnpm run cli:rollup && pnpm run bot:rollup && pnpm run provider:rollup && pnpm run database:rollup && pnpm run contexts:rollup && pnpm run create-bot-whatsapp:rollup && pnpm run eslint-plugin:rollup && pnpm run portal:rollup", "build": "pnpm run cli:rollup && pnpm run bot:rollup && pnpm run provider:rollup && pnpm run database:rollup && pnpm run contexts:rollup && pnpm run create-bot-whatsapp:rollup && pnpm run portal:rollup && pnpm run eslint-plugin:rollup", "copy.lib": "node ./scripts/move.js", - "test.unit": "node ./node_modules/uvu/bin.js packages test", + "test.unit": "node ./node_modules/uvu/bin.js packages test -i database-json", "test.e2e": "node ./node_modules/uvu/bin.js __test__ ", "test.coverage": "node ./node_modules/c8/bin/c8.js npm run test.unit", "test": "npm run test.coverage", diff --git a/packages/bot/context/idleState.class.js b/packages/bot/context/idleState.class.js index 35b5c018e..560fb950d 100755 --- a/packages/bot/context/idleState.class.js +++ b/packages/bot/context/idleState.class.js @@ -1,6 +1,10 @@ class IdleState { indexCb = new Map() + /** + * + * @param param0 + */ setIdleTime = ({ from, inRef, timeInSeconds, cb }) => { cb = cb ?? (() => {}) const startTime = new Date().getTime() @@ -33,7 +37,7 @@ class IdleState { /** * - * @param {*} param0 + * @param param0 * @returns */ get = ({ from, inRef }) => { @@ -47,15 +51,19 @@ class IdleState { } } + /** + * + * @param ctxInComming + */ stop = (ctxInComming) => { try { const queueCb = this.indexCb.get(ctxInComming.from) ?? [] for (const iterator of queueCb) { iterator.stop(ctxInComming) } + this.indexCb.set(ctxInComming.from, []) } catch (err) { - console.log(err) - return null + console.error(err) } } } diff --git a/packages/bot/core/core.class.js b/packages/bot/core/core.class.js index 06094a61f..1d18665d8 100644 --- a/packages/bot/core/core.class.js +++ b/packages/bot/core/core.class.js @@ -283,12 +283,19 @@ class CoreClass extends EventEmitter { const continueFlow = async (initRef = undefined) => { const currentPrev = await this.databaseClass.getPrevByNumber(from) - let nextFlow = (await this.flowClass.find(refToContinue?.ref, true)) ?? [] + + let nextFlow = this.flowClass.find(refToContinue?.ref, true) || [] if (initRef && !initRef?.idleFallBack) { - nextFlow = (await this.flowClass.find(initRef?.ref, true)) ?? [] + nextFlow = this.flowClass.find(initRef?.ref, true) || [] } - const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize) + const getContinueIndex = nextFlow.findIndex((msg) => msg.refSerialize === currentPrev?.refSerialize) + const indexToContinue = getContinueIndex !== -1 ? getContinueIndex : 0 + const filterNextFlow = nextFlow + .slice(indexToContinue) + .filter((i) => i.refSerialize !== currentPrev?.refSerialize) + + // const filterNextFlow = nextFlow.filter((msg) => msg.refSerialize !== currentPrev?.refSerialize); const isContinueFlow = filterNextFlow.map((i) => i.keyword).includes(currentPrev?.ref) if (!isContinueFlow) { @@ -482,7 +489,9 @@ class CoreClass extends EventEmitter { inRef, timeInSeconds: options.startIdleMs / 1000, cb: async (opts) => { - await runContext(true, { idleFallBack: opts.next, ref: opts.inRef, body: opts.body }) + if (opts?.next) { + await runContext(true, { idleFallBack: opts.next, ref: opts.inRef, body: opts.body }) + } }, }) return diff --git a/packages/bot/package.json b/packages/bot/package.json index 9a241685d..3deb201a8 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/bot", - "version": "0.0.223-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/bundle.bot.cjs", "scripts": { diff --git a/packages/cli/package.json b/packages/cli/package.json index eefedf2f5..2b3baabac 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/cli", - "version": "0.0.111-alpha.0", + "version": "0.1.37", "description": "", "main": "index.js", "devDependencies": { diff --git a/packages/contexts/package.json b/packages/contexts/package.json index d16829a29..85439b569 100644 --- a/packages/contexts/package.json +++ b/packages/contexts/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/contexts", - "version": "0.0.39-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/bundle.contexts.cjs", "files": [ diff --git a/packages/create-bot-whatsapp/package.json b/packages/create-bot-whatsapp/package.json index 66a2afc51..9b201e504 100644 --- a/packages/create-bot-whatsapp/package.json +++ b/packages/create-bot-whatsapp/package.json @@ -1,6 +1,6 @@ { "name": "create-bot-whatsapp", - "version": "0.0.141-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/bundle.create-bot-whatsapp.cjs", "files": [ diff --git a/packages/database/package.json b/packages/database/package.json index 5c2986ba0..0c57dbe93 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/database", - "version": "0.0.86-alpha.0", + "version": "0.1.37", "description": "Esto es el conector a mysql, pg, mongo", "main": "./lib/mock/index.cjs", "keywords": [], diff --git a/packages/eslint-plugin-bot-whatsapp/package.json b/packages/eslint-plugin-bot-whatsapp/package.json index a689f3ce7..4f3be902d 100644 --- a/packages/eslint-plugin-bot-whatsapp/package.json +++ b/packages/eslint-plugin-bot-whatsapp/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-bot-whatsapp", - "version": "0.0.4-alpha.0", + "version": "0.1.37", "description": "", "main": "./lib/eslint-plugin-bot-whatsapp.cjs", "files": [ diff --git a/packages/portal/package.json b/packages/portal/package.json index 7214ee7d4..5b1367de4 100644 --- a/packages/portal/package.json +++ b/packages/portal/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/portal", - "version": "0.0.44-alpha.0", + "version": "0.1.37", "description": "Portal WEB para escanear QR", "main": "./lib/portal.http.cjs", "scripts": { diff --git a/packages/provider/package.json b/packages/provider/package.json index 336a73926..6295af7fb 100644 --- a/packages/provider/package.json +++ b/packages/provider/package.json @@ -1,6 +1,6 @@ { "name": "@bot-whatsapp/provider", - "version": "0.0.161-alpha.0", + "version": "0.1.37", "description": "Esto es el conector a Twilio, Meta, etc...", "main": "./lib/mock/index.cjs", "keywords": [],