1
0

Separate intents to separate modules

This commit is contained in:
2018-04-22 22:02:53 +02:00
parent 0f1d9e7f39
commit b3bc949e01
7 changed files with 92 additions and 50 deletions

View File

@@ -0,0 +1,20 @@
const normalize = str => str.toLowerCase()
const intents = {
default: require('./default'),
start: require('./start'),
drink: require('./drink'),
debug: require('./debug'),
}
const get = msg => {
const text = normalize(msg.text)
const intent = Object.keys(intents).find(
k => intents[k].keywords.indexOf(text) !== -1
)
return intent ? intents[intent].run : intents.default.run
}
module.exports = {
get,
}