3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-30 16:09:27 +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) {
if(!err) {
if(_.include(ignores.ignores, module)) {
ignores.ignores = _.without(ignores.ignores, module);
this.db.save('ignores', user.id, function(err) {
if(!err) {
dbot.instance.removeIgnore(event.user, module) dbot.instance.removeIgnore(event.user, module)
event.reply(dbot.t('unignored', { event.reply(dbot.t('unignored', {
'user': event.user, 'user': event.user,
'module': module 'module': module
})); }));
}
});
} else { } else {
event.reply(dbot.t('invalid_unignore', { 'user': event.user })); 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) { });
}; };
}; };