From 68d8c75b50e880e4e20a06f7801f488c4e01f2df Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Wed, 26 Oct 2011 17:24:19 +0100 Subject: [PATCH] var not int jesus christ java --- modules/spelling.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); }