forked from GitHub/dbot
fix the quote/command correct order thing
This commit is contained in:
parent
52d38aa1e7
commit
6fb7c8e91f
@ -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;
|
||||
|
@ -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));
|
||||
},
|
||||
|
@ -3,6 +3,5 @@
|
||||
"dependencies": [ "users", "event" ],
|
||||
"rmLimit": 10,
|
||||
"ignorable": true,
|
||||
"quotesOnJoin": false,
|
||||
"udFallback": false
|
||||
"quotesOnJoin": false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user