From 6fb7c8e91fb6a515fb4dc995eabd6744e0f3dbbb Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 17 Aug 2013 18:13:38 +0000 Subject: [PATCH] fix the quote/command correct order thing --- modules/command/command.js | 54 ++++++++++++++++++++++++-------------- modules/quotes/commands.js | 12 +-------- modules/quotes/config.json | 3 +-- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/modules/command/command.js b/modules/command/command.js index 47f22fe..e842a3c 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -16,28 +16,44 @@ var command = function(dbot) { return; } if(!_.has(dbot.commands, commandName)) { - if(_.has(dbot.modules, 'spelling')) { - var commands = _.keys(dbot.commands) - winner = false, - closestMatch = Infinity; + if(_.has(dbot.modules, 'quotes')) { + var key = event.message.substring(1); + dbot.api.quotes.getInterpolatedQuote(event.server, event.channel.name, 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; + _.each(commands, function(command) { + var distance = dbot.api.spelling.distance(commandName, command); + if(distance < closestMatch) { + closestMatch = distance; + winner = command; + } + }); + + if(closestMatch < 3) { + 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; + } - if(closestMatch < 3) { - event.reply(commandName + ' not found. Did you mean ' + winner + '?'); - return; - } else if(_.has(dbot.modules, 'quotes')) { - commandName = '~'; - } else { - return; - } - } else if(_.has(dbot.modules, 'quotes')) { + else if(_.has(dbot.modules, 'quotes')) { commandName = '~'; } else { return; diff --git a/modules/quotes/commands.js b/modules/quotes/commands.js index 97229ad..81d2043 100644 --- a/modules/quotes/commands.js +++ b/modules/quotes/commands.js @@ -38,17 +38,7 @@ var commands = function(dbot) { if(quote) { event.reply(key + ': ' + quote); } else { - if(this.config.udFallback === true && _.has(dbot.modules, 'link')) { - 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 { - event.reply(dbot.t('category_not_found', { 'category': key })); - } + event.reply(dbot.t('category_not_found', { 'category': key })); } }.bind(this)); }, diff --git a/modules/quotes/config.json b/modules/quotes/config.json index d0fbe4a..5b7e2e5 100644 --- a/modules/quotes/config.json +++ b/modules/quotes/config.json @@ -3,6 +3,5 @@ "dependencies": [ "users", "event" ], "rmLimit": 10, "ignorable": true, - "quotesOnJoin": false, - "udFallback": false + "quotesOnJoin": false }