Browse files

Support for whois command

Asking for whois info is quite popular. This adds it to the server
and the client side.

Signed-off-by: Rohan Jain <crodjer@gmail.com>
  • Loading branch information...
1 parent 8dcd4f5 commit 8fe5ae4dc0c5786666520c9deb34a3652c167602 @crodjer committed Sep 30, 2012
Showing with 32 additions and 0 deletions.
  1. +26 −0 assets/js/client.js
  2. +1 −0 lib/irclink.js
  3. +5 −0 lib/socket.js
View
26 assets/js/client.js
@@ -149,6 +149,27 @@ $(function() {
irc.chatWindows.getByName('status').stream.add(message);
});
+ // Whois data
+ irc.socket.on('whois', function(data){
+ var key, message;
+ var stream = irc.chatWindows.getByName('status').stream;
+ if (data.info){
+ var info = {
+ " ": data.info.nick + ' (' + (data.info.user + '@' + data.info.host) + ')',
+ realname: data.info.realname,
+ server: data.info.server + ' (' + data.info.serverinfo + ')',
+ account: data.info.account
+ };
+
+ for (key in info){
+ if (info.hasOwnProperty(key)){
+ message = new Message({sender: key, raw: info[key], type: 'whois'});
+ stream.add(message);
+ }
+ }
+ }
+ });
+
irc.socket.on('message', function(data) {
var chatWindow = irc.chatWindows.getByName(data.to.toLowerCase());
var type = 'message';
@@ -358,6 +379,11 @@ $(function() {
topic: commandText[1]});
}
break;
+ case '/whois':
+ if (commandText[1]){
+ irc.socket.emit('whois', {nick: commandText[1]});
+ }
+ break;
case '/me':
irc.socket.emit('action', {
target: irc.chatWindows.getActive().get('name'),
View
1 lib/irclink.js
@@ -58,6 +58,7 @@ var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password
'pm': ['nick', 'text'],
'registered': ['message'],
'motd': ['motd'],
+ 'whois': ['info'],
'error': ['message'],
'netError': ['message']
};
View
5 lib/socket.js
@@ -136,6 +136,11 @@ module.exports = function(socket, connections) {
);
});
+ socket.removeAllListeners('whois');
+ socket.on('whois', function(data) {
+ connection.client.whois(data.nick);
+ });
+
socket.removeAllListeners('topic');
socket.on('topic', function(data){
connection.client.send('TOPIC ', data.name, data.topic);

0 comments on commit 8fe5ae4

Please sign in to comment.