From 51298b83623e94d66fe3a2d79cf8093a177802fe Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 2 Jan 2013 19:00:44 +0000 Subject: [PATCH] Enhancements to ~alias as per [#95] --- modules/users/strings.json | 7 +++++-- modules/users/users.js | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/users/strings.json b/modules/users/strings.json index 2a8b876..b334100 100644 --- a/modules/users/strings.json +++ b/modules/users/strings.json @@ -2,10 +2,13 @@ "alias": { "english": "{alias} is an alias of {user}" }, + "primary": { + "english": "{user} is a primary user with {count} aliases." + }, "unknown_alias": { - "english": "{alias} does not currently exist as an alias." + "english": "{alias} does not currently exist as an alias or known user." }, "aliasparentset": { - "english": "{newParent} is now the parent user, and {newAlias} is an alias" + "english": "{newParent} is now the parent user, and {newAlias} is an alias." } } diff --git a/modules/users/users.js b/modules/users/users.js index 17457e3..ab342a4 100644 --- a/modules/users/users.js +++ b/modules/users/users.js @@ -25,7 +25,13 @@ var users = function(dbot) { '~alias': function(event) { var knownUsers = getServerUsers(event); var alias = event.params[1].trim(); - if(knownUsers.aliases.hasOwnProperty(alias)) { + if(knownUsers.users.include(alias)) { + var aliasCount = 0; + knownUsers.aliases.each(function(primaryUser) { + if(primaryUser == alias) aliasCount += 1; + }.bind(this)); + event.reply(dbot.t('primary', { 'user': alias, 'count': aliasCount })); + } else if(knownUsers.aliases.hasOwnProperty(alias)) { event.reply(dbot.t('alias', { 'alias': alias, 'user': knownUsers.aliases[alias] })); } else {