From 119d0b306eee5a7689cd7beb9179eda19bbbbd0b Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Fri, 4 Nov 2011 16:34:36 +0000 Subject: [PATCH] correct other peoples spelling --- modules/spelling.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/spelling.js b/modules/spelling.js index d96b82d..b564b2f 100644 --- a/modules/spelling.js +++ b/modules/spelling.js @@ -5,6 +5,7 @@ var spelling = function(dbot) { return { 'listener': function(data, params) { var q = data.message.valMatch(/^\*\*?([\d\w\s]*)/, 2); + var otherQ = data.message.valMatch(/^([\d\w\s]*): \*\*?([\d\w\s]*)/); if(q) { var correction = q[1]; var candidates = last[data.channel][data.user].split(' '); @@ -26,6 +27,29 @@ var spelling = function(dbot) { dbot.say(data.channel, data.user + ' meant: ' + fix); } } + } else if(otherQ) { + if(last[data.channel].hasOwnProperty([otherQ[1]])) { + var correction = otherQ[2]; + var candidates = last[data.channel][otherQ[1]].split(' '); + var winner = false; + var winnerDistance = 99999999; //urgh fix later + + for(var i=0;i