3
0
mirror of https://github.com/reality/dbot.git synced 2025-01-27 12:34:15 +01:00

isIgnoring now belongs in ignore.api, changes in command to reflect this. ~ignore now operational for commands. [#331]

This commit is contained in:
reality 2013-04-10 01:28:53 +00:00
parent 6cea1256ce
commit b56ac4164a
4 changed files with 29 additions and 40 deletions

View File

@ -35,16 +35,6 @@ var api = function(dbot) {
return access; 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 Regex to event message, store result. Return false if it doesn't
* apply. * apply.

View File

@ -24,37 +24,36 @@ var command = function(dbot) {
if(this.api.isBanned(event.user, commandName)) { if(this.api.isBanned(event.user, commandName)) {
event.reply(dbot.t('command_ban', {'user': event.user})); event.reply(dbot.t('command_ban', {'user': event.user}));
} else { } else {
if(!this.api.isIgnoring(event.user, commandName) && dbot.api.ignore.isUserIgnoring(event.server, event.user, commandName, function(isIgnoring) {
!this.api.isIgnoring(event.channel, commandName) && if(!isIgnoring && this.api.hasAccess(event.user, commandName) && dbot.commands[commandName].disabled !== true) {
this.api.hasAccess(event.user, commandName) && if(this.api.applyRegex(commandName, event)) {
dbot.commands[commandName].disabled !== true) { try {
if(this.api.applyRegex(commandName, event)) { var command = dbot.commands[commandName];
try { var results = command.apply(dbot.modules[command.module], [event]);
var command = dbot.commands[commandName]; if(_.has(command, 'hooks') && results !== false) {
var results = command.apply(dbot.modules[command.module], [event]); _.each(command['hooks'], function(hook) {
if(_.has(command, 'hooks') && results !== false) { hook.apply(hook.module, _.values(results));
_.each(command['hooks'], function(hook) { }, this);
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) { dbot.save();
if(dbot.config.debugMode == true) { } else {
event.reply('- Error in ' + commandName + ':'); if(commandName !== '~') {
event.reply('- Message: ' + err); if(_.has(dbot.usage, commandName)) {
event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim()); 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); }.bind(this);
this.on = 'PRIVMSG'; this.on = 'PRIVMSG';

View File

@ -1,5 +1,5 @@
var _ = require('underscore')._, var _ = require('underscore')._,
uuid = require('node-uuid'); uuid = require('node-uuid'),
databank = require('databank'), databank = require('databank'),
AlreadyExistsError = databank.AlreadyExistsError, AlreadyExistsError = databank.AlreadyExistsError,
NoSuchThingError = databank.NoSuchThingError, NoSuchThingError = databank.NoSuchThingError,