summaryrefslogtreecommitdiffstats
path: root/lib/Crawl/Bot.pm
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-11-28 15:40:24 -0600
committerJesse Luehrs <doy@tozt.net>2009-11-28 15:40:46 -0600
commit29c0d80c40d44eb77e3320c5c883357eb6b6f604 (patch)
treef20d05b0defcb969cb481240db4b454a7a5b95dd /lib/Crawl/Bot.pm
parent765eca33ac35568caa92c5559cd1d20d0ad7315b (diff)
downloadcrawlbot-29c0d80c40d44eb77e3320c5c883357eb6b6f604.tar.gz
crawlbot-29c0d80c40d44eb77e3320c5c883357eb6b6f604.zip
make plugins a bit more flexible
Diffstat (limited to 'lib/Crawl/Bot.pm')
-rw-r--r--lib/Crawl/Bot.pm31
1 files changed, 9 insertions, 22 deletions
diff --git a/lib/Crawl/Bot.pm b/lib/Crawl/Bot.pm
index b6d956e..7d34403 100644
--- a/lib/Crawl/Bot.pm
+++ b/lib/Crawl/Bot.pm
@@ -4,6 +4,10 @@ use MooseX::NonMoose;
extends 'Bot::BasicBot';
use File::Path;
+use Module::Pluggable (
+ instantiate => 'new',
+ sub_name => 'create_plugins',
+);
has [qw(username name)] => (
# don't need (or want) accessors, just want to initialize the hash slot
@@ -26,33 +30,17 @@ has update_time => (
default => 300,
);
-has mantis => (
- is => 'ro',
- isa => 'Crawl::Bot::Mantis',
- lazy => 1,
- default => sub {
- my $self = shift;
- require Crawl::Bot::Mantis;
- Crawl::Bot::Mantis->new(bot => $self);
- },
-);
-
-has wiki => (
+has plugins => (
is => 'ro',
- isa => 'Crawl::Bot::Wiki',
+ isa => 'ArrayRef[Crawl::Bot::Plugin]',
lazy => 1,
- default => sub {
- my $self = shift;
- require Crawl::Bot::Wiki;
- Crawl::Bot::Wiki->new(bot => $self);
- },
+ default => sub { [__PACKAGE__->create_plugins(bot => shift)] },
);
sub BUILD {
my $self = shift;
File::Path::mkpath($self->data_dir);
- $self->mantis;
- $self->wiki;
+ $self->plugins;
}
before say => sub {
@@ -63,8 +51,7 @@ before say => sub {
sub tick {
my $self = shift;
- $self->mantis->tick;
- $self->wiki->tick;
+ $_->tick for @{ $self->plugins };
return $self->update_time;
}