-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommander.js
More file actions
41 lines (35 loc) · 834 Bytes
/
commander.js
File metadata and controls
41 lines (35 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const {
co,
createSimpleMessage
} = require('./utils')
const STRINGS = require('./strings')
const HELP_MENU = `**/help** - see this menu
**/products** - see the list of products
**/forgetme** - exercise your right to be forgotten
`
module.exports = Commander
function Commander (api) {
this.api = api
}
const proto = Commander.prototype
proto.exec = co(function* ({ req, command }) {
let resp
switch (command) {
case '/help':
resp = HELP_MENU
break
case '/products':
return this.api.sendProductList({ req, to: req.user })
case '/forgetme':
return this.api.forgetUser({ req, user: req.user })
// case '/human':
// return this.api.sendProductList(req)
default:
resp = STRINGS.DONT_UNDERSTAND
break
}
return this.api.send({
req,
object: createSimpleMessage(resp)
})
})