3
0
mirror of https://github.com/pragma-/pbot.git synced 2025-02-10 19:40:56 +01:00
pbot/lib/PBot/Plugin/Base.pm

38 lines
1022 B
Perl
Raw Normal View History

2021-07-13 19:45:56 -07:00
# File: Base.pm
2021-06-18 21:23:34 -07:00
#
# Purpose: Base class for PBot plugins.
# SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <pragma78@gmail.com>
2021-07-10 15:00:22 -07:00
# SPDX-License-Identifier: MIT
2020-02-08 19:48:05 -08:00
2021-07-13 19:45:56 -07:00
package PBot::Plugin::Base;
2020-02-08 19:48:05 -08:00
2021-06-18 21:23:34 -07:00
use PBot::Imports;
2020-02-08 19:48:05 -08:00
sub new($class, %args) {
2021-06-18 21:23:34 -07:00
if (not exists $args{pbot}) {
2020-02-15 14:38:32 -08:00
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");
2020-02-15 14:38:32 -08:00
}
my $self = bless {}, $class;
2021-06-18 21:23:34 -07:00
$self->{pbot} = $args{pbot};
$self->initialize(%args);
2020-02-15 14:38:32 -08:00
return $self;
2020-02-08 19:48:05 -08:00
}
sub initialize {
2020-02-15 14:38:32 -08: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-08 19:48:05 -08:00
}
sub unload {
2020-02-15 14:38:32 -08: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-08 19:48:05 -08:00
}
1;