From: Darren Date: Sat, 10 May 2014 01:07:29 +0000 (+0100) Subject: Removing clientEvent() calls from irc/commands.js X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cd5b1558cf21bd5779190ab2bd9b39e10ac9389f;p=KiwiIRC.git Removing clientEvent() calls from irc/commands.js --- diff --git a/server/irc/channel.js b/server/irc/channel.js index 2226828..8c2c4a6 100644 --- a/server/irc/channel.js +++ b/server/irc/channel.js @@ -18,6 +18,7 @@ var IrcChannel = function(irc_connection, name) { kick: onKick, quit: onQuit, privmsg: onMsg, + action: onAction, notice: onNotice, ctcp_request: onCtcpRequest, ctcp_response: onCtcpResponse, @@ -148,6 +149,27 @@ function onMsg(event) { } +function onAction(event) { + var that = this; + + global.modules.emit('irc action', { + channel: this, + connection: this.irc_connection, + irc_event: event + }) + .done(function() { + that.irc_connection.clientEvent('action', { + nick: event.nick, + ident: event.ident, + hostname: event.hostname, + channel: event.channel, + msg: event.msg, + time: event.time + }); + }); +} + + function onNotice(event) { var that = this; diff --git a/server/irc/commands.js b/server/irc/commands.js index b403ded..f7f1d84 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -611,7 +611,11 @@ handlers = { if ((msg.charAt(0) === String.fromCharCode(1)) && (msg.charAt(msg.length - 1) === String.fromCharCode(1))) { //CTCP request if (msg.substr(1, 6) === 'ACTION') { - this.irc_connection.clientEvent('action', { + namespace = (command.params[0].toLowerCase() === this.irc_connection.nick.toLowerCase()) ? + 'user ' + command.nick : + 'channel ' + command.params[0]; + + this.irc_connection.emit(namespace + ' action', { nick: command.nick, ident: command.ident, hostname: command.hostname, @@ -619,14 +623,7 @@ handlers = { msg: msg.substring(8, msg.length - 1), time: time }); - } else if (msg.substr(1, 4) === 'KIWI') { - tmp = msg.substring(6, msg.length - 1); - namespace = tmp.split(' ', 1)[0]; - this.irc_connection.clientEvent('kiwi', { - namespace: namespace, - data: tmp.substr(namespace.length + 1), - time: time - }); + } else if (msg.substr(1, 7) === 'VERSION') { client_info = this.irc_connection.state.client.client_info; version_string = global.build_version; @@ -637,12 +634,14 @@ handlers = { } version_string = 'KiwiIRC (' + version_string + ')'; - this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION ' + version_string + String.fromCharCode(1)); + } else if (msg.substr(1, 6) === 'SOURCE') { this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'SOURCE http://www.kiwiirc.com/' + String.fromCharCode(1)); + } else if (msg.substr(1, 10) === 'CLIENTINFO') { this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'CLIENTINFO SOURCE VERSION TIME' + String.fromCharCode(1)); + } else { namespace = (command.params[0].toLowerCase() === this.irc_connection.nick.toLowerCase()) ? 'user' : 'channel'; this.irc_connection.emit(namespace + ' ' + command.nick + ' ctcp_request', { @@ -985,10 +984,10 @@ handlers = { params.shift(); genericNotice.call(this, command, params.slice(0, -1).join(', ') + ' ' + command.params[command.params.length - 1]); }, - + RPL_HOSTCLOACKING: function (command) { genericNotice.call(this, command, command.params[1] + ' ' + command.params[command.params.length - 1]); - }, + }, }; @@ -999,7 +998,7 @@ function genericNotice (command, msg, is_error) { if (typeof is_error !== 'boolean') is_error = true; - this.irc_connection.clientEvent('notice', { + this.irc_connection.emit('user ' + command.prefix + ' notice', { from_server: true, nick: command.prefix, ident: '', diff --git a/server/irc/user.js b/server/irc/user.js index 021d1bb..69df179 100755 --- a/server/irc/user.js +++ b/server/irc/user.js @@ -29,6 +29,7 @@ var IrcUser = function (irc_connection, nick) { notice: onNotice, ctcp_response: onCtcpResponse, privmsg: onPrivmsg, + action: onAction, ctcp_request: onCtcpRequest, mode: onMode }; @@ -267,6 +268,25 @@ function onPrivmsg(event) { }); } +function onAction(event) { + var that = this; + + global.modules.emit('irc action', { + connection: this.irc_connection, + irc_event: event + }) + .done(function() { + that.irc_connection.clientEvent('action', { + nick: event.nick, + ident: event.ident, + hostname: event.hostname, + channel: event.channel, + msg: event.msg, + time: event.time + }); + }); +} + function onCtcpRequest(event) { this.irc_connection.clientEvent('ctcp_request', { nick: event.nick,