From 765eca33ac35568caa92c5559cd1d20d0ad7315b Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 28 Nov 2009 05:03:32 -0600 Subject: factor out broadcasting messages a bit --- lib/Crawl/Bot.pm | 9 +++++++++ lib/Crawl/Bot/Mantis.pm | 7 ++----- lib/Crawl/Bot/Wiki.pm | 9 +++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Crawl/Bot.pm b/lib/Crawl/Bot.pm index 47738fb..b6d956e 100644 --- a/lib/Crawl/Bot.pm +++ b/lib/Crawl/Bot.pm @@ -68,4 +68,13 @@ sub tick { return $self->update_time; } +sub say_all { + my $self = shift; + my ($message) = @_; + $self->say( + channel => $_, + body => $message, + ) for $self->channels; +} + 1; diff --git a/lib/Crawl/Bot/Mantis.pm b/lib/Crawl/Bot/Mantis.pm index e3c9c44..8f4b937 100644 --- a/lib/Crawl/Bot/Mantis.pm +++ b/lib/Crawl/Bot/Mantis.pm @@ -10,7 +10,7 @@ has bot => ( isa => 'Crawl::Bot', required => 1, weak_ref => 1, - handles => [qw(say channels data_dir)], + handles => [qw(say_all data_dir)], ); has rss_feed => ( @@ -101,10 +101,7 @@ sub tick { (my $title = $issue->title) =~ s/\d+: //; my $link = $issue->link; (my $user = $issue->creator) =~ s/ <.*?>$//; - $self->say( - channel => $_, - body => "$title ($link) by $user", - ) for $self->channels; + $self->say_all("$title ($link) by $user"); $self->add_issue($id); }); $self->save_cache; diff --git a/lib/Crawl/Bot/Wiki.pm b/lib/Crawl/Bot/Wiki.pm index dea004b..bffc925 100644 --- a/lib/Crawl/Bot/Wiki.pm +++ b/lib/Crawl/Bot/Wiki.pm @@ -8,7 +8,7 @@ has bot => ( isa => 'Crawl::Bot', required => 1, weak_ref => 1, - handles => [qw(say channels)], + handles => [qw(say_all)], ); has xmlrpc_location => ( @@ -49,11 +49,8 @@ sub tick { if ($page =~ /(===?=?=?=?) (.*) \1/) { $name = $2; } - $self->say( - channel => $_, - body => "$change->{author} created page $name at " - . $self->wiki_base . "$change->{name}", - ) for $self->channels; + $self->say_all("$change->{author} created page $name at " + . $self->wiki_base . "$change->{name}"); } } -- cgit v1.2.3-54-g00ecf