-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 748 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (29 loc) · 748 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
'use strict';
const readline = require('readline');
const reader = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: true,
});
reader.setPrompt('=> ');
const matcher = require('./matcher');
reader.prompt();
reader.on('line', replay => {
matcher(replay, data => {
// console.debug('reply', replay, 'data', data);
switch (data.intent) {
case 'HELLO_COMMAND':
console.info('привед!!! :)');
reader.prompt();
break;
case 'BYE_COMMAND':
console.info('пока... =(');
process.exit(0);
break;
default:
console.info(`Sorry, but I don't understand you! Exiting...`);
reader.prompt();
break;
}
});
});