mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-06 03:59:31 +01:00
Simplify VERSION.pm
This commit is contained in:
parent
67d2dd5d95
commit
8cff244256
@ -134,6 +134,9 @@ sub initialize {
|
||||
# prepare and open logger
|
||||
$self->{logger} = PBot::Core::Logger->new(pbot => $self, filename => "$conf{data_dir}/log/log", %conf);
|
||||
|
||||
# log the version
|
||||
$self->{logger}->log(PBot::VERSION::BUILD_NAME . ' version ' . PBot::VERSION::BUILD_REVISION . ' ' . PBot::VERSION::BUILD_DATE . "\n");
|
||||
|
||||
# log command-line arguments
|
||||
$self->{logger}->log("Args: @ARGV\n") if @ARGV;
|
||||
|
||||
@ -158,10 +161,6 @@ sub initialize {
|
||||
# create commands so the modules can register new commands
|
||||
$self->{commands} = PBot::Core::Commands->new(pbot => $self, filename => "$conf{data_dir}/commands", %conf);
|
||||
|
||||
# prepare the version information and `version` command
|
||||
$self->{version} = PBot::VERSION->new(pbot => $self, %conf);
|
||||
$self->{logger}->log($self->{version}->version . "\n");
|
||||
|
||||
# prepare registry
|
||||
$self->{registry} = PBot::Core::Registry->new(pbot => $self, filename => "$conf{data_dir}/registry", %conf);
|
||||
|
||||
|
@ -11,8 +11,6 @@ use parent 'PBot::Core::Class';
|
||||
|
||||
use PBot::Imports;
|
||||
|
||||
use PBot::VERSION qw/BUILD_REVISION BUILD_DATE/;
|
||||
|
||||
use LWP::UserAgent;
|
||||
|
||||
sub initialize {
|
||||
@ -22,7 +20,11 @@ sub initialize {
|
||||
$self->{pbot}->{commands}->register(sub { $self->cmd_version(@_) }, 'version');
|
||||
|
||||
# initialize last_check version data
|
||||
$self->{last_check} = {timestamp => 0, version => BUILD_REVISION, date => BUILD_DATE};
|
||||
$self->{last_check} = {
|
||||
timestamp => 0,
|
||||
version => PBot::VERSION::BUILD_REVISION,
|
||||
date => PBot::VERSION::BUILD_DATE,
|
||||
};
|
||||
}
|
||||
|
||||
sub cmd_version {
|
||||
@ -61,9 +63,9 @@ sub cmd_version {
|
||||
|
||||
my $result = '/say ';
|
||||
$result .= "$target_nick: " if $target_nick;
|
||||
$result .= $self->{pbot}->{version}->version;
|
||||
$result .= PBot::VERSION::BUILD_NAME . ' version ' . PBot::VERSION::BUILD_REVISION . ' ' . PBot::VERSION::BUILD_DATE;
|
||||
|
||||
if ($self->{last_check}->{version} > BUILD_REVISION) {
|
||||
if ($self->{last_check}->{version} > PBot::VERSION::BUILD_REVISION) {
|
||||
$result .= "; new version available: $self->{last_check}->{version} $self->{last_check}->{date}!";
|
||||
}
|
||||
|
||||
|
@ -1,48 +1,29 @@
|
||||
# File: VERSION.pm
|
||||
#
|
||||
# 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.
|
||||
# Purpose: Keeps track of bot version constants.
|
||||
#
|
||||
# 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.
|
||||
# Rather than each PBot::Core package having its own version identifier, all
|
||||
# of PBot is considered a single package. The BUILD_REVSION constant is the
|
||||
# count of git commits to the PBot repository.
|
||||
#
|
||||
# See also the version command in PBot::Core::Commands::Version. It can compare
|
||||
# the local PBot version against latest version on GitHub (or the URL in
|
||||
# the `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.
|
||||
# identifiers as a template for versioned $HOME/PBot/Plugin/ plugins.
|
||||
|
||||
# SPDX-FileCopyrightText: 2021 Pragmatic Software <pragma78@gmail.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
package PBot::VERSION;
|
||||
use parent 'PBot::Core::Class';
|
||||
|
||||
use PBot::Imports;
|
||||
|
||||
use Exporter qw/import/;
|
||||
our @EXPORT = ();
|
||||
our %EXPORT_TAGS = (
|
||||
'all' => [qw/BUILD_NAME BUILD_REVISION BUILD_DATE/],
|
||||
);
|
||||
our @EXPORT_OK = (
|
||||
@{ $EXPORT_TAGS{all} },
|
||||
);
|
||||
|
||||
# These are set automatically by the /misc/update_version script
|
||||
# These are set by the /misc/update_version script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 4317,
|
||||
BUILD_REVISION => 4318,
|
||||
BUILD_DATE => "2021-07-27",
|
||||
};
|
||||
|
||||
sub initialize {
|
||||
# nothing to do here
|
||||
}
|
||||
|
||||
sub version {
|
||||
return BUILD_NAME . " version " . BUILD_REVISION . " " . BUILD_DATE;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user