forked from GitHub/dbot
mergeChannelUsers internal API function in users + mergeusers seems to be working [#470]
This commit is contained in:
parent
2fc5fc6992
commit
5dddae4f00
@ -83,7 +83,7 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('unknown_alias', { 'alias': newPrimary }));
|
event.reply(dbot.t('unknown_alias', { 'alias': newPrimarj }));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
@ -94,15 +94,16 @@ var commands = function(dbot) {
|
|||||||
|
|
||||||
this.api.resolveUser(event.server, primaryUser, function(user) {
|
this.api.resolveUser(event.server, primaryUser, function(user) {
|
||||||
if(user) {
|
if(user) {
|
||||||
this.api.resolveUser(event.server, secondaryUser, function(secondaryUser) {
|
this.api.resolveUser(event.server, secondaryUser, function(oldUser) {
|
||||||
if(secondaryUser) {
|
if(secondaryUser) {
|
||||||
user.aliases.push(secondaryUser.primaryNick);
|
user.aliases.push(oldUser.primaryNick);
|
||||||
user.aliases.concat(secondaryUser.aliases);
|
user.aliases.concat(oldUser.aliases);
|
||||||
this.db.del('users', secondaryUser.id, function(err) {
|
this.internalAPI.mergeChannelUsers(event.server, oldUser, primaryUser);
|
||||||
|
this.db.del('users', oldUser.id, function(err) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
this.db.save('users', user.id, user, function(err) {
|
this.db.save('users', user.id, user, function(err) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
this.updateChannels(event, secondaryUser, primaryUser);
|
this.internalAPI.mergeChannelUsers(event.server, secondaryUser, primaryUser);
|
||||||
event.reply(dbot.t('merged_users', {
|
event.reply(dbot.t('merged_users', {
|
||||||
'old_user': secondaryUser,
|
'old_user': secondaryUser,
|
||||||
'new_user': primaryUser
|
'new_user': primaryUser
|
||||||
@ -116,11 +117,11 @@ var commands = function(dbot) {
|
|||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('unprimary_error'));
|
event.reply(dbot.t('unprimary_error', { 'nick': secondaryUser }));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
} else {
|
} else {
|
||||||
event.reply(dbot.t('unprimary_error'));
|
event.reply(dbot.t('unprimary_error', { 'nick': primaryUser }));
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
"nl": "{newParent} is nu de bovenliggende gebruiker, en {newAlias} is een alias."
|
"nl": "{newParent} is nu de bovenliggende gebruiker, en {newAlias} is een alias."
|
||||||
},
|
},
|
||||||
"unprimary_error": {
|
"unprimary_error": {
|
||||||
"en": "One of those users isn't currently recorded as a primary user.",
|
"en": "{nick} isn't recorded as a primary user.",
|
||||||
"na'vi": "fo sute txin ke lu.",
|
"na'vi": "fo sute txin ke lu.",
|
||||||
"nl": "Een van deze gebruikers is nog niet bekend als een primaire gebruiker."
|
"nl": "Een van deze gebruikers is nog niet bekend als een primaire gebruiker."
|
||||||
},
|
},
|
||||||
|
@ -67,7 +67,26 @@ var users = function(dbot) {
|
|||||||
// QQ
|
// QQ
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}.bind(this)
|
}.bind(this),
|
||||||
|
|
||||||
|
'mergeChannelUsers': function(server, oldUser, newUser) {
|
||||||
|
newUser.channels = _.union(oldUser.channels, newUser.channels);
|
||||||
|
_.each(newUser.channels, function(name) {
|
||||||
|
this.api.getChannel(server, name, function(channel) {
|
||||||
|
if(_.include(channel.users, oldUser.id)) {
|
||||||
|
channel.users = _.without(channel.users, oldUser.id);
|
||||||
|
}
|
||||||
|
if(!_.include(channel.users, newUser.id)) {
|
||||||
|
channel.users.push(newUser.id);
|
||||||
|
}
|
||||||
|
this.db.save('channel_users', channel.id, channel, function(err) {
|
||||||
|
if(err) {
|
||||||
|
// QQ
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.listener = function(event) {
|
this.listener = function(event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user