Unknown IRC commands sent to client; RPL_WHOISACCOUNT, RPL_WHOISHOST, ERR_USERONCHANN...
authorDarren <darren@darrenwhitlen.com>
Sat, 28 Sep 2013 14:36:58 +0000 (15:36 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 28 Sep 2013 14:36:58 +0000 (15:36 +0100)
client/assets/src/models/network.js
server/irc/commands.js
server/irc/server.js
server/irc/user.js

index 5f773b57e2401d4fb4ce0635cf73c3fc6eb4aa36..93ede55bd9314701157cf7fa89233a7b6cfac753 100644 (file)
             this.gateway.on('away', onAway, this);
             this.gateway.on('list_start', onListStart, this);
             this.gateway.on('irc_error', onIrcError, this);
+            this.gateway.on('unknown_command', onUnknownCommand, this);
         },
 
 
             panel.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_network_channel_inviteonly').fetch(event.channel), 'status');
             _kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_channel_inviteonly').fetch(event.channel));
             break;
+        case 'user_on_channel':
+            panel.addMsg(' ', '== ' + event.nick + ' is already on this channel');
+            break;
         case 'channel_is_full':
             panel.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_network_channel_limitreached').fetch(event.channel), 'status');
             _kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_channel_limitreached').fetch(event.channel));
             //_kiwi.front.tabviews.server.addMsg(null, ' ', '== ' + data, 'status');
         }
     }
+
+
+    function onUnknownCommand(event) {
+        var display_params = _.clone(event.params);
+
+        // A lot of commands have our nick as the first parameter. This is redundant for us
+        if (display_params[0] && display_params[0] == this.get('nick')) {
+            display_params.shift();
+        }
+
+        if (event.trailing)
+            display_params.push(event.trailing);
+
+        this.panels.server.addMsg('', '[' + event.command + '] ' + display_params.join(', ', ''));
+    }
 }
 
 )();
