-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlegbot.js
37 lines (26 loc) · 854 Bytes
/
legbot.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
"use strict";
var log = require('./log.js');
log.info("Starting legbot");
var client = require('./client.js');
var Channel = require('./lib/channel.js');
var Web = require('./web');
client.client.on('connect', function(){
log.info("Connected!");
loadChannels();
});
function loadChannels(){
log.debug("Querying channels to join");
Channel.findActiveChannels(client.joinChannels);
}
//We do a clean disconnect on SIGINT before dying
process.on('SIGINT', function(){
log.info("Got SIGINT! Disconnecting IRC and exiting.");
client.client.disconnect("Time for off line LEG DAY!", function(){
log.info("Disconnected.");
});
//Instead of using the callback we set a 2 second timeout.
//Checking wether the IRC connection is active is a bit of a bother and can give a false answer.
setTimeout(function(){
process.exit();
}, 2000);
});