From 5989f3f4b2a8ba8b6cfcdfc79727c127761e8c6e Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Sat, 15 Jun 2013 02:19:56 +0100 Subject: [PATCH] Handle replies to WHOWAS command --- client/assets/src/models/network.js | 16 +++++++++++++++- server/irc/commands.js | 27 ++++++++++++++++++++++++++- server/irc/user.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/client/assets/src/models/network.js b/client/assets/src/models/network.js index 92f49a5..5fd4454 100644 --- a/client/assets/src/models/network.js +++ b/client/assets/src/models/network.js @@ -80,6 +80,7 @@ this.gateway.on('userlist_end', onUserlistEnd, this); this.gateway.on('mode', onMode, this); this.gateway.on('whois', onWhois, this); + this.gateway.on('whowas', onWhowas, this); this.gateway.on('away', onAway, this); this.gateway.on('list_start', onListStart, this); this.gateway.on('irc_error', onIrcError, this); @@ -601,7 +602,7 @@ } else if (event.chans) { panel.addMsg(event.nick, 'Channels: ' + event.chans, 'whois'); } else if (event.irc_server) { - panel.addMsg(event.nick, 'Connected to server: ' + event.irc_server, 'whois'); + panel.addMsg(event.nick, 'Connected to server: ' + event.irc_server + ' ' + event.server_info, 'whois'); } else if (event.msg) { panel.addMsg(event.nick, event.msg, 'whois'); } else if (event.logon) { @@ -617,6 +618,19 @@ } } + function onWhowas(event) { + var panel; + + if (event.end) + return; + + panel = _kiwi.app.panels().active; + if (event.host) { + panel.addMsg(event.nick, event.nick + ' [' + event.nick + ((event.ident)? '!' + event.ident : '') + '@' + event.host + '] * ' + event.real_name, 'whois'); + } else { + panel.addMsg(event.nick, 'No such nick', 'whois'); + } + } function onAway(event) { diff --git a/server/irc/commands.js b/server/irc/commands.js index d64934a..0dc53c0 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -23,6 +23,7 @@ irc_numerics = { '311': 'RPL_WHOISUSER', '312': 'RPL_WHOISSERVER', '313': 'RPL_WHOISOPERATOR', + '314': 'RPL_WHOWASUSER', '317': 'RPL_WHOISIDLE', '318': 'RPL_ENDOFWHOIS', '319': 'RPL_WHOISCHANNELS', @@ -38,6 +39,7 @@ irc_numerics = { '366': 'RPL_ENDOFNAMES', '367': 'RPL_BANLIST', '368': 'RPL_ENDOFBANLIST', + '369': 'RPL_ENDOFWHOWAS', '372': 'RPL_MOTD', '375': 'RPL_MOTDSTART', '376': 'RPL_ENDOFMOTD', @@ -45,6 +47,7 @@ irc_numerics = { '401': 'ERR_NOSUCHNICK', '404': 'ERR_CANNOTSENDTOCHAN', '405': 'ERR_TOOMANYCHANNELS', + '406': 'ERR_WASNOSUCHNICK', '421': 'ERR_UNKNOWNCOMMAND', '422': 'ERR_NOMOTD', '432': 'ERR_ERRONEUSNICKNAME', @@ -171,7 +174,8 @@ handlers = { 'RPL_WHOISSERVER': function (command) { this.irc_connection.emit('user ' + command.params[1] + ' whoisserver', { nick: command.params[1], - irc_server: command.params[2] + irc_server: command.params[2], + server_info: command.trailing }); }, @@ -211,6 +215,27 @@ handlers = { }); }, + 'RPL_WHOWASUSER': function (command) { + this.irc_connection.emit('user ' + command.params[1] + ' whowas', { + nick: command.params[1], + ident: command.params[2], + host: command.params[3], + real_name: command.trailing + }); + }, + + 'RPL_ENDOFWHOWAS': function (command) { + this.irc_connection.emit('user ' + command.params[1] + ' endofwhowas', { + nick: command.params[1] + }); + }, + + 'ERR_WASNOSUCHNICK': function (command) { + this.irc_connection.emit('user ' + command.params[1] + ' wasnosucknick', { + nick: command.params[1] + }); + }, + 'RPL_LISTSTART': function (command) { this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' list_start', {}); }, diff --git a/server/irc/user.js b/server/irc/user.js index 499f691..387b7f1 100755 --- a/server/irc/user.js +++ b/server/irc/user.js @@ -16,7 +16,11 @@ var IrcUser = function (irc_connection, nick) { whoismodes: onWhoisModes, whoisidle: onWhoisIdle, whoisregnick: onWhoisRegNick, + whoisserver: onWhoisServer, endofwhois: onWhoisEnd, + whowas: onWhoWas, + endofwhowas: onWhoWasEnd, + wasnosuchnick: onWasNoSuchNick, notice: onNotice, ctcp_response: onCtcpResponse, privmsg: onPrivmsg, @@ -88,6 +92,7 @@ function onWhoisServer(event) { this.irc_connection.clientEvent('whois', { nick: event.nick, irc_server: event.irc_server, + server_info: event.server_info, end: false }); } @@ -141,6 +146,30 @@ function onWhoisEnd(event) { }); } +function onWhoWas(event) { + this.irc_connection.clientEvent('whowas', { + nick: event.nick, + ident: event.user, + host: event.host, + real_name: event.real_name, + end: false + }); +} + +function onWasNoSuchNick(event) { + this.irc_connection.clientEvent('whowas', { + nick: event.nick, + end: false + }); +} + +function onWhoWasEnd(event) { + this.irc_connection.clientEvent('whowas', { + nick: event.nick, + end: true + }); +} + function onNotice(event) { this.irc_connection.clientEvent('notice', { from_server: event.from_server, -- 2.25.1