3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

remove extra JOIN listener in users. derp

This commit is contained in:
reality 2013-08-19 17:32:19 +00:00
parent 0f53693c28
commit a7b2ba96e7

View File

@ -91,34 +91,19 @@ var users = function(dbot) {
}; };
this.listener = function(event) { this.listener = function(event) {
if(event.action == 'JOIN' && event.user != dbot.config.name) { this.api.isKnownUser(event.server, event.newNick, function(isKnown) {
if(!event.rUser) { event.rUser.currentNick = event.newNick;
this.internalAPI.createUser(event.server, event.user, function(user) {
this.internalAPI.addChannelUser(event.rChannel, user, {}, function() {}); if(!isKnown) {
}.bind(this)); event.rUser.aliases.push(event.newNick);
} else if(!_.include(event.rUser.channels, event.rChannel.id)) {
this.internalAPI.addChannelUser(event.rChannel, event.rUser, {}, function() {});
} }
if(event.rUser.currentNick != event.user) { this.db.save('users', event.rUser.id, event.rUser, function(err) {
event.rUser.currentNick = event.user; dbot.api.event.emit('new_user_alias', [ event.rUser, event.newNick ]);
this.db.save('users', event.rUser.id, event.rUser, function() {}); });
} }.bind(this));
} else if(event.action == 'NICK') {
this.api.isKnownUser(event.server, event.newNick, function(isKnown) {
event.rUser.currentNick = event.newNick;
if(!isKnown) {
event.rUser.aliases.push(event.newNick);
}
this.db.save('users', event.rUser.id, event.rUser, function(err) {
dbot.api.event.emit('new_user_alias', [ event.rUser, event.newNick ]);
});
}.bind(this));
}
}.bind(this); }.bind(this);
this.on = ['JOIN', 'NICK']; this.on = ['NICK'];
this.onLoad = function() { this.onLoad = function() {
dbot.instance.addPreEmitHook(function(event, callback) { dbot.instance.addPreEmitHook(function(event, callback) {