Refactoring
This commit is contained in:
parent
221ed4b980
commit
b3b36282aa
@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
public: true,
|
||||
host: "0.0.0.0",
|
||||
port: 9090,
|
||||
port: 9000,
|
||||
theme: "themes/example.css",
|
||||
home: "",
|
||||
debug: false
|
||||
|
@ -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)
|
||||
var delay = 0;
|
||||
(config.networks || []).forEach(function(n) {
|
||||
setTimeout(function() {
|
||||
client.connect(n);
|
||||
else
|
||||
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) {
|
||||
|
@ -1,22 +1,22 @@
|
||||
var path = require("path");
|
||||
|
||||
var Helper = module.exports = {
|
||||
getConfig: function () {
|
||||
return require(path.resolve(__dirname, "..", "config"));
|
||||
},
|
||||
getConfig: function () {
|
||||
return require(path.resolve(__dirname, "..", "config"));
|
||||
},
|
||||
|
||||
getHomeDirectory: function () {
|
||||
return (
|
||||
this.getConfig().home ||
|
||||
process.env.SHOUT_HOME ||
|
||||
path.resolve(process.env.HOME, ".shout")
|
||||
);
|
||||
},
|
||||
getHomeDirectory: function () {
|
||||
return (
|
||||
this.getConfig().home
|
||||
|| process.env.SHOUT_HOME
|
||||
|| path.resolve(process.env.HOME, ".shout")
|
||||
);
|
||||
},
|
||||
|
||||
resolveHomePath: function () {
|
||||
var fragments = [ Helper.HOME ].concat([].slice.apply(arguments));
|
||||
return path.resolve.apply(path, fragments);
|
||||
}
|
||||
resolveHomePath: function () {
|
||||
var fragments = [ Helper.HOME ].concat([].slice.apply(arguments));
|
||||
return path.resolve.apply(path, fragments);
|
||||
}
|
||||
};
|
||||
|
||||
Helper.HOME = Helper.getHomeDirectory()
|
||||
|
Loading…
Reference in New Issue
Block a user