Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better way of finding what channels a user is in #4

Merged
merged 1 commit into from
Jul 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,14 @@ function Client(server, nick, opt) {

channels = [];

// TODO better way of finding what channels a user is in?
// finding what channels a user is in
Object.keys(self.chans).forEach(function(channame) {
var channel = self.chans[channame];
channel.users[message.args[0]] = channel.users[message.nick];
delete channel.users[message.nick];
channels.push(channame);
if (message.nick in channel.users) {
channel.users[message.args[0]] = channel.users[message.nick];
delete channel.users[message.nick];
channels.push(channame);
}
});

// old nick, new nick, channels
Expand Down Expand Up @@ -501,8 +503,10 @@ function Client(server, nick, opt) {
channels = [];
Object.keys(self.chans).forEach(function(channame) {
var channel = self.chans[channame];
channels.push(channame);
delete channel.users[nick];
if (nick in channel.users) {
channels.push(channame);
delete channel.users[nick];
}
});
self.emit('kill', nick, message.args[1], channels, message);
break;
Expand Down Expand Up @@ -544,11 +548,13 @@ function Client(server, nick, opt) {

channels = [];

// TODO better way of finding what channels a user is in?
// finding what channels a user is in?
Object.keys(self.chans).forEach(function(channame) {
var channel = self.chans[channame];
delete channel.users[message.nick];
channels.push(channame);
if (message.nick in channel.users) {
delete channel.users[message.nick];
channels.push(channame);
}
});

// who, reason, channels
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"Justin Gallardo <[email protected]>",
"Chris Nehren <[email protected]>",
"Henri Niemeläinen <[email protected]>",
"Alex Miles <[email protected]>"
"Alex Miles <[email protected]>",
"Andrei Husanu <[email protected]>"
],
"repository": {
"type": "git",
Expand Down