diff options
author | Neil Moore <neil@s-z.org> | 2012-03-14 09:34:20 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2012-03-14 09:34:20 -0500 |
commit | 6ad7390aa31303ba12b27435e84669e5910db946 (patch) | |
tree | ff33d6666525c8040ebfe6d9c094fd8dee1af4fa | |
parent | 332c3f7fa191779bbc86f01269c45226e8925dcf (diff) | |
download | crawlbot-6ad7390aa31303ba12b27435e84669e5910db946.tar.gz crawlbot-6ad7390aa31303ba12b27435e84669e5910db946.zip |
Support %? (monster-stable) in addition to %? (monster-trunk).
-rw-r--r-- | lib/Crawl/Bot/Plugin/Monster.pm | 12 |
1 files changed, 8 insertions, 4 deletions
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 = <F>; CORE::close(F); |