Regex reverted back kiwi original
authorDarren <darren@darrenwhitlen.com>
Sun, 30 Sep 2012 15:45:44 +0000 (16:45 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 30 Sep 2012 15:45:44 +0000 (16:45 +0100)
client_backbone/dev/model_gateway.js
server/client.js
server/irc-commands.js
server/irc-connection.js

index 45cb41bc594811f760313b6b05e403324042f6c4..5b4de4dc7686be7caaaf1c7f561dd894bd3983dd 100755 (executable)
@@ -153,7 +153,7 @@ kiwi.model.Gateway = function () {
     *   Parses the response from the server\r
     */\r
     this.parse = function (command, data) {\r
-        //console.log('gateway event', command, data);\r
+        console.log('gateway event', command, data);\r
         if (command !== undefined) {\r
             that.trigger('on' + command, data);\r
 \r
index 5191fb95ca4c5e55b345829f462ed0c4f970ec85..e71d6c97ac43b530df6bf7526b0040692afeffae 100755 (executable)
@@ -47,7 +47,7 @@ module.exports.Client = Client;
 
 Client.prototype.sendIRCCommand = function (command, data, callback) {
     var c = {command: command, data: data};
-    console.log('C<--', c);
+    //console.log('C<--', c);
     this.websocket.emit('irc', c, callback);
 };
 
index c88200994831ff399b4be49ac80961ec72b938f7..fb72fe72bae2abfe5b929c38bb9dfeb2f4d66dc3 100755 (executable)
@@ -385,7 +385,12 @@ var listeners = {
                     }
                 }
                 
-                this.client.sendIRCCommand('mode', {server: this.con_num, target: command.params[0], nick: command.nick, modes: modes});
+                this.client.sendIRCCommand('mode', {
+                    server: this.con_num,
+                    target: command.params[0],
+                    nick: command.nick || command.prefix || '',
+                    modes: modes
+                });
             },
     'PRIVMSG':              function (command) {
                                /*command.server = this.con_num;
index d6a0a0e0addf73dd92e76c29f8ede2135be5f782..eade6a49195e2a2bfa2a614216e1f30559475120 100755 (executable)
@@ -83,8 +83,8 @@ var connect_handler = function () {
     this.emit('connected');
 };
 
-//parse_regex = /^(?::(?:([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)|([a-z0-9\x5B-\x60\x7B-\x7D\.\-]+)!([a-z0-9~\.\-_|]+)@?([a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-z]*[0-9a-z]*)*|\d{1,3}\x2e\d{1,3}\x2e\d{1,3}\x2e\d{1,3}|[0-9a-f]+(?::[0-9a-f]+){7}|0:0:0:0:0:(?:0|ffff):\d{1,3}\x2e\d{1,3}\x2e\d{1,3}\x2e\d{1,3}))?)\x20)?([a-z]+|\d{3})((?:\x20[\x01-\t\v\f\x0e-\x1f!-9;-@\x5b-\xff][\x01-\t\v\f\x0e-\x1f!-@\x5b-\xff]*){0,14}(?:\x20:[\x01-\t\v\f\x0e-@\x5b-\xff]*)?|(?:\x20[\x01-\t\v\f\x0e-\x1f!-9;-@\x5b-\xff][\x01-\t\v\f\x0e-\x1f!-@\x5b-\xff]*){14}(?:\x20:?[\x01-\t\v\f\x0e-@\x5b-\xff]*)?)?/i;
 
 var parse = function (data) {
     var i,
@@ -109,26 +109,24 @@ var parse = function (data) {
             }
 
             // We have a complete line of data, parse it!
-            //msg = parse_regex.exec(data[i].replace(/^\r+|\r+$/, ''));
-                       msg2 = alt_regex.exec(data[i].replace(/^\r+|\r+$/, ''));
-                       //console.log(msg2);
-            if (msg2) {
+            msg = parse_regex.exec(data[i].replace(/^\r+|\r+$/, ''));
+                       //msg2 = alt_regex.exec(data[i].replace(/^\r+|\r+$/, ''));
+                       console.log('S-->', data[i]);
+            console.log('Matches', msg);
+            if (msg) {
                 msg = {
-                    prefix:     msg2[1],
-                    nick:       msg2[2],
-                    ident:      msg2[3],
-                    hostname:   msg2[4],
-                    command:    msg2[5]
+                    prefix:     msg[1],
+                    nick:       msg[2],
+                    ident:      msg[3],
+                    hostname:   msg[4] || '',
+                    command:    msg[5],
+                    params:     msg[6] || '',
+                    trailing:   (msg[7]) ? msg[7].trim() : ''
                 };
-                               trm = msg2[6].indexOf(':');
-                               if (trm !== -1){
-                                       msg.params = msg2[6].substr(0, trm - 1).trim().split(" ");
-                                       msg.trailing = msg2[6].substr(trm + 1).trim();
-                               } else {
-                                       msg.params = msg2[6].trim().split(" ");
-                               }
-                console.log('S-->', data[i]);
-                               //console.log(msg);
+                msg.params = msg.params.split(' ');
+
+                               console.log('Parsed', msg);
+
                 this.emit('irc_' + msg.command.toUpperCase(), msg);
             } else {
                 console.log("Malformed IRC line: " + data[i].replace(/^\r+|\r+$/, ''));