mirror of
https://github.com/reality/dbot.git
synced 2024-11-27 22:39:26 +01:00
do that properly
This commit is contained in:
parent
007540bead
commit
c2d2e0342e
@ -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)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user