Removing clientEvent() calls from irc/commands.js
authorDarren <darren@darrenwhitlen.com>
Sat, 10 May 2014 01:07:29 +0000 (02:07 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 10 May 2014 01:07:29 +0000 (02:07 +0100)
server/irc/channel.js
server/irc/commands.js
server/irc/user.js

index 2226828a0372d1a49b44b3946af723867929330c..8c2c4a6a0747cde171e98e25277fc99bd2e00632 100644 (file)
@@ -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;
 
index b403dedf1bba6af87b1d15137bb574f92ba0cc6b..f7f1d84717d87ac3384a11d541599367bc6e2aef 100644 (file)
@@ -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: '',
index 021d1bb9ffd179dc60d2bb1e5f0885b1e3a1e66a..69df179862c300e40503ae1a0ea6a65b5bc2af27 100755 (executable)
@@ -29,6 +29,7 @@ var IrcUser = function (irc_connection, nick) {
         notice:         onNotice,\r
         ctcp_response:  onCtcpResponse,\r
         privmsg:        onPrivmsg,\r
+        action:         onAction,\r
         ctcp_request:   onCtcpRequest,\r
         mode:           onMode\r
     };\r
@@ -267,6 +268,25 @@ function onPrivmsg(event) {
     });\r
 }\r
 \r
+function onAction(event) {\r
+    var that = this;\r
+\r
+    global.modules.emit('irc action', {\r
+        connection: this.irc_connection,\r
+        irc_event: event\r
+    })\r
+    .done(function() {\r
+        that.irc_connection.clientEvent('action', {\r
+            nick: event.nick,\r
+            ident: event.ident,\r
+            hostname: event.hostname,\r
+            channel: event.channel,\r
+            msg: event.msg,\r
+            time: event.time\r
+        });\r
+    });\r
+}\r
+\r
 function onCtcpRequest(event) {\r
     this.irc_connection.clientEvent('ctcp_request', {\r
         nick: event.nick,\r