diff --git a/lib/PBot/Core.pm b/lib/PBot/Core.pm index 3294ca86..785f2312 100644 --- a/lib/PBot/Core.pm +++ b/lib/PBot/Core.pm @@ -219,6 +219,8 @@ sub initialize { return; } ); + + $self->{logger}->log("PBot::Core initialized.\n"); } sub random_nick { diff --git a/lib/PBot/Core/Class.pm b/lib/PBot/Core/Class.pm index 53ef4394..73af1251 100644 --- a/lib/PBot/Core/Class.pm +++ b/lib/PBot/Core/Class.pm @@ -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"); diff --git a/lib/PBot/Core/Factoids/Data.pm b/lib/PBot/Core/Factoids/Data.pm index f7b1ea7d..b3680a5f 100644 --- a/lib/PBot/Core/Factoids/Data.pm +++ b/lib/PBot/Core/Factoids/Data.pm @@ -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}, ); } diff --git a/lib/PBot/Core/Plugins.pm b/lib/PBot/Core/Plugins.pm index 38c9291c..681acc7b 100644 --- a/lib/PBot/Core/Plugins.pm +++ b/lib/PBot/Core/Plugins.pm @@ -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); diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index d6da8615..f7b2d01e 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -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 # 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 {