3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 03:33:07 +01:00

regex better

This commit is contained in:
Luke Slater 2011-08-25 14:19:17 +01:00
parent a9f2d7fe51
commit e62bacfa98

View File

@ -4,13 +4,9 @@ var youAre = function(dbot) {
return {
'listener': function(data) {
var num = Math.floor(Math.random()*11);
var key = data.message.match(/ is|are ([\d\w\s']*),?\.?/);
var key = data.message.match(/ is|are ([\d\w\s']*),?\.?and?/);
if(num == 1 && key != undefined) {
if(key[1].indexOf('and') !== -1) {
key[1] = key[1].split('and')[0];
} // TODO: fix the regex to do this. i hate regex
dbot.say(data.channel, data.user + ': You\'re ' + key[1]);
}
},