diff options
author | Neil Moore <neil@s-z.org> | 2012-09-16 14:48:54 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2012-09-16 14:48:54 -0500 |
commit | 036fce364572a97ad17e9635ce3f8a6642ee8c4a (patch) | |
tree | 9c78c3e3eb36f61b42d3d9b7a9ceb2cc09407041 | |
parent | 4854a7c6db0072ba59bc8b6d2454b7bc34d23792 (diff) | |
download | crawlbot-036fce364572a97ad17e9635ce3f8a6642ee8c4a.tar.gz crawlbot-036fce364572a97ad17e9635ce3f8a6642ee8c4a.zip |
Support "%0.10?monster" to query a particular version.
-rw-r--r-- | lib/Crawl/Bot/Plugin/Monster.pm | 8 |
1 files 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; |