3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 20:39:25 +01:00
dbot/modules/ignore/api.js
reality 223b20b598 * ~ban and ~unban now fully databankerised and tested [#331]
* Refactored ~ignore and ~unignore
* Refactored API
* Command uses new ban/ignore APIs, removed its own isBanned
* Ignore is now aware of servers [#188]
2013-04-11 20:12:29 +00:00

38 lines
1.2 KiB
JavaScript

var _ = require('underscore')._,
databank = require('databank'),
AlreadyExistsError = databank.AlreadyExistsError,
NoSuchThingError = databank.NoSuchThingError,
NotImplementedError = databank.NotImplementedError;
var api = function(dbot) {
return {
// Is user ignoring command/module?
'isUserIgnoring': function(server, user, item, callback) {
this.internalAPI.isUserImpeded(server, user, item, 'ignores', callback);
},
// Is user banned from command/module?
'isUserBanned': function(server, user, item, callback) {
this.internalAPI.isUserImpeded(server, user, item, 'bans', callback);
},
// Resolve a nick and return their user and ignores object
'getUserIgnores': function(server, user, callback) {
dbot.api.users.resolveUser(server, user, function(user) {
if(user) {
this.db.read('ignores', user.id, function(err, ignores) {
callback(false, user, ignores);
});
} else {
callback(true, null, null);
}
}.bind(this));
}
};
}
exports.fetch = function(dbot) {
return api(dbot);
};