From eeb59bae4b306a46f67535fabd156730d3eb28d0 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Thu, 25 Aug 2011 20:34:39 +0100 Subject: [PATCH] Glorious regex victory! --- modules/youare.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/youare.js b/modules/youare.js index ab4d228..607c5e2 100644 --- a/modules/youare.js +++ b/modules/youare.js @@ -3,13 +3,9 @@ var youAre = function(dbot) { return { 'listener': function(data) { - var key = data.message.valMatch(/(is|are) ([\d\w\s']*)/, 3); - - if(Number.prototype.chanceIn(1, 3) && key) { - if(key[2].indexOf('and') !== -1) { - key[2] = key[2].split('and')[0]; - } // TODO: fix the regex to do this. i hate regex + var key = data.message.match(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/); + if(key && Number.prototype.chanceIn(1, 3)) { dbot.say(data.channel, data.user + ': You\'re ' + key[2]); } },