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

adding initial support for wildcard ignores/bans

This commit is contained in:
John Maguire 2013-03-21 06:34:33 -04:00
parent d197a30b17
commit e90572aebf

View File

@ -4,8 +4,10 @@ var api = function(dbot) {
return { return {
'isBanned': function(user, command) { 'isBanned': function(user, command) {
var banned = false; var banned = false;
if(_.has(dbot.db.bans, command)) { if(_.has(dbot.db.bans, user)) {
if(_.include(dbot.db.bans[command], user) || _.include(dbot.db.bans['*'], user)) { if(_.include(dbot.db.bans[user], command) ||
_.include(dbot.db.bans[user], dbot.commands[command].module) ||
_.include(dbot.db.bans[user], '*')) {
banned = true; banned = true;
} }
} }
@ -39,7 +41,8 @@ var api = function(dbot) {
'isIgnoring': function(item, command) { 'isIgnoring': function(item, command) {
var module = dbot.commands[command].module; var module = dbot.commands[command].module;
return (_.has(dbot.db.ignores, item) && return (_.has(dbot.db.ignores, item) &&
_.include(dbot.db.ignores[item], module)); (_.include(dbot.db.ignores[item], module) ||
_.include(dbot.db.ignores[item], '*')));
}, },
/** /**