mirror of
https://github.com/reality/dbot.git
synced 2024-12-28 05:32:50 +01:00
Fix ~setaliasparent [#272]
This commit is contained in:
parent
3814df98f6
commit
17c2c4b317
@ -15,7 +15,6 @@ var api = function(dbot) {
|
||||
'resolveUser': function(server, nick, callback) {
|
||||
var user = false;
|
||||
this.db.search('users', { 'server': server }, function(result) {
|
||||
console.log(result.primaryNick);
|
||||
if(result.primaryNick == nick || _.include(result.aliases, nick)) {
|
||||
user = result;
|
||||
}
|
||||
|
@ -36,14 +36,19 @@ var commands = function(dbot) {
|
||||
'~setaliasparent': function(event) {
|
||||
var newPrimary = event.params[1].trim();
|
||||
this.api.resolveUser(event.server, newPrimary, function(user) {
|
||||
if(user) {
|
||||
if(user && user.primaryNick != newPrimary) {
|
||||
var newAlias = user.primaryNick;
|
||||
user.primaryNick = newPrimary;
|
||||
user.aliases = _.without(user.aliases, newPrimary).push(newAlias);
|
||||
user.aliases = _.without(user.aliases, newPrimary);
|
||||
user.aliases.push(newAlias);
|
||||
this.internalAPI.updateChannelPrimaryUser(event.server, newAlias, newPrimary);
|
||||
|
||||
this.db.save('users', user.id, user, function(err) {
|
||||
if(!err) {
|
||||
event.reply(dbot.t('aliasparentset', {
|
||||
'newParent': newPrimary,
|
||||
'newAlias': newAlias
|
||||
}));
|
||||
dbot.api.event.emit('~setaliasparent', {
|
||||
'server': event.server,
|
||||
'alias': newAlias
|
||||
@ -51,7 +56,7 @@ var commands = function(dbot) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
event.reply(dbot.t('unknown_alias', { 'alias': newParent }));
|
||||
event.reply(dbot.t('unknown_alias', { 'alias': newPrimary }));
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
@ -80,17 +85,17 @@ var commands = function(dbot) {
|
||||
'secondary': secondaryUser
|
||||
});
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
} else {
|
||||
event.reply(dbot.t('unprimary_error'));
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
} else {
|
||||
event.reply(dbot.t('unprimary_error'));
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ var users = function(dbot) {
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}.bind(this));
|
||||
}.bind(this),
|
||||
|
||||
'updateChannelPrimaryUser': function(server, oldUser, newUser) {
|
||||
@ -82,7 +82,6 @@ var users = function(dbot) {
|
||||
this.api.isKnownUser(event.server, event.newNick, function(isKnown) {
|
||||
if(!isKnown) {
|
||||
this.api.resolveUser(event.server, event.user, function(user) {
|
||||
dbot.say('aberwiki', '#realitest', event.newNick);
|
||||
user.aliases.push(event.newNick);
|
||||
this.db.save('users', user.id, user, function(err) {
|
||||
if(!err) {
|
||||
|
Loading…
Reference in New Issue
Block a user