From 6ad7390aa31303ba12b27435e84669e5910db946 Mon Sep 17 00:00:00 2001 From: Neil Moore Date: Wed, 14 Mar 2012 09:34:20 -0500 Subject: Support %? (monster-stable) in addition to %? (monster-trunk). --- lib/Crawl/Bot/Plugin/Monster.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/Crawl/Bot/Plugin/Monster.pm b/lib/Crawl/Bot/Plugin/Monster.pm index ee6c971..0c22a25 100644 --- a/lib/Crawl/Bot/Plugin/Monster.pm +++ b/lib/Crawl/Bot/Plugin/Monster.pm @@ -12,12 +12,13 @@ sub said { my ($args) = @_; my @keys = (who => $args->{who}, channel => $args->{channel}, "body"); - if ($args->{body} =~ /^%\?\? *(.*)/) { - my $resp = $self->get_monster_info($1); + if ($args->{body} =~ /^%(\?\??) *(.*)/) { + my $branch = ($1 eq "??") ? "trunk" : "stable"; + my $resp = $self->get_monster_info($2, $branch); if ($resp) { $self->say(@keys, $resp); } else { - $self->say(@keys, "Error calling monster-trunk: $!") + $self->say(@keys, "Error calling monster-$branch: $!") } } } @@ -25,8 +26,11 @@ sub said { sub get_monster_info { my $self = shift; my $monster = shift; + my $branch = shift; - CORE::open(F, "-|", "bin/monster-trunk", $monster) or return undef; + return "Error: Bad branch $branch\n" unless $branch =~ /^(trunk|stable)$/; + + CORE::open(F, "-|", "bin/monster-$branch", $monster) or return undef; local $/ = undef; my $resp = ; CORE::close(F); -- cgit v1.2.3-54-g00ecf