diff --git a/modules/spelling.js b/modules/spelling.js index abfdf59..a020d4a 100644 --- a/modules/spelling.js +++ b/modules/spelling.js @@ -6,18 +6,21 @@ var spelling = function(dbot) { 'listener': function(data, params) { var q = data.message.valMatch(/^\*([\d\w\s]*)/, 2); if(q) { + dbot.say(data.channel, 'got q'); var correction = q[1]; var candidates = last[data.channel][data.user].split(' '); var winner = false; + var winnerDistance = 99999999; //urgh fix later for(var i=0;i winner) { + if(distance < winner) { winner = candidates[i]; + winnerDistance = distance; } } - - if(winner < 3) { + console.log(winner + ' ' + winnerDistance); + if(winnerDistance < 3) { var fix = data.message.replace(winner, correction); dbot.say(data.channel, data.user + ':' + fix); }