do that properly

This commit is contained in:
Luke Slater 2012-01-09 14:53:48 +00:00
parent 007540bead
commit c2d2e0342e

View File

@ -10,14 +10,14 @@ var spelling = function(dbot) {
for(var i=0;i<candidates.length;i++) { for(var i=0;i<candidates.length;i++) {
var distance = String.prototype.distance(correction, candidates[i]); var distance = String.prototype.distance(correction, candidates[i]);
if(distance < winnerDistance) { if(distance < winnerDistance) {
winner = candidates[i]; winner = i;
winnerDistance = distance; winnerDistance = distance;
} }
} }
if(winnerDistance < 7) { if(winnerDistance < 7) {
if(winner !== correction) { if(winner !== correction) {
candidates[i] = correction; candidates[winner] = correction;
var fix = candidates.join(' '); var fix = candidates.join(' ');
last[data.channel][candidate] = fix; last[data.channel][candidate] = fix;
if (/^.ACTION/.test(fix)) { if (/^.ACTION/.test(fix)) {