3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 11:42:36 +01:00

Glorious regex victory!

This commit is contained in:
Luke Slater 2011-08-25 20:34:39 +01:00
parent 6072cb0e8b
commit eeb59bae4b

View File

@ -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]);
}
},