diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-11-28 05:03:32 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-11-28 05:03:32 -0600 |
commit | 765eca33ac35568caa92c5559cd1d20d0ad7315b (patch) | |
tree | d20657a5cc9b6727c70d9a6bacb2438469b25d42 /lib | |
parent | 0855b8d28197bb7f92594526fe5f3277d34f9e6d (diff) | |
download | crawlbot-765eca33ac35568caa92c5559cd1d20d0ad7315b.tar.gz crawlbot-765eca33ac35568caa92c5559cd1d20d0ad7315b.zip |
factor out broadcasting messages a bit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Crawl/Bot.pm | 9 | ||||
-rw-r--r-- | lib/Crawl/Bot/Mantis.pm | 7 | ||||
-rw-r--r-- | 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}"); } } |