From 63811c172b65a2e7230c31619327d9e064f04e9b Mon Sep 17 00:00:00 2001 From: Darren Date: Tue, 1 Jul 2014 02:37:21 +0100 Subject: [PATCH] Refactor gecos so plugins can modify it before connecting --- server/irc/connection.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/irc/connection.js b/server/irc/connection.js index dc51a40..f6ac97a 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -56,6 +56,7 @@ var IrcConnection = function (hostname, port, ssl, nick, user, options, state, c this.nick = nick; this.user = user; // Contains users real hostname and address this.username = this.nick.replace(/[^0-9a-zA-Z\-_.\/]/, ''); + this.gecos = ''; // Users real-name. Uses default from config if empty this.password = options.password || ''; // Set the passed encoding. or the default if none giving or it fails @@ -606,11 +607,16 @@ var socketConnectHandler = function () { connect_data = findWebIrc.call(this, connect_data); global.modules.emit('irc authorize', connect_data).done(function ircAuthorizeCb() { - var gecos = '[www.kiwiirc.com] ' + that.nick; + var gecos = that.gecos; - if (global.config.default_gecos) { + if (!gecos && global.config.default_gecos) { + // We don't have a gecos yet, so use the default gecos = global.config.default_gecos.toString().replace('%n', that.nick); - gecos = gecos.toString().replace('%h', that.user.hostname); + gecos = gecos.replace('%h', that.user.hostname); + + } else if (!gecos) { + // We don't have a gecos nor a default, so lets set somthing + gecos = '[www.kiwiirc.com] ' + that.nick; } // Send any initial data for webirc/etc -- 2.25.1