mirror of
https://github.com/reality/dbot.git
synced 2024-12-18 08:32:42 +01:00
command similar check
This commit is contained in:
parent
d98c1657dc
commit
84558f13d5
15
run.js
15
run.js
@ -108,6 +108,20 @@ DBot.prototype.reloadModules = function() {
|
|||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
|
||||||
if(q) {
|
if(q) {
|
||||||
if(this.db.bans['*'].include(data.user)) {
|
if(this.db.bans['*'].include(data.user)) {
|
||||||
@ -124,6 +138,7 @@ DBot.prototype.reloadModules = function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user