diff --git a/plugins/8ball.pm b/plugins/8ball.pm index f10ee88..a7c88a9 100644 --- a/plugins/8ball.pm +++ b/plugins/8ball.pm @@ -1,7 +1,27 @@ sub { my( $said ) = @_; - my @a=("Outlook good", + my $ors =()= $said->{body}=~m/\bor\b/g; + my $commas =()= $said->{body}=~m/,(?=.*\bor\b)/g; + + my @a; + + if ($ors == 1) + { + if ($commas > 0) + { + @a = split(/\bor\b/, $said->{body}); + } + else + { + @a = split(/(?:\bor\b|\s*,\s*)/, $said->{body}); + } + + s/^\s*//, s/\s*$// for @a; #trim them up + } + else + { + @a=("Outlook good", "Outlook not so good", "My reply is no", "Don't count on it", @@ -9,17 +29,19 @@ sub { "Ask again later", "Most likely", "Cannot predict now", -"Yes","Yes, definitely", + "Yes", + "Yes, definitely", "Better not tell you now", -"It is certain", -"Very doubtful", -"It is decidedly so", -"Concentrate and ask again", -"Signs point to yes", -"My sources say no", -"Without a doubt", -"Reply hazy, try again", -"As I see it, yes"); + "It is certain", + "Very doubtful", + "It is decidedly so", + "Concentrate and ask again", + "Signs point to yes", + "My sources say no", + "Without a doubt", + "Reply hazy, try again", + "As I see it, yes"); + } print $a[rand@a]."." }