forked from GitHub/dbot
change spelling correction order in command ~
This commit is contained in:
parent
23bd691927
commit
dfb17dc107
44
run.js
44
run.js
@ -114,30 +114,28 @@ DBot.prototype.reloadModules = function() {
|
|||||||
} else {
|
} else {
|
||||||
var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
|
var q = data.message.valMatch(/^~([\d\w\s-]*)/, 2);
|
||||||
if(q) {
|
if(q) {
|
||||||
// See if it's similar to anything
|
if(this.db.bans['*'].include(data.user)) {
|
||||||
var winnerDistance = Infinity;
|
this.say(data.channel, data.user +
|
||||||
var winner = false;
|
' is banned from using this command. Commence incineration.');
|
||||||
for(var commandName in this.commands) {
|
} else {
|
||||||
var distance = String.prototype.distance(params[0], commandName);
|
q[1] = q[1].trim();
|
||||||
if(distance < winnerDistance) {
|
key = this.cleanNick(q[1])
|
||||||
winner = commandName;
|
if(this.db.quoteArrs.hasOwnProperty(key)) {
|
||||||
winnerDistance = distance;
|
this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(winnerDistance < 3) {
|
|
||||||
this.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!');
|
|
||||||
} else { // See if there's anything in quotes
|
|
||||||
if(this.db.bans['*'].include(data.user)) {
|
|
||||||
this.say(data.channel, data.user +
|
|
||||||
' is banned from using this command. Commence incineration.');
|
|
||||||
} else {
|
} else {
|
||||||
q[1] = q[1].trim();
|
// See if it's similar to anything
|
||||||
key = this.cleanNick(q[1])
|
var winnerDistance = Infinity;
|
||||||
if(this.db.quoteArrs.hasOwnProperty(key)) {
|
var winner = false;
|
||||||
this.say(data.channel, q[1] + ': ' + this.db.quoteArrs[key].random());
|
for(var commandName in this.commands) {
|
||||||
} else {
|
var distance = String.prototype.distance(params[0], commandName);
|
||||||
this.say(data.channel, 'Nobody loves ' + q[1]);
|
if(distance < winnerDistance) {
|
||||||
|
winner = commandName;
|
||||||
|
winnerDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(winnerDistance < 3) {
|
||||||
|
this.say(data.channel, 'Did you mean ' + winner + '? Learn to type, hippie!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user