-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsecondUnit.js
58 lines (45 loc) · 1.03 KB
/
secondUnit.js
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const {say, next, exec, end, match, take, getvar} = require('../../')
//
// dialogs tag shortcuts
//
const restart = 'secondUnit.restart'
const dogIntroduction = 'firstUnit.dogIntroduction'
const secondUnit = {
/**
* askRestart
* output state function
*/
askRestart() {
say('Do you want to restart?')
next(restart)
},
/**
* verifyName
* input state function
*
* @param {requestDataObject} request
*
*/
restart(request) {
switch(take(request)) {
// yes
case match( /^(yes|ok|true|right|correct|sure)/i ):
exec(dogIntroduction)
break
// no
case match( /^no/i ):
// terminate the dialog
// get a variable from another unit
say(`See you again ${getvar('firstName', 'firstUnit')}!`)
end()
break
// balblabla
default:
say('I do not understand.')
say('Do you want to restart?')
next(restart)
break
}
}
}
module.exports = secondUnit