forked from endoplasmic/google-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (24 loc) · 830 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
31
32
33
'use strict';
const EventEmitter = require('events');
const util = require('util');
const Assistant = require('./components/assistant');
const Auth = require('./components/auth');
const Conversation = require('./components/conversation');
function GoogleAssistant(config) {
if (config === undefined) config = {};
let assistant;
// we need to auth with Google right out of the gate
const auth = new Auth(config.auth);
auth.on('ready', (client) => {
assistant = new Assistant(client);
this.emit('ready', assistant);
});
this.start = (callback) => {
const conversation = new Conversation(assistant, config.audio);
this.emit('started', conversation);
if (callback) callback(conversation);
};
return this;
}
util.inherits(GoogleAssistant, EventEmitter);
module.exports = GoogleAssistant;