index 4778c9eeac55dc2777715b96c112615cdf93ceda..053da587c72350164a8f0911292fa841742090e5 100644 (file)
@@ -30,6 +30,7 @@ irc_numerics = {
     '321': 'RPL_LISTSTART',
     '322': 'RPL_LIST',
     '323': 'RPL_LISTEND',
+    '330': 'RPL_WHOISACCOUNT',
     '331': 'RPL_NOTOPIC',
     '332': 'RPL_TOPIC',
     '333': 'RPL_TOPICWHOTIME',
@@ -43,6 +44,7 @@ irc_numerics = {
     '372': 'RPL_MOTD',
     '375': 'RPL_MOTDSTART',
     '376': 'RPL_ENDOFMOTD',
+    '378': 'RPL_WHOISHOST',
     '379': 'RPL_WHOISMODES',
     '401': 'ERR_NOSUCHNICK',
     '404': 'ERR_CANNOTSENDTOCHAN',
@@ -54,6 +56,7 @@ irc_numerics = {
     '433': 'ERR_NICKNAMEINUSE',
     '441': 'ERR_USERNOTINCHANNEL',
     '442': 'ERR_NOTONCHANNEL',
+    '443': 'ERR_USERONCHANNEL',
     '451': 'ERR_NOTREGISTERED',
     '464': 'ERR_PASSWDMISMATCH',
     '470': 'ERR_LINKCHANNEL',
@@ -64,6 +67,7 @@ irc_numerics = {
     '481': 'ERR_NOPRIVILEGES',
     '482': 'ERR_CHANOPRIVSNEEDED',
     '670': 'RPL_STARTTLS',
+    '671': 'RPL_WHOISSECURE',
     '900': 'RPL_SASLAUTHENTICATED',
     '903': 'RPL_SASLLOGGEDIN',
     '904': 'ERR_SASLNOTAUTHORISED',
@@ -85,7 +89,7 @@ IrcCommands.prototype.dispatch = function (command, data) {
     if (handlers[command]) {
         handlers[command].call(this, data);
     } else {
-        unknownCommand(command, data);
+        unknownCommand.call(this, command, data);
     }
 };
 
@@ -101,8 +105,26 @@ IrcCommands.addNumeric = function (numeric, handler_name) {
 };
 
 unknownCommand = function (command, data) {
-    // TODO: Do something here, log?
-};
+    var params = _.clone(data.params);
+
+    this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' unknown_command', {
+        command: command,
+        params: params,
+        trailing: data.trailing
+    });
+
+
+/*
+            this.irc_connection.emit(namespace + ' ' + command.params[0] + ' notice', {
+                from_server: command.prefix ? true : false,
+                nick: command.nick || command.prefix || undefined,
+                ident: command.ident,
+                hostname: command.hostname,
+                target: command.params[0],
+                msg: command.trailing
+            });
+            */
+ };
 
 
 handlers = {
@@ -213,6 +235,26 @@ handlers = {
         });
     },
 
+    'RPL_WHOISHOST': function (command) {
+        this.irc_connection.emit('user ' + command.params[1] + ' whoishost', {
+            nick: command.params[1],
+            msg: command.trailing
+        });
+    },
+
+    'RPL_WHOISSECURE': function (command) {
+        this.irc_connection.emit('user ' + command.params[1] + ' whoissecure', {
+            nick: command.params[1]
+        });
+    },
+
+    'RPL_WHOISACCOUNT': function (command) {
+        this.irc_connection.emit('user ' + command.params[1] + ' whoisaccount', {
+            nick: command.params[1],
+            account: command.params[2]
+        });
+    },
+
     'RPL_WHOWASUSER': function (command) {
         this.irc_connection.emit('user ' + command.params[1] + ' whowas', {
             nick: command.params[1],
@@ -697,6 +739,13 @@ handlers = {
         });
     },
 
+    ERR_USERONCHANNEL: function (command) {
+        this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' user_on_channel', {
+            nick: command.params[1],
+            channel: command.params[2]
+        });
+    },
+
     ERR_CHANNELISFULL: function (command) {
         this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' channel_is_full', {
             channel: command.params[1],
index e68766fce7989d99e0ca95ac7816b941b6d78aef..6ec4828aedc3ceeb0e7b87ffa026719ba26bf753 100755 (executable)
@@ -27,11 +27,13 @@ var IrcServer = function (irc_connection) {
         not_on_channel:         onNotOnChannel,
         channel_is_full:        onChannelIsFull,
         invite_only_channel:    onInviteOnlyChannel,
+        user_on_channel:        onUserAlreadyInChannel,
         banned_from_channel:    onBannedFromChannel,
         bad_channel_key:        onBadChannelKey,
         chanop_privs_needed:    onChanopPrivsNeeded,
         nickname_in_use:        onNicknameInUse,
-        erroneus_nickname:      onErroneusNickname
+        erroneus_nickname:      onErroneusNickname,
+        unknown_command:        onUnknownCommand
     };
     EventBinder.bindIrcEvents('server *', this.irc_events, this, this.irc_connection);
 
@@ -197,6 +199,14 @@ function onInviteOnlyChannel(event) {
     });
 }
 
+function onUserAlreadyInChannel(event) {
+    this.irc_connection.clientEvent('irc_error', {
+        error: 'user_on_channel',
+        channel: event.channel,
+        nick: event.nick
+    });
+}
+
 function onBannedFromChannel(event) {
     this.irc_connection.clientEvent('irc_error', {
         error: 'banned_from_channel',
@@ -236,3 +246,12 @@ function onErroneusNickname(event) {
         reason: event.reason
     });
 }
+
+function onUnknownCommand(event) {
+    this.irc_connection.clientEvent('unknown_command', {
+        error: 'unknown_command',
+        command: event.command,
+        params: event.params,
+        trailing: event.trailing
+    });
+}
index 387b7f1534901bdb1e73f9e6be7e793a2a29499d..95df5884210e1c85ff21486390bb2e50975adaa1 100755 (executable)
@@ -17,6 +17,9 @@ var IrcUser = function (irc_connection, nick) {
         whoisidle:      onWhoisIdle,\r
         whoisregnick:   onWhoisRegNick,\r
         whoisserver:    onWhoisServer,\r
+        whoishost:      onWhoisHost,\r
+        whoissecure:    onWhoisSecure,\r
+        whoisaccount:   onWhoisAccount,\r
         endofwhois:     onWhoisEnd,\r
         whowas:         onWhoWas,\r
         endofwhowas:    onWhoWasEnd,\r
@@ -138,6 +141,30 @@ function onWhoisRegNick(event) {
     });\r
 }\r
 \r
+function onWhoisHost(event) {\r
+    this.irc_connection.clientEvent('whois', {\r
+        nick: event.nick,\r
+        msg: event.msg,\r
+        end: false\r
+    });\r
+}\r
+\r
+function onWhoisSecure(event) {\r
+    this.irc_connection.clientEvent('whois', {\r
+        nick: event.nick,\r
+        msg: 'Using a secure connection',\r
+        end: false\r
+    });\r
+}\r
+\r
+function onWhoisAccount(event) {\r
+    this.irc_connection.clientEvent('whois', {\r
+        nick: event.nick,\r
+        msg: 'Logged in as ' + event.account,\r
+        end: false\r
+    });\r
+}\r
+\r
 function onWhoisEnd(event) {\r
     this.irc_connection.clientEvent('whois', {\r
         nick: event.nick,\r