mirror of
https://github.com/cheveguerra/bot-whatsapp.git
synced 2026-04-20 12:39:24 +00:00
.
This commit is contained in:
20
packages/io/classes/flow.class.js
Normal file
20
packages/io/classes/flow.class.js
Normal file
@@ -0,0 +1,20 @@
|
||||
class FlowClass {
|
||||
flow
|
||||
constructor(_flow) {
|
||||
this.flow = _flow
|
||||
}
|
||||
|
||||
find = (message, ref = false) => {
|
||||
let keyRef = ref
|
||||
let ansRef = null
|
||||
if (!keyRef) {
|
||||
keyRef =
|
||||
this.flow.find((n) => n.keyword.includes(message))?.ref || null
|
||||
}
|
||||
ansRef = this.flow.find((n) => n.keyword === keyRef)
|
||||
if (ansRef) return ansRef
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FlowClass
|
||||
@@ -1,4 +1,3 @@
|
||||
const { addKeyword, addAnswer } = require('./methods')
|
||||
module.exports = { addKeyword, addAnswer }
|
||||
|
||||
|
||||
const FlowClass = require('./classes/flow.class')
|
||||
module.exports = { addKeyword, addAnswer, instance: FlowClass }
|
||||
|
||||
@@ -4,16 +4,6 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"io:dev": "node ./index.js",
|
||||
"io:rollup": "node ../../node_modules/.bin/rollup index.js --config ./rollup-cli.config.js",
|
||||
"format:check": "prettier --check .",
|
||||
"format:write": "prettier --write .",
|
||||
"lint:check": "eslint .",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"test:io": "node ../../node_modules/uvu/bin.js tests",
|
||||
"build:io": "npm run format:write && npm run lint:fix && npm run io:rollup"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
||||
@@ -3,7 +3,7 @@ const commonjs = require('@rollup/plugin-commonjs')
|
||||
module.exports = {
|
||||
input: 'index.js',
|
||||
output: {
|
||||
file: 'lib/io/bundle.cjs',
|
||||
file: 'lib/io/bundle.io.cjs',
|
||||
format: 'cjs',
|
||||
},
|
||||
plugins: [commonjs()],
|
||||
|
||||
Reference in New Issue
Block a user