3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

var not int jesus christ java

This commit is contained in:
Luke Slater 2011-10-26 17:24:19 +01:00
parent c7b2b5b139
commit 68d8c75b50

View File

@ -6,18 +6,21 @@ var spelling = function(dbot) {
'listener': function(data, params) { 'listener': function(data, params) {
var q = data.message.valMatch(/^\*([\d\w\s]*)/, 2); var q = data.message.valMatch(/^\*([\d\w\s]*)/, 2);
if(q) { if(q) {
dbot.say(data.channel, 'got q');
var correction = q[1]; var correction = q[1];
var candidates = last[data.channel][data.user].split(' '); var candidates = last[data.channel][data.user].split(' ');
var winner = false; var winner = false;
var winnerDistance = 99999999; //urgh fix later
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 > winner) { if(distance < winner) {
winner = candidates[i]; winner = candidates[i];
winnerDistance = distance;
} }
} }
console.log(winner + ' ' + winnerDistance);
if(winner < 3) { if(winnerDistance < 3) {
var fix = data.message.replace(winner, correction); var fix = data.message.replace(winner, correction);
dbot.say(data.channel, data.user + ':' + fix); dbot.say(data.channel, data.user + ':' + fix);
} }