3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 21:09:31 +01:00
dbot/modules/ignore/api.js

50 lines
1.5 KiB
JavaScript
Raw Normal View History

2013-04-11 22:17:14 +02:00
var _ = require('underscore')._;
var api = function(dbot) {
return {
// 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);
},
// 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);
},
// Is channel ignoring module?
// TODO: Command support
2013-06-27 17:33:18 +02:00
'isChannelIgnoring': function(channelName, item, callback) {
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);
});
},
// 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);
} else {
2013-06-27 17:33:18 +02:00
callback(true, null);
}
2013-06-27 17:33:18 +02:00
});
}
};
}
exports.fetch = function(dbot) {
return api(dbot);
};