mirror of
https://github.com/reality/dbot.git
synced 2024-11-30 16:09:27 +01:00
parent
bfd11c5d4d
commit
b3b91f189f
@ -161,41 +161,25 @@ var users = function(dbot) {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
dbot.instance.addListener('366', 'users', function(event) {
|
dbot.instance.addListener('366', 'users', function(event) {
|
||||||
this.api.getChannel(event.server, event.channel.name, function(channel) {
|
var checkChannel = function(channel) {
|
||||||
var checkChannelUsers = function(channel) {
|
async.eachSeries(event.channel.nicks, function(nick, next) {
|
||||||
var i = 0;
|
|
||||||
var checkChannelNicks = function(chanicks) {
|
|
||||||
if(i == chanicks.length) return;
|
|
||||||
var nick = chanicks[i]; i++;
|
|
||||||
this.api.resolveUser(event.server, nick, function(user) {
|
this.api.resolveUser(event.server, nick, function(user) {
|
||||||
if(!user) {
|
var checkChannelUser = function(user) {
|
||||||
this.internalAPI.createUser(event.server, nick, event.channel.name, function(result) {
|
if(!_.inlude(channel.users, user.id)) {
|
||||||
this.internalAPI.addChannelUser(result, event.channel.name, function(err) {
|
this.internalAPI.addChannelUser(channel, user, next);
|
||||||
checkChannelNicks(chanicks);
|
|
||||||
});
|
|
||||||
}.bind(this));
|
|
||||||
} else {
|
} else {
|
||||||
if(!_.include(user.channels, event.channel.name)) {
|
next();
|
||||||
this.internalAPI.addChannelUser(user, event.channel.name, function(err) {
|
|
||||||
checkChannelNicks(chanicks);
|
|
||||||
});
|
|
||||||
user.channels.push(event.channel.name);
|
|
||||||
this.db.save('users', user.id, user, function(err) { });
|
|
||||||
} else {
|
|
||||||
checkChannelNicks(chanicks);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}.bind(this));
|
|
||||||
}.bind(this);
|
|
||||||
checkChannelNicks(_.keys(event.channel.nicks));
|
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
if(!channel) { // Channel does not yet exist
|
if(user) {
|
||||||
this.internalAPI.createChannel(event.server, event.channel.name, checkChannelUsers);
|
checkChannelUser(user);
|
||||||
} else {
|
} else {
|
||||||
checkChannelUsers(channel);
|
this.internalAPI.createUser(event.server, nick, channel.id, checkChannelUser);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
});
|
||||||
|
};
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
var connections = dbot.instance.connections;
|
var connections = dbot.instance.connections;
|
||||||
|
Loading…
Reference in New Issue
Block a user