Support for some error messages (cannot join channel etc). Issue #7
authorJack Allnutt <m2ys4u@Gmail.com>
Tue, 26 Jul 2011 23:17:05 +0000 (00:17 +0100)
committerJack Allnutt <m2ys4u@Gmail.com>
Tue, 26 Jul 2011 23:17:05 +0000 (00:17 +0100)
js/front.js
node/kiwi.js

index 3259bc97819211d72e05e9dfc971f105ff817708..6a1675114e09281246506bf01510fb835f66f637 100644 (file)
@@ -34,6 +34,7 @@ var front = {
                $(gateway).bind("ondebug", front.onDebug);
         $(gateway).bind("onctcp_request", front.onCTCPRequest);
         $(gateway).bind("onctcp_response", front.onCTCPResponse);
+        $(gateway).bind("onirc_error", front.onIRCError);
                
                this.buffer = [];
                
@@ -149,7 +150,7 @@ var front = {
                        chan = chans[i];
                        if (front.tabviews[chan.toLowerCase()] === undefined) {
                                gateway.join(chan);
-                               front.tabviewAdd(chan);
+                               //front.tabviewAdd(chan);
                        } else {
                                front.tabviews[chan.toLowerCase()].show();
                        }
@@ -473,6 +474,25 @@ var front = {
                front.tabviews[data.to.toLowerCase()].addMsg(null, ' ', '=== Redirected from ' + data.from, 'action');
        },
        
+    onIRCError: function (e, data) {
+        switch(data.error) {
+        case 'banned_from_channel':
+            front.tabviews.server.addMsg(null, ' ', '=== You are banned from ' + data.channel + ': ' + data.reason, 'status');
+            break;
+        case 'bad_channel_key':
+            front.tabviews.server.addMsg(null, ' ', '=== Bad channel key for ' + data.channel, 'status');
+            break;
+        case 'invite_only_channel':
+            front.tabviews.server.addMsg(null, ' ', '=== ' + data.channel + ' is invite only.', 'status');
+            break;
+        case 'channel_is_full':
+            front.tabviews.server.addMsg(null, ' ', '=== ' + data.channel + ' is full.', 'status');
+            break;
+        default:
+            front.tabviews.server.addMsg(null, ' ', '=== ' + data, 'status');
+        }
+    },
+    
        registerKeys: function () {
                $('#kiwi_msginput').bind('keydown', function (e) {
                        var windows = $('#windows');
index 3ed8efe3b43872190166b47278337a54ff0e28a4..6d7f54c6e5115fad399bd44a18952a0296b06452 100644 (file)
@@ -70,22 +70,30 @@ function changeUser(){
  */
 
 var ircNumerics = {
-    RPL_WELCOME:        '001',
-    RPL_ISUPPORT:       '005',
-    RPL_WHOISUSER:      '311',
-    RPL_WHOISSERVER:    '312',
-    RPL_WHOISOPERATOR:  '313',
-    RPL_WHOISIDLE:      '317',
-    RPL_ENDOFWHOIS:     '318',
-    RPL_WHOISCHANNELS:  '319',
-    RPL_TOPIC:          '332',
-    RPL_NAMEREPLY:      '353',
-    RPL_ENDOFNAMES:     '366',
-    RPL_MOTD:           '372',
-    RPL_WHOISMODES:     '379',
-    ERR_NOSUCHNICK:     '401',
-    ERR_LINKCHANNEL:    '470',
-    RPL_STARTTLS:       '670'
+    RPL_WELCOME:            '001',
+    RPL_ISUPPORT:           '005',
+    RPL_WHOISUSER:          '311',
+    RPL_WHOISSERVER:        '312',
+    RPL_WHOISOPERATOR:      '313',
+    RPL_WHOISIDLE:          '317',
+    RPL_ENDOFWHOIS:         '318',
+    RPL_WHOISCHANNELS:      '319',
+    RPL_TOPIC:              '332',
+    RPL_NAMEREPLY:          '353',
+    RPL_ENDOFNAMES:         '366',
+    RPL_MOTD:               '372',
+    RPL_WHOISMODES:         '379',
+    ERR_NOSUCHNICK:         '401',
+    ERR_CANNOTSENDTOCHAN:   '404',
+    ERR_TOOMANYCHANNELS:    '405',
+    ERR_USERNOTINCHANNEL:   '441',
+    ERR_NOTONCHANNEL:       '442',
+    ERR_LINKCHANNEL:        '470',
+    ERR_CHANNELISFULL:      '471',
+    ERR_INVITEONLYCHAN:     '473',
+    ERR_BANNEDFROMCHAN:     '474',
+    ERR_BADCHANNELKEY:      '475',
+    RPL_STARTTLS:           '670'
 };
 
 
@@ -326,6 +334,31 @@ var parseIRCMessage = function (websocket, ircSocket, data) {
                 console.log(e);
             }
             break;*/
+        case ircNumerics.ERR_CANNOTSENDTOCHAN:
+            websocket.emit('message', {event: 'irc_error', error: 'cannot_send_to_chan', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
+        case ircNumerics.ERR_TOOMANYCHANNELS:
+            websocket.emit('message', {event: 'irc_error', error: 'too_many_channels', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
+        case ircNumerics.ERR_USERNOTINCHANNEL:
+            params = msg.params.split(" ");
+            websocket.emit('message', {event: 'irc_error', error: 'user_not_in_channel', nick: params[0], channel: params[1], reason: msg.trainling});
+            break;
+        case ircNumerics.ERR_NOTONCHANNEL:
+            websocket.emit('message', {event: 'irc_error', error: 'not_on_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
+        case ircNumerics.ERR_CHANNELISFULL:
+            websocket.emit('message', {event: 'irc_error', error: 'channel_is_full', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
+        case ircNumerics.ERR_INVITEONLYCHAN:
+            websocket.emit('message', {event: 'irc_error', error: 'invite_only_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
+        case ircNumerics.ERR_BANNEDFROMCHAN:
+            websocket.emit('message', {event: 'irc_error', error: 'banned_from_channel', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
+        case ircNumerics.ERR_BADCHANNELKEY:
+            websocket.emit('message', {event: 'irc_error', error: 'bad_channel_key', channel: msg.params.split(" ")[1], reason: msg.trailing});
+            break;
         }
     } else {
         console.log("Unknown command.\r\n");