forked from GitHub/dbot
isIgnoring now belongs in ignore.api, changes in command to reflect this. ~ignore now operational for commands. [#331]
This commit is contained in:
parent
6cea1256ce
commit
b56ac4164a
@ -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.
|
||||
|
@ -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';
|
||||
|
@ -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) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
var _ = require('underscore')._,
|
||||
uuid = require('node-uuid');
|
||||
uuid = require('node-uuid'),
|
||||
databank = require('databank'),
|
||||
AlreadyExistsError = databank.AlreadyExistsError,
|
||||
NoSuchThingError = databank.NoSuchThingError,
|
||||
|
Loading…
Reference in New Issue
Block a user