Separate intents to separate modules
This commit is contained in:
20
bot/facebook/intents/index.js
Normal file
20
bot/facebook/intents/index.js
Normal 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,
|
||||
}
|
||||
Reference in New Issue
Block a user