mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-17 19:26:23 +00:00
next save conversation
This commit is contained in:
12
package.json
12
package.json
@@ -14,7 +14,7 @@
|
||||
"lint:check": "eslint ./packages",
|
||||
"lint:fix": "eslint --fix ./packages",
|
||||
"build": "yarn run cli:rollup && yarn run bot:rollup && yarn run provider:rollup && yarn run database:rollup",
|
||||
"link.dist": "",
|
||||
"link.dist": "cd packages/bot && npm link && cd ../provider && npm link && cd ../cli && npm link",
|
||||
"test.unit": "node ./node_modules/uvu/bin.js packages test",
|
||||
"test.e2e": "node ./node_modules/uvu/bin.js __tests__ test",
|
||||
"test.coverage": "node ./node_modules/c8/bin/c8.js --check-coverage --lines=90 npm run test.unit",
|
||||
@@ -46,13 +46,12 @@
|
||||
],
|
||||
"repository": "https://github.com/leifermendez/bot-whatsapp",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@rollup/plugin-json": "^5.0.1",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@rollup/plugin-replace": "^5.0.1"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^23.0.2",
|
||||
"@rollup/plugin-json": "^5.0.1",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@rollup/plugin-replace": "^5.0.1",
|
||||
"c8": "^7.12.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.26.0",
|
||||
@@ -61,6 +60,7 @@
|
||||
"prompts": "^2.4.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^3.2.3",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-copy": "^3.4.0",
|
||||
"uvu": "^0.5.6"
|
||||
},
|
||||
|
||||
@@ -46,9 +46,8 @@ class CoreClass {
|
||||
* @private
|
||||
* @param {*} ctxMessage
|
||||
*/
|
||||
handleMsg = ({ body, to, from }) => {
|
||||
handleMsg = ({ body, from }) => {
|
||||
let msgToSend = []
|
||||
console.log('____', this.databaseClass.listHistory)
|
||||
const prevMsg = [...this.databaseClass.listHistory].pop()
|
||||
|
||||
if (prevMsg?.ref && prevMsg?.options?.capture) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@bot-whatsapp/cli": "*",
|
||||
"@bot-whatsapp/provider": "*",
|
||||
"kleur": "^4.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
const { test } = require('uvu')
|
||||
const assert = require('uvu/assert')
|
||||
const MockProvider = require('../../../__mocks__/mock.provider')
|
||||
const { createBot, CoreClass } = require('@bot-whatsapp/bot')
|
||||
const { createBot, CoreClass } = require('../index')
|
||||
|
||||
class MockFlow {
|
||||
find = () => {}
|
||||
}
|
||||
|
||||
class MockDB {
|
||||
listHistory = []
|
||||
save = () => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
class MockDatabase {
|
||||
listHistory = []
|
||||
|
||||
constructor() {}
|
||||
constructor() {
|
||||
/**
|
||||
* Se debe cargar listHistory con historial de mensajes
|
||||
* para que se pueda continuar el flow
|
||||
*/
|
||||
}
|
||||
|
||||
save = (ctx) => {
|
||||
console.log('Guardando DB...', ctx)
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
class DatabaseClass {
|
||||
history = []
|
||||
engineDB
|
||||
constructor(_engineDB) {
|
||||
this.engineDB = _engineDB
|
||||
}
|
||||
|
||||
/**
|
||||
* Se debe guardar mensaje numero
|
||||
* @param {*} ctx
|
||||
* @returns
|
||||
*/
|
||||
saveLog = (ctx) => {
|
||||
this.history.pop()
|
||||
this.history.push(ctx)
|
||||
this.engineDB.save(ctx)
|
||||
return ctx
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DatabaseClass
|
||||
@@ -1,12 +0,0 @@
|
||||
const DatabaseClass = require('./classes/database.class')
|
||||
|
||||
/**
|
||||
* Crear instancia de clase
|
||||
* @param {*} args
|
||||
* @returns
|
||||
*/
|
||||
const create = async (engineClass) => {
|
||||
return new DatabaseClass(engineClass)
|
||||
}
|
||||
|
||||
module.exports = { create }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@bot-whatsapp/database",
|
||||
"version": "0.0.1",
|
||||
"description": "Esto es el conector a mysql, pg, mongo",
|
||||
"main": "index.js",
|
||||
"main": "./lib/bundle.database.cjs",
|
||||
"private": true,
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
||||
@@ -2,7 +2,7 @@ const commonjs = require('@rollup/plugin-commonjs')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const { join } = require('path')
|
||||
|
||||
const PATH = join(__dirname, 'lib', 'database', 'bundle.database.cjs')
|
||||
const PATH = join(__dirname, 'lib', 'bundle.database.cjs')
|
||||
|
||||
module.exports = {
|
||||
input: join(__dirname, 'index.js'),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@bot-whatsapp/provider",
|
||||
"version": "0.0.1",
|
||||
"description": "Esto es el conector a Twilio, Meta, etc...",
|
||||
"main": "./lib/bundle.mock.cjs",
|
||||
"main": "./lib/mock/index.cjs",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"test.unit": "cross-env NODE_ENV=test node ../../node_modules/uvu/bin.js tests"
|
||||
@@ -15,6 +15,8 @@
|
||||
"qr-image": "^3.2.0"
|
||||
},
|
||||
"files": [
|
||||
"./lib/*"
|
||||
"./lib/mock/*",
|
||||
"./lib/twilio/*",
|
||||
"./lib/web-whatsapp/*"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = [
|
||||
{
|
||||
input: join(__dirname, 'web-whatsapp', 'index.js'),
|
||||
output: {
|
||||
file: join(__dirname, 'lib', 'bundle.web-whatsapp.cjs'),
|
||||
file: join(__dirname, 'lib', 'web-whatsapp', 'index.cjs'),
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
@@ -13,7 +13,7 @@ module.exports = [
|
||||
{
|
||||
input: join(__dirname, 'twilio', 'index.js'),
|
||||
output: {
|
||||
file: join(__dirname, 'lib', 'bundle.twilio.cjs'),
|
||||
file: join(__dirname, 'lib', 'twilio', 'index.cjs'),
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
@@ -21,7 +21,7 @@ module.exports = [
|
||||
{
|
||||
input: join(__dirname, 'mock', 'index.js'),
|
||||
output: {
|
||||
file: join(__dirname, 'lib', 'bundle.mock.cjs'),
|
||||
file: join(__dirname, 'lib', 'mock', 'index.cjs'),
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
|
||||
46
yarn.lock
46
yarn.lock
@@ -501,6 +501,11 @@ estraverse@^5.1.0, estraverse@^5.2.0:
|
||||
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
|
||||
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
|
||||
|
||||
estree-walker@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
|
||||
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==
|
||||
|
||||
estree-walker@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac"
|
||||
@@ -847,6 +852,15 @@ istanbul-reports@^3.1.4:
|
||||
html-escaper "^2.0.0"
|
||||
istanbul-lib-report "^3.0.0"
|
||||
|
||||
js-cleanup@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/js-cleanup/-/js-cleanup-1.2.0.tgz#8dbc65954b1d38b255f1e8cf02cd17b3f7a053f9"
|
||||
integrity sha512-JeDD0yiiSt80fXzAVa/crrS0JDPQljyBG/RpOtaSbyDq03VHa9szJWMaWOYU/bcTn412uMN2MxApXq8v79cUiQ==
|
||||
dependencies:
|
||||
magic-string "^0.25.7"
|
||||
perf-regexes "^1.0.1"
|
||||
skip-regex "^1.0.2"
|
||||
|
||||
js-sdsl@^4.1.4:
|
||||
version "4.1.5"
|
||||
resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.5.tgz#1ff1645e6b4d1b028cd3f862db88c9d887f26e2a"
|
||||
@@ -906,6 +920,13 @@ lodash.merge@^4.6.2:
|
||||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
|
||||
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
|
||||
|
||||
magic-string@^0.25.7:
|
||||
version "0.25.9"
|
||||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"
|
||||
integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
|
||||
dependencies:
|
||||
sourcemap-codec "^1.4.8"
|
||||
|
||||
magic-string@^0.26.4:
|
||||
version "0.26.7"
|
||||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.26.7.tgz#caf7daf61b34e9982f8228c4527474dac8981d6f"
|
||||
@@ -1051,6 +1072,11 @@ path-type@^4.0.0:
|
||||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
||||
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
||||
|
||||
perf-regexes@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/perf-regexes/-/perf-regexes-1.0.1.tgz#6da1d62f5a94bf9353a0451bccacf69068b75d0b"
|
||||
integrity sha512-L7MXxUDtqr4PUaLFCDCXBfGV/6KLIuSEccizDI7JxT+c9x1G1v04BQ4+4oag84SHaCdrBgQAIs/Cqn+flwFPng==
|
||||
|
||||
picomatch@^2.3.1:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
|
||||
@@ -1125,6 +1151,14 @@ rimraf@^3.0.2:
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rollup-plugin-cleanup@^3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-cleanup/-/rollup-plugin-cleanup-3.2.1.tgz#8cbc92ecf58babd7c210051929797f137bbf777c"
|
||||
integrity sha512-zuv8EhoO3TpnrU8MX8W7YxSbO4gmOR0ny06Lm3nkFfq0IVKdBUtHwhVzY1OAJyNCIAdLiyPnOrU0KnO0Fri1GQ==
|
||||
dependencies:
|
||||
js-cleanup "^1.2.0"
|
||||
rollup-pluginutils "^2.8.2"
|
||||
|
||||
rollup-plugin-copy@^3.4.0:
|
||||
version "3.4.0"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-copy/-/rollup-plugin-copy-3.4.0.tgz#f1228a3ffb66ffad8606e2f3fb7ff23141ed3286"
|
||||
@@ -1136,6 +1170,13 @@ rollup-plugin-copy@^3.4.0:
|
||||
globby "10.0.1"
|
||||
is-plain-object "^3.0.0"
|
||||
|
||||
rollup-pluginutils@^2.8.2:
|
||||
version "2.8.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
|
||||
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
|
||||
dependencies:
|
||||
estree-walker "^0.6.1"
|
||||
|
||||
rollup@^3.2.3:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.3.0.tgz#ae8dc84808a9c75d775d8b2ed8db1adada31a581"
|
||||
@@ -1184,6 +1225,11 @@ sisteransi@^1.0.5:
|
||||
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
|
||||
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
|
||||
|
||||
skip-regex@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/skip-regex/-/skip-regex-1.0.2.tgz#ac655d77e7c771ac2b9f37585fea37bff56ad65b"
|
||||
integrity sha512-pEjMUbwJ5Pl/6Vn6FsamXHXItJXSRftcibixDmNCWbWhic0hzHrwkMZo0IZ7fMRH9KxcWDFSkzhccB4285PutA==
|
||||
|
||||
slash@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
|
||||
|
||||
Reference in New Issue
Block a user