3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00
pbot/Plugins/Plugin.pm

40 lines
1.1 KiB
Perl
Raw Normal View History

2020-02-09 04:48:05 +01:00
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
package Plugins::Plugin;
# purpose: base class for PBot plugins
use warnings; use strict;
sub new {
2020-02-15 23:38:32 +01:00
my ($proto, %conf) = @_;
my $class = ref($proto) || $proto;
my $self = bless {}, $class;
if (not exists $conf{pbot}) {
my ($package, $filename, $line) = caller(0);
my (undef, undef, undef, $subroutine) = caller(1);
Carp::croak("Missing pbot reference to " . $class . ", created by $subroutine at $filename:$line");
}
$self->{pbot} = $conf{pbot};
$self->initialize(%conf);
return $self;
2020-02-09 04:48:05 +01:00
}
sub initialize {
2020-02-15 23:38:32 +01:00
my ($package, $filename, $line) = caller(0);
my (undef, undef, undef, $subroutine) = caller(1);
Carp::croak("Missing initialize subroutine in $subroutine at $filename:$line");
2020-02-09 04:48:05 +01:00
}
sub unload {
2020-02-15 23:38:32 +01:00
my ($package, $filename, $line) = caller(0);
my (undef, undef, undef, $subroutine) = caller(1);
Carp::croak("Missing unload subroutine in $subroutine at $filename:$line");
2020-02-09 04:48:05 +01:00
}
1;