diff --git a/modules/users/README.md b/modules/users/README.md index 90ac175..be8c3e7 100644 --- a/modules/users/README.md +++ b/modules/users/README.md @@ -24,6 +24,12 @@ This command merges two nicks which are recorded as primary users into one user. The secondary user and all of their aliases will be merged under primaryuser. Requires moderator level access by default. +#### ~addalias [user] [alias] +Manually add alias to user. + +#### ~removealias [alias] +Remove alias from user. + ### API #### resolveUser(server, nick, callback) diff --git a/modules/users/commands.js b/modules/users/commands.js index 884125b..2754bfc 100644 --- a/modules/users/commands.js +++ b/modules/users/commands.js @@ -60,6 +60,24 @@ var commands = function(dbot) { }.bind(this)); }, + '~removealias': function(event) { + var alias = event.params[1]; + + this.api.resolveUser(event.server, alias, function(user) { + if(user) { + user.aliases = _.without(user.aliases, alias); + this.db.save('users', user.id, user, function(err) { + event.reply(dbot.t('alias_removed', { + 'primary': user.primaryNick, + 'alias': alias + })); + }); + } else { + event.reply(dbot.t('unknown_alias', { 'alias': nick })); + } + }.bind(this)); + }, + '~setaliasparent': function(event) { var newPrimary = event.params[1].trim(); this.api.resolveUser(event.server, newPrimary, function(user) { @@ -135,6 +153,7 @@ var commands = function(dbot) { commands['~setaliasparent'].access = 'moderator'; commands['~mergeusers'].access = 'moderator'; commands['~addalias'].access = 'moderator'; + commands['~removealias'].access = 'moderator'; return commands; }; diff --git a/modules/users/strings.json b/modules/users/strings.json index fd0fdd7..fc2facd 100644 --- a/modules/users/strings.json +++ b/modules/users/strings.json @@ -26,6 +26,9 @@ "fr": "{alias} n'existe pas actuellement en tant qu'alias ou utilisateur connu.", "it": "{alias} non esiste attualmente come alias o utente conosciuto." }, + "alias_removed": { + "en": "Removed alias {alias} from {primary}." + }, "aliasparentset": { "en": "{newParent} is now the parent user, and {newAlias} is an alias.", "na'vi": "{newParent} lu sa'sem set ulte {newAlias} lu stxo set nìteng.", diff --git a/modules/users/usage.json b/modules/users/usage.json index 203bd4d..8943282 100644 --- a/modules/users/usage.json +++ b/modules/users/usage.json @@ -1,5 +1,7 @@ { "~alias": "~alias [nick]", "~setaliasparent": "~setaliasparent [nick]", - "~mergeusers": "~mergeusers [primary] [secondary]" + "~mergeusers": "~mergeusers [primary] [secondary]", + "~addalias": "~addalias [user] [alias]", + "~removealias": "~removealias [alias]" }