From 2ccf5107e0d93c9bcf92a1232e5a83329b90f1b4 Mon Sep 17 00:00:00 2001 From: Neil Moore Date: Mon, 2 Jan 2012 22:38:21 -0500 Subject: Send responses to the correct channel/user, not everyone. --- lib/Crawl/Bot/Plugin.pm | 2 +- lib/Crawl/Bot/Plugin/Commit.pm | 10 +++++++--- lib/Crawl/Bot/Plugin/Mantis.pm | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/Crawl/Bot/Plugin.pm b/lib/Crawl/Bot/Plugin.pm index 185c209..6ef7c80 100644 --- a/lib/Crawl/Bot/Plugin.pm +++ b/lib/Crawl/Bot/Plugin.pm @@ -6,7 +6,7 @@ has bot => ( isa => 'Crawl::Bot', required => 1, weak_ref => 1, - handles => [qw(say_all data_dir)], + handles => [qw(say say_all data_dir)], ); # not all plugins require implementations here diff --git a/lib/Crawl/Bot/Plugin/Commit.pm b/lib/Crawl/Bot/Plugin/Commit.pm index 7f51848..70b7278 100644 --- a/lib/Crawl/Bot/Plugin/Commit.pm +++ b/lib/Crawl/Bot/Plugin/Commit.pm @@ -45,6 +45,8 @@ sub said { my $self = shift; my ($args) = @_; + my @keys = (who => $args->{who}, channel => $args->{channel}, "body"); + if ($args->{body} =~ /^%git(?:\s+(.*))?$/) { my $rev = $1; $rev = "HEAD" unless $rev; @@ -53,11 +55,13 @@ sub said { my $abbr = substr($commit->{hash}, 0, 12); my $pl = ($commit->{nfiles} == 1 ? "" : "s"); - $self->say_all("$commit->{author} * r$abbr: $commit->{subject} " - . "($commit->{date}, $commit->{nfiles} file$pl, $commit->{nins}+ $commit->{ndel}-)"); + $self->say(@keys, "$commit->{author} * r$abbr: $commit->{subject} " + . "($commit->{date}, $commit->{nfiles} file$pl, " + . "$commit->{nins}+ $commit->{ndel}-)" + ); } else { my $ev = $? >> 8; - $self->say_all("Could not find commit $rev (git returned $ev)"); + $self->say(@keys, "Could not find commit $rev (git returned $ev)"); } } } diff --git a/lib/Crawl/Bot/Plugin/Mantis.pm b/lib/Crawl/Bot/Plugin/Mantis.pm index e6ff7be..5498bc9 100644 --- a/lib/Crawl/Bot/Plugin/Mantis.pm +++ b/lib/Crawl/Bot/Plugin/Mantis.pm @@ -17,9 +17,11 @@ sub item_to_id { sub said { my $self = shift; my ($args) = @_; + + my @keys = (who => $args->{who}, channel => $args->{channel}, "body"); if ($args->{body} =~ /^%bug (\d+)$/) { - $self->say_all("https://crawl.develz.org/mantis/view.php?id=$1"); + $self->say(@keys, "https://crawl.develz.org/mantis/view.php?id=$1"); } } -- cgit v1.2.3-54-g00ecf