Refactoring

This commit is contained in:
Mattias Erming 2014-09-13 10:10:32 -07:00
parent 221ed4b980
commit b3b36282aa
3 changed files with 25 additions and 27 deletions

View File

@ -1,7 +1,7 @@
module.exports = {
public: true,
host: "0.0.0.0",
port: 9090,
port: 9000,
theme: "themes/example.css",
home: "",
debug: false

View File

@ -54,15 +54,12 @@ function Client(sockets, config) {
});
if (config) {
var client = this;
var wait_total = 0;
_.each(config.networks || [], function(n) {
if (wait_total == 0)
client.connect(n);
else
var delay = 0;
(config.networks || []).forEach(function(n) {
setTimeout(function() {
client.connect(n);
}, wait_total);
wait_total += 500;
}, delay);
delay += 1000;
});
}
}
@ -96,11 +93,12 @@ Client.prototype.find = function(id) {
Client.prototype.connect = function(args) {
var client = this;
var server = _.defaults(_.pick(args, ['host', 'port', 'rejectUnauthorized', 'name']), {
host: "irc.freenode.org",
port: args.tls ? 6697 : 6667,
var server = {
host: args.host || "irc.freenode.org",
port: args.port || (args.tls ? 6697 : 6667),
name: args.name || "",
rejectUnauthorized: false
});
};
var stream = args.tls ? tls.connect(server) : net.connect(server);
stream.on("error", function(e) {

View File

@ -7,9 +7,9 @@ var Helper = module.exports = {
getHomeDirectory: function () {
return (
this.getConfig().home ||
process.env.SHOUT_HOME ||
path.resolve(process.env.HOME, ".shout")
this.getConfig().home
|| process.env.SHOUT_HOME
|| path.resolve(process.env.HOME, ".shout")
);
},