mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 04:29:16 +00:00
next save conversation
This commit is contained in:
@@ -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()],
|
||||
|
||||
Reference in New Issue
Block a user