add merge users command and fix up strings

This commit is contained in:
reality 2014-09-04 09:51:39 +00:00
parent 0a4240f3db
commit 905ced9485
4 changed files with 64 additions and 40 deletions

View File

@ -63,3 +63,7 @@ var api = function(dbot) {
} }
}; };
}; };
exports.fetch = function(dbot) {
return api(dbot);
};

View File

@ -9,26 +9,26 @@ var commands = function(dbot) {
this.api.getUserAliases(user.id, function(err, aliases) { this.api.getUserAliases(user.id, function(err, aliases) {
var including = _.first(aliases, 10).join(', '); var including = _.first(aliases, 10).join(', ');
if(nick === user.primaryNick) { if(nick !== user.primaryNick) {
if(aliases.length === 0) {
event.reply(dbot.t('primary_no_alias', {
'user': user.primaryNick,
'currentNick': user.currentNick
}));
} else {
event.reply(dbot.t('primary', {
'user': user.primaryNick,
'currentNick': user.currentNick,
'count': aliases.length,
'including': including
}));
}
} else {
event.reply(dbot.t('alias', { event.reply(dbot.t('alias', {
'alias': nick, 'alias': nick,
'user': user.primaryNick 'user': user.primaryNick
})); }));
} }
if(aliases.length === 0) {
event.reply(dbot.t('primary_no_alias', {
'user': user.primaryNick,
'currentNick': user.currentNick
}));
} else {
event.reply(dbot.t('primary', {
'user': user.primaryNick,
'currentNick': user.currentNick,
'count': aliases.length,
'including': including
}));
}
}); });
} else { } else {
event.reply(dbot.t('unknown_alias', { 'alias': nick })); event.reply(dbot.t('unknown_alias', { 'alias': nick }));
@ -69,7 +69,7 @@ var commands = function(dbot) {
if(user) { if(user) {
if(user.primaryNick !== newPrimary) { if(user.primaryNick !== newPrimary) {
this.internalAPI.reparentUser(user, newPrimary, function() { this.internalAPI.reparentUser(user, newPrimary, function() {
event.reply(dbot.t('aliasparentset', { event.reply(dbot.t('alias_parent_set', {
'newParent': newPrimary, 'newParent': newPrimary,
'newAlias': user.primaryNick 'newAlias': user.primaryNick
})); }));
@ -98,6 +98,30 @@ var commands = function(dbot) {
event.reply(dbot.t('unknown_alias', { 'alias': nick })); event.reply(dbot.t('unknown_alias', { 'alias': nick }));
} }
}); });
},
'~mergeusers': function(event) {
var oldNick = event.params[1],
newNick = event.params[2];
this.api.resolveUser(event.server, oldNick, function(err, oldUser) {
if(oldUser) {
this.api.resolveUser(event.server, newNick, function(err, newUser) {
if(newUser) {
this.internalAPI.mergeUsers(oldUser, newUser, function() {
event.reply(dbot.t('merged_users', {
'old_user': secondaryUser,
'new_user': primaryUser
}));
});
} else {
event.reply(dbot.t('unknown_alias', { 'alias': newNick }));
}
}.bind(this));
} else {
event.reply(dbot.t('unknown_alias', { 'alias': oldNick }));
}
}.bind(this));
} }
}; };
this.commands['~setaliasparent'].access = 'moderator'; this.commands['~setaliasparent'].access = 'moderator';

View File

@ -8,22 +8,23 @@
"fr": "{alias} est un alias de {user}", "fr": "{alias} est un alias de {user}",
"it": "{alias} è un alias di {user}" "it": "{alias} è un alias di {user}"
}, },
"added_mobile_alias": {
"en": "{alias} added as a mobile alias.",
"de": "{alias} als mobiler Benutzer hinzugefügt."
},
"already_mobile": {
"en": "{alias} is already a mobile alias.",
"de": "{alias} ist bereits ein mobiler Benutzer."
},
"primary": { "primary": {
"en": "{user} (currently {currentNick}) is a primary user with {count} aliases, ", "en": "{user} (currently {currentNick}) is a primary user with {count} aliases, including {including}.",
"na'vi": "{user} ({currentNick}) lu txin ulte {count}a stxo lu poru, ", "na'vi": "{user} ({currentNick}) lu txin ulte {count}a stxo lu poru, {including}",
"nl": "{user} ({currentNick}) is een primaire gebruiker met {count} aliassen, ", "nl": "{user} ({currentNick}) is een primaire gebruiker met {count} aliassen, {including}",
"cy": "Mae {user} ({currentNick}) yn ddefnyddiwr gynradd gyda {count} enwau eraill, ", "cy": "Mae {user} ({currentNick}) yn ddefnyddiwr gynradd gyda {count} enwau eraill, ",
"de": "{user} ({currentNick}) ist ein Benutzer mit {count} Nicknamen, ", "de": "{user} ({currentNick}) ist ein Benutzer mit {count} Nicknamen, {including}",
"fr": "{user} (actuellement {currentNick}) est un utilisateur primaire avec {count} alias, ", "fr": "{user} (actuellement {currentNick}) est un utilisateur primaire avec {count} alias, {including}",
"it": "{user} (attualmente {currentNick}) è un utente primario con {count} alias, " "it": "{user} (attualmente {currentNick}) è un utente primario con{count} alias, {including}"
},
"primary_no_alias": {
"en": "{user} (currently {currentNick}) is a primary user.",
"na'vi": "{user} ({currentNick}) lu txin ulte",
"nl": "{user} ({currentNick}) is een primaire gebruiker",
"cy": "Mae {user} ({currentNick}) yn ddefnyddiwr gynradd",
"de": "{user} ({currentNick}) ist ein Benutzer",
"fr": "{user} (actuellement {currentNick}) est un utilisateur primaire",
"it": "{user} (attualmente {currentNick}) è un utente primario"
}, },
"unknown_alias": { "unknown_alias": {
"en": "{alias} does not currently exist as an alias or known user.", "en": "{alias} does not currently exist as an alias or known user.",
@ -39,7 +40,7 @@
"de": "Alias {alias} von {primary} entfernt.", "de": "Alias {alias} von {primary} entfernt.",
"it": "Tolto alias {alias} da {primary}." "it": "Tolto alias {alias} da {primary}."
}, },
"aliasparentset": { "alias_parent_set": {
"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.",
"cy": "Mae {newParent} ydy defnyddiwr rhiant nawr, a {alias} ydy enw arall.", "cy": "Mae {newParent} ydy defnyddiwr rhiant nawr, a {alias} ydy enw arall.",
@ -48,15 +49,6 @@
"fr": "{newParent} est maintenant le même utilisateur parent, et {newAlias} est un alias.", "fr": "{newParent} est maintenant le même utilisateur parent, et {newAlias} est un alias.",
"it": "{newParent} è adesso l' utente genitore e {newAlias} è un alias." "it": "{newParent} è adesso l' utente genitore e {newAlias} è un alias."
}, },
"unprimary_error": {
"en": "{nick} isn't recorded as a primary user.",
"na'vi": "fo sute txin ke lu.",
"cy": "Nid yw un o'r defnyddwyr hynny yn cael ei gofnodi ar hyn o bryd fel defnyddiwr gynradd.",
"nl": "Een van deze gebruikers is nog niet bekend als een primaire gebruiker.",
"de": "Einer dieser Benutzer ist nicht als Hauptbenutzer gespeichert.",
"fr": "{nick} n'est pas enregistré en tant qu'utilisateur primaire.",
"it": "{nick} non è registrato come utente principale."
},
"merged_users": { "merged_users": {
"en": "{old_user} and their aliases have been merged into {new_user}.", "en": "{old_user} and their aliases have been merged into {new_user}.",
"na'vi": "{old_user} ulte stxo alahe {new_user} lu set.", "na'vi": "{old_user} ulte stxo alahe {new_user} lu set.",

View File

@ -140,3 +140,7 @@ var users = function(dbot) {
}); });
}.bind(this); }.bind(this);
}; };
exports.fetch = function(dbot) {
return new users(dbot);
};