diff --git a/modules/command/api.js b/modules/command/api.js index dd19b9e..3261a65 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -35,16 +35,6 @@ var api = function(dbot) { return access; }, - /** - * Is item (user or channel) ignoring command? - */ - 'isIgnoring': function(item, command) { - var module = dbot.commands[command].module; - return (_.has(dbot.db.ignores, item) && - (_.include(dbot.db.ignores[item], module) || - _.include(dbot.db.ignores[item], '*'))); - }, - /** * Apply Regex to event message, store result. Return false if it doesn't * apply. diff --git a/modules/command/command.js b/modules/command/command.js index 935f6e0..1c636e5 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -24,37 +24,36 @@ var command = function(dbot) { if(this.api.isBanned(event.user, commandName)) { event.reply(dbot.t('command_ban', {'user': event.user})); } else { - if(!this.api.isIgnoring(event.user, commandName) && - !this.api.isIgnoring(event.channel, commandName) && - this.api.hasAccess(event.user, commandName) && - dbot.commands[commandName].disabled !== true) { - if(this.api.applyRegex(commandName, event)) { - try { - var command = dbot.commands[commandName]; - var results = command.apply(dbot.modules[command.module], [event]); - if(_.has(command, 'hooks') && results !== false) { - _.each(command['hooks'], function(hook) { - hook.apply(hook.module, _.values(results)); - }, this); + dbot.api.ignore.isUserIgnoring(event.server, event.user, commandName, function(isIgnoring) { + if(!isIgnoring && this.api.hasAccess(event.user, commandName) && dbot.commands[commandName].disabled !== true) { + if(this.api.applyRegex(commandName, event)) { + try { + var command = dbot.commands[commandName]; + var results = command.apply(dbot.modules[command.module], [event]); + if(_.has(command, 'hooks') && results !== false) { + _.each(command['hooks'], function(hook) { + hook.apply(hook.module, _.values(results)); + }, this); + } + } catch(err) { + if(dbot.config.debugMode == true) { + event.reply('- Error in ' + commandName + ':'); + event.reply('- Message: ' + err); + event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim()); + } } - } catch(err) { - if(dbot.config.debugMode == true) { - event.reply('- Error in ' + commandName + ':'); - event.reply('- Message: ' + err); - event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim()); + dbot.save(); + } else { + if(commandName !== '~') { + if(_.has(dbot.usage, commandName)) { + event.reply('Usage: ' + dbot.usage[commandName]); + } else { + event.reply(dbot.t('syntax_error')); + } } - } - dbot.save(); - } else { - if(commandName !== '~') { - if(_.has(dbot.usage, commandName)) { - event.reply('Usage: ' + dbot.usage[commandName]); - } else { - event.reply(dbot.t('syntax_error')); - } - } + } } - } + }.bind(this)); } }.bind(this); this.on = 'PRIVMSG'; diff --git a/modules/ignore/ignore.js b/modules/ignore/ignore.js index 6e1e9d1..ffe64e8 100644 --- a/modules/ignore/ignore.js +++ b/modules/ignore/ignore.js @@ -68,7 +68,7 @@ var ignore = function(dbot) { '~unignore': function(event) { var module = event.params[1]; - + dbot.api.users.resolveUser(event.server, event.user, function(user) { this.db.read('ignores', user.id, function(err, ignores) { if(!ignores) { diff --git a/modules/users/api.js b/modules/users/api.js index 207b4d3..ebfefea 100644 --- a/modules/users/api.js +++ b/modules/users/api.js @@ -1,5 +1,5 @@ var _ = require('underscore')._, - uuid = require('node-uuid'); + uuid = require('node-uuid'), databank = require('databank'), AlreadyExistsError = databank.AlreadyExistsError, NoSuchThingError = databank.NoSuchThingError,