From 07156b2eb3e50dabdd4cca127c9de67005bcedd7 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 18 Jul 2017 14:32:42 +0000 Subject: [PATCH] this --- modules/command/command.js | 84 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/modules/command/command.js b/modules/command/command.js index 459e5a2..03b4dde 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -17,51 +17,12 @@ var command = function(dbot) { return; } commandName = commandName.substring(1); - if(!_.has(dbot.commands, commandName)) { - if(_.has(dbot.modules, 'quotes')) { - var key = event.message.substring(1); - dbot.api.quotes.getInterpolatedQuote(event.server, - event.channel.name, event.user, key, function(quote) { - if(quote) { - event.reply(key + ': ' + quote); - } else if(_.has(dbot.modules, 'spelling')) { - var commands = _.keys(dbot.commands), - winner = false, - closestMatch = Infinity; - - _.each(commands, function(command) { - var distance = dbot.api.spelling.distance(commandName, command); - if(distance < closestMatch) { - closestMatch = distance; - winner = command; - } - }); - - if(closestMatch < 1) { - event.reply(commandName + ' not found. Did you mean ' + winner + '?'); - return; - } else if(_.has(dbot.modules, 'quotes')) { - dbot.api.link.udLookup(key, function(word, definition) { - if(word) { - event.reply(key + '[UD]: ' + definition); - } else { - event.reply(dbot.t('category_not_found', { 'category': key })); - } - }); - } else { - return; - } - } - }); - return; - } else { - return; - } - } + this.api.hasAccess(event, commandName, function(hasAccess) { dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) { dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) { + if(isBanned) { if(this.config.banOutput && commandName != this.config.commandPrefix) { event.reply(dbot.t('command_ban', {'user': event.user})); @@ -71,6 +32,47 @@ var command = function(dbot) { event.reply(dbot.t('access_denied', { 'user': event.user })); } } else if(!isIgnoring && _.has(dbot.commands, commandName) && !dbot.commands[commandName].disabled) { + if(!_.has(dbot.commands, commandName)) { + if(_.has(dbot.modules, 'quotes')) { + var key = event.message.substring(1); + dbot.api.quotes.getInterpolatedQuote(event.server, + event.channel.name, event.user, key, function(quote) { + if(quote) { + event.reply(key + ': ' + quote); + } else if(_.has(dbot.modules, 'spelling')) { + var commands = _.keys(dbot.commands), + winner = false, + closestMatch = Infinity; + + _.each(commands, function(command) { + var distance = dbot.api.spelling.distance(commandName, command); + if(distance < closestMatch) { + closestMatch = distance; + winner = command; + } + }); + + if(closestMatch < 1) { + event.reply(commandName + ' not found. Did you mean ' + winner + '?'); + return; + } else if(_.has(dbot.modules, 'quotes')) { + dbot.api.link.udLookup(key, function(word, definition) { + if(word) { + event.reply(key + '[UD]: ' + definition); + } else { + event.reply(dbot.t('category_not_found', { 'category': key })); + } + }); + } else { + return; + } + } + }); + return; + } else { + return; + } + } if(this.api.applyRegex(commandName, event)) { try { cDomain.run(function() {