~addalias command for adding non-used nicks to user alias records [#373]

This commit is contained in:
reality 2013-04-20 11:21:04 +00:00
parent 8712216948
commit 4319ee18e1
2 changed files with 33 additions and 0 deletions

View File

@ -35,6 +35,31 @@ var commands = function(dbot) {
});
},
'~addalias': function(event) {
var nick = event.input[1],
alias = event.input[2];
this.api.resolveUser(event.server, nick, function(user) {
if(user) {
if(!_.include(user.aliases, alias)) {
user.aliases.push(alias);
this.db.save('users', user.id, user, function(err) {
if(!err) {
event.reply(dbot.t('alias_added', {
'user': user.primaryNick,
'alias': alias
}));
}
});
} else {
event.reply(dbot.t('alias_exists', { '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) {
@ -104,9 +129,11 @@ var commands = function(dbot) {
commands['~alias'].regex = [/^~alias ([\d\w[\]{}^|\\`_-]+?)/, 2];
commands['~setaliasparent'].regex = [/^~setaliasparent ([\d\w[\]{}^|\\`_-]+?)/, 2];
commands['~mergeusers'].regex = [/^~mergeusers ([\d\w[\]{}^|\\`_-]+?)\s*?([\d\w[\]{}^|\\`_-]+?)/, 3];
commands['~addalias'].regex = [/^~addalias ([\d\w[\]{}^|\\`_-]+?) ([\d\w[\]{}^|\\`_-]+?)$/, 3];
commands['~setaliasparent'].access = 'moderator';
commands['~mergeusers'].access = 'moderator';
commands['~addalias'].access = 'moderator';
return commands;
};

View File

@ -28,5 +28,11 @@
"en": "{old_user} and their aliases have been merged into {new_user}.",
"na'vi": "{old_user} ulte stxo alahe {new_user} lu set.",
"nl": "{old_user} en zijn aliassen zijn samengevoegd met {new_user}."
},
"alias_exists": {
"en": "Alias {alias} already exists."
},
"alias_added": {
"en": "Alias {alias} added to {user}."
}
}