Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Modules are now loaded on demand, moved to plugins/

  • Loading branch information...
commit eafa3d36983a7822f134fd8bc5b3843bad468090 1 parent c32abde
@tadzik authored
View
17 a8bot.pm
@@ -3,7 +3,6 @@ use feature ':5.10';
use a8bot::Plugin;
use Moose;
use MooseX::NonMoose;
-use Module::Pluggable sub_name => 'pluggable', require => 1;
use AnyEvent;
use AnyEvent::IRC::Client;
@@ -71,13 +70,6 @@ has 'wantconnection' => (
sub BUILD {
my $self = shift;
- foreach my $plugin ($self->pluggable) {
- my $plug = a8bot::Plugin->new(
- bot => $self,
- plugin => $plugin,
- );
- $self->add_plugin($plug);
- }
$self->reg_cb(
disconnect => sub {
if ($self->wantconnection) {
@@ -118,6 +110,15 @@ sub BUILD {
# exit 0;
#}
+sub load_plugin {
+ my ($self, $plugin) = @_;
+ my $plug = a8bot::Plugin->new(
+ bot => $self,
+ plugin => $plugin,
+ );
+ $self->add_plugin($plug);
+}
+
sub log {
my ($self, @args) = @_;
if ($self->verbose) {
View
2  a8bot/Plugin.pm
@@ -1,5 +1,6 @@
package a8bot::Plugin;
use feature ':5.10';
+use lib 'plugins';
use Moose;
has 'bot' => (
@@ -47,6 +48,7 @@ has '_registered' => (
sub BUILD {
my $self = shift;
+ require $self->plugin . '.pm';
my $events = $self->plugin->init;
$self->_disconnect($events->{disconnect} // sub {});
$self->_publicmsg($events->{publicmsg} // sub {});
View
2  app.pl
@@ -7,6 +7,8 @@
verbose => 1,
);
+$bot->load_plugin('Ping');
+
#$SIG{INT} = sub { $bot->cleanup };
#$SIG{TERM} = sub { $bot->cleanup };
View
2  a8bot/Plugin/Odzywki.pm → plugins/Odzywki.pm
@@ -1,4 +1,4 @@
-package a8bot::Plugin::Odzywki;
+package Odzywki;
use Tie::RegexpHash;
tie my %db, 'Tie::RegexpHash';
View
2  a8bot/Plugin/Ping.pm → plugins/Ping.pm
@@ -1,4 +1,4 @@
-package a8bot::Plugin::Ping;
+package Ping;
# example plugin for a8bot
# a plugin MUST have an 'init' subroutine, returning a hash with keys
View
2  a8bot/Plugin/Powiedz.pm → plugins/Powiedz.pm
@@ -1,4 +1,4 @@
-package a8bot::Plugin::Powiedz;
+package Powiedz;
use strict;
use warnings;
use Hash::MultiValue;
View
2  a8bot/Plugin/Seen.pm → plugins/Seen.pm
@@ -1,4 +1,4 @@
-package a8bot::Plugin::Seen;
+package Seen;
use POSIX 'strftime';
my %log;
View
2  a8bot/Plugin/WebTitle.pm → plugins/WebTitle.pm
@@ -1,4 +1,4 @@
-package a8bot::Plugin::WebTitle;
+package WebTitle;
use LWP::Simple qw /get $ua/;
sub init {
Please sign in to comment.
Something went wrong with that request. Please try again.