mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-26 05:49:27 +01:00
Minor clean-up and polish
- add more comments to VERSION.pm - minor clean up of logging messages - minor refactoring - VERSION.pm will no longer be updated as its own distinct commit
This commit is contained in:
parent
837046a34b
commit
67d2dd5d95
@ -219,6 +219,8 @@ sub initialize {
|
||||
return;
|
||||
}
|
||||
);
|
||||
|
||||
$self->{logger}->log("PBot::Core initialized.\n");
|
||||
}
|
||||
|
||||
sub random_nick {
|
||||
|
@ -10,12 +10,15 @@ package PBot::Core::Class;
|
||||
|
||||
use PBot::Imports;
|
||||
|
||||
our $quiet = 0;
|
||||
my %import_opts;
|
||||
|
||||
sub import {
|
||||
my ($package, %opts) = @_;
|
||||
|
||||
$quiet = $opts{quiet};
|
||||
if (%opts) {
|
||||
# set import options for package
|
||||
$import_opts{$package} = \%opts;
|
||||
}
|
||||
}
|
||||
|
||||
sub new {
|
||||
@ -25,18 +28,24 @@ sub new {
|
||||
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");
|
||||
Carp::croak("Missing pbot reference to $class, created by $subroutine at $filename:$line");
|
||||
}
|
||||
|
||||
# create class instance
|
||||
my $self = bless { pbot => $args{pbot} }, $class;
|
||||
|
||||
$self->{pbot}->{logger}->log("Initializing $class\n") unless $quiet;
|
||||
# log class initialization unless quieted
|
||||
unless (exists $import_opts{$class} and $import_opts{$class}{quiet}) {
|
||||
$self->{pbot}->{logger}->log("Initializing $class\n")
|
||||
}
|
||||
|
||||
$self->initialize(%args);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub initialize {
|
||||
# ensure class has an initialize() subroutine
|
||||
my ($package, $filename, $line) = caller(0);
|
||||
my (undef, undef, undef, $subroutine) = caller(1);
|
||||
Carp::croak("Missing initialize subroutine in $subroutine at $filename:$line");
|
||||
|
@ -54,12 +54,10 @@ our %factoid_metadata = (
|
||||
sub initialize {
|
||||
my ($self, %conf) = @_;
|
||||
|
||||
my $filename = $conf{filename};
|
||||
|
||||
$self->{storage} = PBot::Core::Storage::DualIndexSQLiteObject->new(
|
||||
pbot => $self->{pbot},
|
||||
name => 'Factoids',
|
||||
filename => $filename,
|
||||
filename => $conf{filename},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -29,18 +29,20 @@ sub autoload {
|
||||
|
||||
my $data_dir = $self->{pbot}->{registry}->get_value('general', 'data_dir');
|
||||
|
||||
$self->{pbot}->{logger}->log("Loading plugins ...\n");
|
||||
|
||||
my $plugin_count = 0;
|
||||
|
||||
my $fh;
|
||||
if (not open $fh, "<$data_dir/plugin_autoload") {
|
||||
$self->{pbot}->{logger}->log("warning: file $data_dir/plugin_autoload does not exist; skipping autoloading of Plugins\n");
|
||||
$self->{pbot}->{logger}->log("Plugins: autoload: file $data_dir/plugin_autoload does not exist; skipping autoloading of Plugins\n");
|
||||
return;
|
||||
}
|
||||
chomp(my @plugins = <$fh>);
|
||||
close $fh;
|
||||
|
||||
$self->{pbot}->{logger}->log("Loading plugins:\n");
|
||||
|
||||
$conf{quiet} = 1;
|
||||
|
||||
foreach my $plugin (sort @plugins) {
|
||||
# do not load plugins that begin with a comment
|
||||
next if $plugin =~ m/^\s*#/;
|
||||
@ -48,6 +50,9 @@ sub autoload {
|
||||
|
||||
$plugin = basename $plugin;
|
||||
$plugin =~ s/.pm$//;
|
||||
|
||||
$self->{pbot}->{logger}->log(" $plugin\n");
|
||||
|
||||
$plugin_count++ if $self->load($plugin, %conf);
|
||||
}
|
||||
|
||||
@ -66,7 +71,7 @@ sub load {
|
||||
$self->{pbot}->{refresher}->{refresher}->refresh_module($module);
|
||||
|
||||
my $ret = eval {
|
||||
$self->{pbot}->{logger}->log("Loading $plugin\n");
|
||||
$self->{pbot}->{logger}->log("Loading $plugin\n") unless $conf{quiet};
|
||||
require "$module";
|
||||
my $class = "PBot::Plugin::$plugin";
|
||||
$self->{plugins}->{$plugin} = $class->new(pbot => $self->{pbot}, %conf);
|
||||
|
@ -1,7 +1,17 @@
|
||||
# File: VERSION.pm
|
||||
#
|
||||
# Purpose: Keeps track of bot version. Can compare current version against
|
||||
# latest version on github or URL in `version.check_url` registry entry.
|
||||
# Purpose: Keeps track of bot version. All of PBot is considered a single
|
||||
# entity. The BUILD_REVSION constant in this file is the count of git commits
|
||||
# to the PBot repository when this file was updated. This file is updated by
|
||||
# the /misc/update_version script after any commits that alter PBot's behavior.
|
||||
#
|
||||
# See also PBot::Core::Commands::Version, which can compare current version
|
||||
# against latest version on github or URL in `version.check_url` registry
|
||||
# entry to notify users of the availability of a new version.
|
||||
#
|
||||
# TODO: The PBot::Plugin::* plugins probably should have their own version
|
||||
# identifiers as a template for using versioned $HOME/PBot/Plugin/ plugins. I
|
||||
# don't want to micro-manage version identifiers for PBot::Core stuff though.
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
@ -20,11 +30,11 @@ our @EXPORT_OK = (
|
||||
@{ $EXPORT_TAGS{all} },
|
||||
);
|
||||
|
||||
# These are set automatically by the misc/update_version script
|
||||
# These are set automatically by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4315,
|
||||
BUILD_DATE => "2021-07-26",
|
||||
BUILD_REVISION => 4317,
|
||||
BUILD_DATE => "2021-07-27",
|
||||
};
|
||||
|
||||
sub initialize {
|
||||
|
Loading…
Reference in New Issue
Block a user