From 768b88d00561eed8059c0c637a56a6fd10b12c5c Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Thu, 25 Aug 2011 14:14:08 +0100 Subject: [PATCH] youare --- modules/youare.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 modules/youare.js diff --git a/modules/youare.js b/modules/youare.js new file mode 100644 index 0000000..7d06685 --- /dev/null +++ b/modules/youare.js @@ -0,0 +1,22 @@ +var youAre = function(dbot) { + var dbot = dbot; + + return { + 'listener': function(data) { + var num = Math.floor(Math.random()*11); + var key = data.message.match(/ is|are ([\d\w\s,'-]*)\.?/); + if(key[1].indexOf('and') !== -1) { + key[1] = key[1].split('and')[0]; + } // TODO: fix the regex to do this. i hate regex + if(num == 1 && key != undefined) { + dbot.say(data.channel, data.user + ': You\'re ' + key[1]); + } + }, + + 'on': 'PRIVMSG' + }; +}; + +exports.fetch = function(dbot) { + return youAre(dbot); +};