From 036fce364572a97ad17e9635ce3f8a6642ee8c4a Mon Sep 17 00:00:00 2001 From: Neil Moore Date: Sun, 16 Sep 2012 14:48:54 -0500 Subject: Support "%0.10?monster" to query a particular version. --- lib/Crawl/Bot/Plugin/Monster.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Crawl/Bot/Plugin/Monster.pm b/lib/Crawl/Bot/Plugin/Monster.pm index 445b16b..9918b8d 100644 --- a/lib/Crawl/Bot/Plugin/Monster.pm +++ b/lib/Crawl/Bot/Plugin/Monster.pm @@ -12,8 +12,8 @@ sub said { my ($args) = @_; my @keys = (who => $args->{who}, channel => $args->{channel}, "body"); - if ($args->{body} =~ /^%(\?\??) *(.*)/) { - my $branch = ($1 eq "??") ? "trunk" : "stable"; + if ($args->{body} =~ /^%(\?|0\.\d+|)\? *([^?].*)/) { + my $branch = ($1 eq "?") ? "trunk" : ($1 || "stable"); my $resp = $self->get_monster_info($2, $branch); if ($resp) { $self->say(@keys, $resp); @@ -28,12 +28,12 @@ sub get_monster_info { my $monster = shift; my $branch = shift; - return "Error: Bad branch $branch\n" unless $branch =~ /^(trunk|stable)$/; + return "Error: Bad branch $branch\n" unless $branch =~ /^(trunk|stable|0.\d+)$/; CORE::open(F, "-|") || do { # Collect stderr too close STDERR; open STDERR, '>&STDOUT'; - exec "bin/monster-$branch", $monster or die "could not execute monster-$branch: $!"; + exec "bin/monster-$branch", $monster or return "Could not execute monster-$branch: $!"; }; binmode F, ":utf8"; local $/ = undef; -- cgit v1.2.3