3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-18 00:22:35 +01:00

command similar check

This commit is contained in:
Luke Slater 2012-02-15 20:29:37 +00:00
parent d98c1657dc
commit 84558f13d5

15
run.js
View File

@ -108,6 +108,20 @@ DBot.prototype.reloadModules = function() {
this.save();
}
} else {
// See if it's similar to anything
var winnerDistance = Infinity;
var winner = false;
for(var commandName in dbot.commands) {
var distance = String.prototype.distance(params[0], commandName);
if(distance < winnerDistance) {
winner = commandName;
winnerDistance = distance;
}
}
if(winnerDistance < 3) {
dbot.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!');
} else { // See if there's anything in quotes
var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
if(q) {
if(this.db.bans['*'].include(data.user)) {
@ -124,6 +138,7 @@ DBot.prototype.reloadModules = function() {
}
}
}
}
}.bind(this));
};