3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 19:52:36 +01:00

fix the quote/command correct order thing

This commit is contained in:
reality 2013-08-17 18:13:38 +00:00
parent 52d38aa1e7
commit 6fb7c8e91f
3 changed files with 37 additions and 32 deletions

View File

@ -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;

View File

@ -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));
},

View File

@ -3,6 +3,5 @@
"dependencies": [ "users", "event" ],
"rmLimit": 10,
"ignorable": true,
"quotesOnJoin": false,
"udFallback": false
"quotesOnJoin": false
}