Skip to content

Commit

Permalink
Include channels user was in when 'kill' is emitted
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Whitman committed Nov 22, 2011
1 parent 36a84c1 commit 1db7c0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/API.rst
Expand Up @@ -222,9 +222,11 @@ Events


.. js:data:: 'kill' .. js:data:: 'kill'


`function (nick, reason, message) { }` `function (nick, reason, channels, message) { }`


Emitted when a user is killed from the IRC server. Emitted when a user is killed from the IRC server.
`channels` is an array of channels the killed user was in which
are known to the client.
See the `raw` event for details on the `message` object. See the `raw` event for details on the `message` object.


.. js:data:: 'message' .. js:data:: 'message'
Expand Down
6 changes: 5 additions & 1 deletion lib/irc.js
Expand Up @@ -349,10 +349,14 @@ function Client(server, nick, opt) {
break; break;
case "KILL": case "KILL":
var nick = message.args[0]; var nick = message.args[0];
self.emit('kill', nick, message.args[1], message); var channels = [];
for ( var channel in self.chans ) { for ( var channel in self.chans ) {
if ( self.chans[channel].users[nick])
channels.push(channel);

delete self.chans[channel].users[nick]; delete self.chans[channel].users[nick];
} }
self.emit('kill', nick, message.args[1], channels, message);
break; break;
case "PRIVMSG": case "PRIVMSG":
var from = message.nick; var from = message.nick;
Expand Down

0 comments on commit 1db7c0e

Please sign in to comment.