-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.js
executable file
·56 lines (46 loc) · 1.56 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env node
"use strict";
process.on('uncaughtException', function(err) {
console.error(err);
});
var log = require("./lib/Logger.js");
var Update = require("./lib/Update.js");
var Server = require("./lib/Server.js").Server;
var Channel = require("./lib/Channel.js").Channel;
var settings = require("./config.js").settings;
if (settings.servers === 'undefined') {
log.critical("You haven't added any servers in the settings.");
process.exit();
}
var servers = [];
for (var i in settings.servers)
{
var serverSettings = settings.servers[i];
if (!serverSettings.address)
throw new Error("You forgot the server address for a server.");
if (!serverSettings.port)
serverSettings.port = 6667;
if (!serverSettings.pass)
serverSettings.pass = "";
if (!serverSettings.nick)
serverSettings.nick = settings.globalNick;
if (!serverSettings.userName)
serverSettings.userName = settings.globalUserName;
if (!serverSettings.realName)
serverSettings.realName = settings.globalRealName;
if (!serverSettings.commandPrefix)
serverSettings.commandPrefix = settings.defaultCommandPrefix;
var server = new Server(serverSettings);
server.modules.load(settings.globalServModules);
server.modules.load(serverSettings.modules);
if (typeof serverSettings.channels != 'undefined') {
for (var channelName in serverSettings.channels) {
var channel = new Channel(server, channelName);
channel.modules.load(settings.globalModules);
channel.modules.load(serverSettings.channels[channelName]);
server.addChannel(channel);
}
}
server.connect();
servers.push(server);
}