Skip to content

Commit

Permalink
feat(bot): ⚡ add blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
leifermendez committed Jan 23, 2023
1 parent 3c4b1c0 commit 7078dc4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/bot/core/core.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class CoreClass {
flowClass
databaseClass
providerClass
constructor(_flow, _database, _provider) {
generalArgs = { blackList: [] }
constructor(_flow, _database, _provider, _args) {
this.flowClass = _flow
this.databaseClass = _database
this.providerClass = _provider
this.generalArgs = { ...this.generalArgs, ..._args }

for (const { event, func } of this.listenerBusEvents()) {
this.providerClass.on(event, func)
Expand Down Expand Up @@ -70,6 +72,7 @@ class CoreClass {
const { body, from } = messageCtxInComming
let msgToSend = []
let fallBackFlag = false
if (this.generalArgs.blackList.includes(from)) return
if (!body) return
if (!body.length) return

Expand Down
4 changes: 2 additions & 2 deletions packages/bot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const { addKeyword, addAnswer, addChild, toSerialize } = require('./io/methods')
* @param {*} args
* @returns
*/
const createBot = async ({ flow, database, provider }) =>
new CoreClass(flow, database, provider)
const createBot = async ({ flow, database, provider }, args = {}) =>
new CoreClass(flow, database, provider, args)

/**
* Crear instancia de clase Io (Flow)
Expand Down

0 comments on commit 7078dc4

Please sign in to comment.