diff --git a/modules/ignore/ignore.js b/modules/ignore/ignore.js index 25633b0..46c43f9 100644 --- a/modules/ignore/ignore.js +++ b/modules/ignore/ignore.js @@ -276,7 +276,7 @@ var ignore = function(dbot) { dbot.api.users.getUser(ignores.id, function(user) { if(user) { _.each(ignores.ignores, function(module) { - dbot.instance.ignoreTag(user.primaryNick, module); + dbot.instance.ignoreTag(user.currentNick, module); }); } }); @@ -287,7 +287,18 @@ var ignore = function(dbot) { dbot.instance.ignoreTag(channel.name, module); }); }, function(err) { }); - }; + + dbot.api.event.addHook('new_current_nick', function(user, oldNick) { + this.api.getUserIgnores(user, function(err, ignores) { + if(ignores) { + _.each(ignores.ignores, function(module) { + dbot.instance.removeIgnore(oldNick, module); + dbot.instance.ignoreTag(user.currentNick, module); + }); + } + }.bind(this)); + }.bind(this)); + }.bind(this); }; exports.fetch = function(dbot) { diff --git a/modules/users/users.js b/modules/users/users.js index 2eeccc5..2fd2a71 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -103,7 +103,10 @@ var users = function(dbot) { } this.db.save('users', event.rUser.id, event.rUser, function(err) { - dbot.api.event.emit('new_user_alias', [ event.rUser, event.newNick ]); + if(!isKnown) { + dbot.api.event.emit('new_user_alias', [ event.rUser, event.newNick ]); + } + dbot.api.event.emit('new_current_nick', [ event.rUser, event.user ]); }); }.bind(this)); }.bind(this); @@ -137,9 +140,10 @@ var users = function(dbot) { this.internalAPI.createUser(event.server, event.user, done); } else { if(event.user !== user.currentNick) { + var oldNick = user.currentNick; user.currentNick = event.user; this.db.save('users', user.id, user, function() { - dbot.api.event.emit('new_current_nick', [ user ]); + dbot.api.event.emit('new_current_nick', [ user, oldNick ]); done(user); }); } else {