2012-12-11 17:04:52 +01:00
|
|
|
var poll = function(dbot) {
|
2013-01-20 21:22:27 +01:00
|
|
|
this.internalAPI = {
|
|
|
|
'updatePollNicks': function(server, oldNick) {
|
|
|
|
var newNick = dbot.api.users.resolveUser(server, oldNick);
|
|
|
|
_.each(dbot.db.polls, function(poll) {
|
|
|
|
if(poll.owner === oldNick) {
|
|
|
|
poll.owner = newNick;
|
|
|
|
}
|
|
|
|
if(_.has(poll.votees, oldNick)) {
|
|
|
|
poll.votees[newNick] = poll.votees[oldNick];
|
|
|
|
delete poll.votees[oldNick];
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.onLoad = function() {
|
2013-05-26 00:09:07 +02:00
|
|
|
// dbot.api.command.addHook('~setaliasparent', this.internalAPI.updatePollNicks);
|
|
|
|
// dbot.api.command.addHook('~mergeusers', this.internalAPI.updatePollNicks);
|
2013-01-20 21:22:27 +01:00
|
|
|
}.bind(this);
|
2012-12-11 17:04:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
2013-01-15 17:21:43 +01:00
|
|
|
return new poll(dbot);
|
2012-12-11 17:04:52 +01:00
|
|
|
}
|