forked from andersonba/yve-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 758 Bytes
/
index.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
const fs = require('fs');
const yaml = require('js-yaml');
const prompt = require('prompt');
const YveBot = require('../../lib/core');
const example = yaml.load(fs.readFileSync(__dirname + '/../chat.yaml', 'utf8'));
const bot = new YveBot(example);
prompt.message = '';
prompt.start();
bot
.on('talk', (message, data) => {
console.log(message);
if (data.options && data.options.length) {
const options = data.options.map(o => o.value || o.label);
console.log(`Choose an option: [${options.join(', ')}]`);
}
})
.on('hear', () => {
prompt.get('You', (err, res) => {
if (err) { throw err; }
bot.hear(res.You);
});
})
.on('end', data => {
console.log('> Finished with data:', data);
})
.start();