3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

Provisional onLoad and ~unignore for ignores module. Needs testing. [#331]

This commit is contained in:
reality 2013-04-09 23:16:40 +00:00
parent 9952e4583c
commit 5c48971034

View File

@ -79,16 +79,28 @@ var ignore = function(dbot) {
'modules': ignoredModules.join(', ') 'modules': ignoredModules.join(', ')
})); }));
} else { } else {
if(_.include(ignoredModules, module)) { dbot.api.users.resolveUser(event.server, event.user, function(user) {
dbot.db.ignores[event.user].splice(dbot.db.ignores[event.user].indexOf(module), 1); this.db.read('ignores', user.id, function(err, ignores) {
dbot.instance.removeIgnore(event.user, module) if(!err) {
event.reply(dbot.t('unignored', { if(_.include(ignores.ignores, module)) {
'user': event.user, ignores.ignores = _.without(ignores.ignores, module);
'module': module this.db.save('ignores', user.id, function(err) {
})); if(!err) {
} else { dbot.instance.removeIgnore(event.user, module)
event.reply(dbot.t('invalid_unignore', { 'user': event.user })); event.reply(dbot.t('unignored', {
} 'user': event.user,
'module': module
}));
}
});
} else {
event.reply(dbot.t('invalid_unignore', { 'user': event.user }));
}
} else if(err == NoSuchThingError) {
event.reply(dbot.t('invalid_unignore', { 'user': event.user }));
}
});
});
} }
}, },
@ -207,11 +219,16 @@ var ignore = function(dbot) {
this.onLoad = function() { this.onLoad = function() {
dbot.instance.clearIgnores(); dbot.instance.clearIgnores();
_.each(dbot.db.ignores, function(ignores, item) {
_.each(ignores, function(ignore) { this.db.scan('ignores', function(ignores) {
dbot.instance.ignoreTag(item, ignore); dbot.api.users.getUser(ignores.id, function(user) {
}, this); if(user) {
}, this); _.each(ignores.ignores, function(module) {
dbot.instance.ignoreTag(user.primaryNick, module);
});
}
});
}, function(err) { });
}; };
}; };