-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
executable file
·34 lines (27 loc) · 913 Bytes
/
server.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
var bot = require('./lib/bot.js');
var commander = require('./lib/commander.js')
var outputChannel = require('./lib/outputChannel');
var config = require('config');
var controller = require('./controller.js')
var $env = process.env.NODE_ENV;
var $envCredentials = config.get('Credentials');
var $envRooms = config.get('Rooms');
var chatOptions = {
jid: $envCredentials.jid,
password: $envCredentials.password,
mentionName: $envCredentials.mentionName,
host: $envCredentials.host,
muc: $envCredentials.muc
}
var bmo = new bot.Client(chatOptions);
var oc = new outputChannel.Channel(bmo);
bmo.connect();
bmo.jabber.on('connected', function() {
bmo.joinRoom($envRooms, $envCredentials.userName);
});
bmo.jabber.on('joinedRoom', function(roomJid) {
bmo.announce(roomJid);
});
bmo.jabber.on('messageReceived', function(msg) {
controller(msg,oc);
});