diff --git a/modules/users/commands.js b/modules/users/commands.js index 8dbead1..6a31979 100644 --- a/modules/users/commands.js +++ b/modules/users/commands.js @@ -13,11 +13,13 @@ var commands = function(dbot) { if(user.aliases.length != 0) { event.reply(dbot.t('primary', { 'user': nick, + 'currentNick': user.currentNick, 'count': user.aliases.length, }) + including); } else { event.reply(dbot.t('primary', { 'user': nick, + 'currentNick': user.currentNick, 'count': user.aliases.length }).slice(0, -2) + "."); } diff --git a/modules/users/strings.json b/modules/users/strings.json index a46e7dc..a73263d 100644 --- a/modules/users/strings.json +++ b/modules/users/strings.json @@ -4,7 +4,7 @@ "na'vi": "ayfko syaw {user} {alias} nìteng" }, "primary": { - "en": "{user} is a primary user with {count} aliases, ", + "en": "{user} is a primary user (currently {currentNick}) with {count} aliases, ", "na'vi": "{user} lu txin ulte {count}a stxo lu poru, " }, "unknown_alias": { diff --git a/modules/users/users.js b/modules/users/users.js index 2972089..78b2c69 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -73,20 +73,30 @@ var users = function(dbot) { if(!_.include(user.channels, event.channel)) { // User not yet channel user this.internalAPI.addChannelUser(user, event.channel.name); } + + user.currentNick = event.user; + this.db.save(users, user.id, user, function(err) { + if(err) { + // QQ + } + }); } }.bind(this)); } else if(event.action == 'NICK') { - this.api.isKnownUser(event.server, event.newNick, function(isKnown) { - if(!isKnown) { - this.api.resolveUser(event.server, event.user, function(user) { + this.api.resolveUser(event.server, event.user, function(user) { + this.api.isKnownUser(event.server, event.newNick, function(isKnown) { + user.currentNick = event.newNick; + + if(!isKnown) { user.aliases.push(event.newNick); - this.db.save('users', user.id, user, function(err) { - if(!err) { - dbot.api.event.emit('new_user_alias', [ user, event.newNick ]); - } - }); - }.bind(this)); - } + } + + this.db.save('users', user.id, user, function(err) { + if(!err) { + dbot.api.event.emit('new_user_alias', [ user, event.newNick ]); + } + }); + }.bind(this)); }.bind(this)); } }.bind(this);