Skip to content

Commit

Permalink
Merge 7de0fb0 into 1572a46
Browse files Browse the repository at this point in the history
  • Loading branch information
Scar26 authored Jul 20, 2020
2 parents 1572a46 + 7de0fb0 commit b0fb841
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ const ctx = fs.readFileSync(`${__dirname}/factory.js`).toString()
const { NlpManager } = require('node-nlp')

class Bot {
constructor (name, greeting, trainingSet) {
constructor (name, greeting, trainingSet, defaultResponse) {
this.name = name
this.greeting = greeting
this.defaultResponse = defaultResponse
this.training = {
state: false,
data: trainingSet
Expand All @@ -22,8 +23,8 @@ class Bot {
this.factory.run(`trainingSet=${trainingSet}`)
}

greet () {
return this.render(this.greeting)
greet (token) {
return this.render(this.greeting, token)
}

addUser (token, name) {
Expand All @@ -47,6 +48,9 @@ class Bot {
} else {
message = response.body
}
if (!message) {
message = this.defaultResponse
}
message = this.render(message, token)
return { action: response.action, body: message }
}
Expand Down

0 comments on commit b0fb841

Please sign in to comment.