2013-04-11 22:17:14 +02:00
|
|
|
var _ = require('underscore')._;
|
2013-04-10 09:50:47 +02:00
|
|
|
|
|
|
|
var api = function(dbot) {
|
|
|
|
return {
|
2013-04-11 22:12:29 +02:00
|
|
|
// Is user ignoring command/module?
|
2013-06-27 17:33:18 +02:00
|
|
|
'isUserIgnoring': function(user, item, callback) {
|
|
|
|
this.internalAPI.isUserImpeded(user, item, 'ignores', callback);
|
2013-04-11 22:12:29 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Is user banned from command/module?
|
2013-06-27 17:33:18 +02:00
|
|
|
'isUserBanned': function(user, item, callback) {
|
|
|
|
this.internalAPI.isUserImpeded(user, item, 'bans', callback);
|
2013-04-11 22:12:29 +02:00
|
|
|
},
|
|
|
|
|
2013-04-11 23:21:12 +02:00
|
|
|
// Is channel ignoring module?
|
|
|
|
// TODO: Command support
|
2013-06-27 17:33:18 +02:00
|
|
|
'isChannelIgnoring': function(channelName, item, callback) {
|
2013-04-11 23:21:12 +02:00
|
|
|
var isIgnoring = false,
|
|
|
|
channel = false;
|
|
|
|
|
|
|
|
this.db.search('channel_ignores', {
|
|
|
|
'server': server,
|
|
|
|
'name': channel
|
|
|
|
}, function(result) {
|
|
|
|
channel = result;
|
|
|
|
}, function(err) {
|
|
|
|
if(!err && channel && _.include(channel.ignores, item)) {
|
|
|
|
isIgnoring = true;
|
|
|
|
}
|
|
|
|
callback(isIgnoring);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2013-04-11 22:12:29 +02:00
|
|
|
// Resolve a nick and return their user and ignores object
|
2013-06-27 17:33:18 +02:00
|
|
|
'getUserIgnores': function(user, callback) {
|
|
|
|
this.db.read('ignores', user.id, function(err, ignores) {
|
|
|
|
if(!err && ignores) {
|
|
|
|
callback(false, ignores);
|
2013-04-11 22:12:29 +02:00
|
|
|
} else {
|
2013-06-27 17:33:18 +02:00
|
|
|
callback(true, null);
|
2013-04-11 22:12:29 +02:00
|
|
|
}
|
2013-06-27 17:33:18 +02:00
|
|
|
});
|
2013-04-10 09:50:47 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return api(dbot);
|
|
|
|
};
|