mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 20:49:15 +00:00
UUID memory without relation UUID DB
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const { validateCtx } = require('../io/methods')
|
||||
const { printer } = require('../utils/interactive')
|
||||
|
||||
/**
|
||||
@@ -46,9 +47,9 @@ class CoreClass {
|
||||
* @private
|
||||
* @param {*} ctxMessage
|
||||
*/
|
||||
handleMsg = ({ body, from }) => {
|
||||
handleMsg = async ({ body, from }) => {
|
||||
let msgToSend = []
|
||||
const prevMsg = [...this.databaseClass.listHistory].pop()
|
||||
const prevMsg = await this.databaseClass.getPrevByNumber(from)
|
||||
|
||||
if (prevMsg?.ref && prevMsg?.options?.capture) {
|
||||
msgToSend = this.flowClass.find(prevMsg.ref, true) || []
|
||||
@@ -62,7 +63,7 @@ class CoreClass {
|
||||
const { answer } = ctxMessage
|
||||
return Promise.all([
|
||||
this.providerClass.sendMessage(numberOrId, answer),
|
||||
this.databaseClass.save(ctxMessage),
|
||||
this.databaseClass.save({ ...ctxMessage, from: numberOrId }),
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const { addAnswer } = require('./addAnswer')
|
||||
const { addKeyword } = require('./addKeyword')
|
||||
const { validateCtx } = require('./validateCtx')
|
||||
const { toJson } = require('./toJson')
|
||||
|
||||
module.exports = { addAnswer, addKeyword, toJson }
|
||||
module.exports = { addAnswer, addKeyword, validateCtx, toJson }
|
||||
|
||||
18
packages/bot/io/methods/validateCtx.js
Normal file
18
packages/bot/io/methods/validateCtx.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const { generateRef } = require('../../utils/hash')
|
||||
/**
|
||||
*
|
||||
* @param answer string
|
||||
* @param options {media:string, buttons:[], capture:true default false}
|
||||
* @returns
|
||||
*/
|
||||
const validateCtx = ({ body, from }) => {
|
||||
return {
|
||||
ref: generateRef(),
|
||||
keyword: null,
|
||||
answer: body,
|
||||
options: {},
|
||||
from,
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { validateCtx }
|
||||
Reference in New Issue
Block a user