create ~removealias command [Close #549]

This commit is contained in:
reality 2013-08-17 17:23:43 +00:00
parent 9d6b2cc3e1
commit 52d38aa1e7
4 changed files with 31 additions and 1 deletions

View File

@ -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. The secondary user and all of their aliases will be merged under primaryuser.
Requires moderator level access by default. Requires moderator level access by default.
#### ~addalias [user] [alias]
Manually add alias to user.
#### ~removealias [alias]
Remove alias from user.
### API ### API
#### resolveUser(server, nick, callback) #### resolveUser(server, nick, callback)

View File

@ -60,6 +60,24 @@ var commands = function(dbot) {
}.bind(this)); }.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) { '~setaliasparent': function(event) {
var newPrimary = event.params[1].trim(); var newPrimary = event.params[1].trim();
this.api.resolveUser(event.server, newPrimary, function(user) { this.api.resolveUser(event.server, newPrimary, function(user) {
@ -135,6 +153,7 @@ var commands = function(dbot) {
commands['~setaliasparent'].access = 'moderator'; commands['~setaliasparent'].access = 'moderator';
commands['~mergeusers'].access = 'moderator'; commands['~mergeusers'].access = 'moderator';
commands['~addalias'].access = 'moderator'; commands['~addalias'].access = 'moderator';
commands['~removealias'].access = 'moderator';
return commands; return commands;
}; };

View File

@ -26,6 +26,9 @@
"fr": "{alias} n'existe pas actuellement en tant qu'alias ou utilisateur connu.", "fr": "{alias} n'existe pas actuellement en tant qu'alias ou utilisateur connu.",
"it": "{alias} non esiste attualmente come alias o utente conosciuto." "it": "{alias} non esiste attualmente come alias o utente conosciuto."
}, },
"alias_removed": {
"en": "Removed alias {alias} from {primary}."
},
"aliasparentset": { "aliasparentset": {
"en": "{newParent} is now the parent user, and {newAlias} is an alias.", "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.", "na'vi": "{newParent} lu sa'sem set ulte {newAlias} lu stxo set nìteng.",

View File

@ -1,5 +1,7 @@
{ {
"~alias": "~alias [nick]", "~alias": "~alias [nick]",
"~setaliasparent": "~setaliasparent [nick]", "~setaliasparent": "~setaliasparent [nick]",
"~mergeusers": "~mergeusers [primary] [secondary]" "~mergeusers": "~mergeusers [primary] [secondary]",
"~addalias": "~addalias [user] [alias]",
"~removealias": "~removealias [alias]"
} }