-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
35 lines (27 loc) · 852 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
35
var irc = require('irc');
var fs = require('fs');
var conf = JSON.parse(fs.readFileSync('config.json').toString());
var client = new irc.Client(conf.server, conf.nick, conf.client);
if (conf.password) {
client.addListener('notice', function (from, to, text) {
console.log(text);
if (text.indexOf('This nickname is registered.') != -1) {
client.say('NickServ', "identify " + conf.password);
console.log('Identifying...');
}
});
}
conf.modules.forEach(function(name) {
try {
var module = require(name);
module(client, conf);
} catch (e) {
console.log('Failed to load module %s - %s', name, e);
return;
}
console.log('Loaded module %s', name);
});
client.connect(conf.connectRetryCount, function() {
console.log('Connection established.');
});
console.log('Connecting to %s...', conf.server);