From 3291586d1818dd52c00c7a0014273fce5b057f8a Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Fri, 26 Aug 2011 12:46:12 +0100 Subject: [PATCH] getajob and youare use valMatch and chanceIn --- modules/getajob.js | 3 +-- modules/youare.js | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/getajob.js b/modules/getajob.js index 0b3d282..7a6d052 100644 --- a/modules/getajob.js +++ b/modules/getajob.js @@ -3,8 +3,7 @@ var getAJob = function(dbot) { return { 'listener': function(data) { - var num = Math.floor(Math.random()*101); - if(num == 50) { + if(Number.prototype.chanceIn(1, 50)) { dbot.say(data.channel, data.user + ': Get a job!'); } }, diff --git a/modules/youare.js b/modules/youare.js index 607c5e2..b033e6b 100644 --- a/modules/youare.js +++ b/modules/youare.js @@ -3,10 +3,10 @@ var youAre = function(dbot) { return { 'listener': function(data) { - var key = data.message.match(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/); + var key = data.message.valMatch(/(\bis\b|\bare\b)\s+([\w\s\d]*?)(\s+)?(,|\.|\band\b|$)/, 5); - if(key && Number.prototype.chanceIn(1, 3)) { - dbot.say(data.channel, data.user + ': You\'re ' + key[2]); + if(key && key[2] != "" && Number.prototype.chanceIn(1, 3)) { + dbot.say(data.channel, data.user + ': You\'re ' + key[2] + '.'); } },