-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathBase.pm
37 lines (29 loc) · 1022 Bytes
/
Base.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File: Base.pm
#
# Purpose: Base class for PBot plugins.
# SPDX-FileCopyrightText: 2021-2023 Pragmatic Software <[email protected]>
# SPDX-License-Identifier: MIT
package PBot::Plugin::Base;
use PBot::Imports;
sub new($class, %args) {
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");
}
my $self = bless {}, $class;
$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;