mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-09 13:39:34 +01:00
42 lines
1.1 KiB
Perl
42 lines
1.1 KiB
Perl
# File: Plugin.pm
|
|
#
|
|
# Purpose: Base class for PBot plugins.
|
|
|
|
# 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;
|
|
|
|
use PBot::Imports;
|
|
|
|
sub new {
|
|
my ($class, %args) = @_;
|
|
|
|
my $self = bless {}, $class;
|
|
|
|
if (not exists $args{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} = $args{pbot};
|
|
$self->initialize(%args);
|
|
return $self;
|
|
}
|
|
|
|
sub initialize {
|
|
my ($package, $filename, $line) = caller(0);
|
|
my (undef, undef, undef, $subroutine) = caller(1);
|
|
Carp::croak("Missing initialize subroutine in $subroutine at $filename:$line");
|
|
}
|
|
|
|
sub unload {
|
|
my ($package, $filename, $line) = caller(0);
|
|
my (undef, undef, undef, $subroutine) = caller(1);
|
|
Carp::croak("Missing unload subroutine in $subroutine at $filename:$line");
|
|
}
|
|
|
|
1;
|