mirror of https://github.com/pragma-/pbot.git
Fix version not updating after `refresh`
This commit is contained in:
parent
59140d4096
commit
39ee73f0b8
|
@ -135,7 +135,8 @@ sub initialize {
|
||||||
$self->{logger} = PBot::Core::Logger->new(pbot => $self, filename => "$conf{data_dir}/log/log", %conf);
|
$self->{logger} = PBot::Core::Logger->new(pbot => $self, filename => "$conf{data_dir}/log/log", %conf);
|
||||||
|
|
||||||
# log the version
|
# log the version
|
||||||
$self->{logger}->log(PBot::VERSION::BUILD_NAME . ' version ' . PBot::VERSION::BUILD_REVISION . ' ' . PBot::VERSION::BUILD_DATE . "\n");
|
$self->{version} = PBot::VERSION->new(pbot => $self);
|
||||||
|
$self->{logger}->log($self->{version}->version . "\n");
|
||||||
|
|
||||||
# log command-line arguments
|
# log command-line arguments
|
||||||
$self->{logger}->log("Args: @ARGV\n") if @ARGV;
|
$self->{logger}->log("Args: @ARGV\n") if @ARGV;
|
||||||
|
|
|
@ -19,10 +19,10 @@ sub initialize {
|
||||||
# register `version` command
|
# register `version` command
|
||||||
$self->{pbot}->{commands}->register(sub { $self->cmd_version(@_) }, 'version');
|
$self->{pbot}->{commands}->register(sub { $self->cmd_version(@_) }, 'version');
|
||||||
|
|
||||||
# initialize last_check version data
|
# initialize last_check version data using compile-time constants
|
||||||
$self->{last_check} = {
|
$self->{last_check} = {
|
||||||
timestamp => 0,
|
timestamp => 0,
|
||||||
version => PBot::VERSION::BUILD_REVISION,
|
revision => PBot::VERSION::BUILD_REVISION,
|
||||||
date => PBot::VERSION::BUILD_DATE,
|
date => PBot::VERSION::BUILD_DATE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,13 @@ sub cmd_version {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $text = $response->decoded_content;
|
my $text = $response->decoded_content;
|
||||||
my ($version, $date) = $text =~ m/^\s+BUILD_REVISION => (\d+).*^\s+BUILD_DATE\s+=> "([^"]+)"/ms;
|
my ($revision, $date) = $text =~ m/^\s+BUILD_REVISION => (\d+).*^\s+BUILD_DATE\s+=> "([^"]+)"/ms;
|
||||||
|
|
||||||
if (not defined $version or not defined $date) {
|
if (not defined $revision or not defined $date) {
|
||||||
return "Unable to get version information: data did not match expected format";
|
return "Unable to get version information: data did not match expected format";
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{last_check} = {timestamp => time, version => $version, date => $date};
|
$self->{last_check} = { timestamp => time, revision => $revision, date => $date };
|
||||||
}
|
}
|
||||||
|
|
||||||
my $target_nick;
|
my $target_nick;
|
||||||
|
@ -63,10 +63,10 @@ sub cmd_version {
|
||||||
|
|
||||||
my $result = '/say ';
|
my $result = '/say ';
|
||||||
$result .= "$target_nick: " if $target_nick;
|
$result .= "$target_nick: " if $target_nick;
|
||||||
$result .= PBot::VERSION::BUILD_NAME . ' version ' . PBot::VERSION::BUILD_REVISION . ' ' . PBot::VERSION::BUILD_DATE;
|
$result .= $self->{pbot}->{version}->version;
|
||||||
|
|
||||||
if ($self->{last_check}->{version} > PBot::VERSION::BUILD_REVISION) {
|
if ($self->{last_check}->{revision} > $self->{pbot}->{version}->revision) {
|
||||||
$result .= "; new version available: $self->{last_check}->{version} $self->{last_check}->{date}!";
|
$result .= "; new version available: $self->{last_check}->{revision} $self->{last_check}->{date}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# File: VERSION.pm
|
# File: VERSION.pm
|
||||||
#
|
#
|
||||||
# Purpose: Keeps track of bot version constants.
|
# Purpose: Sets the PBot version constants.
|
||||||
#
|
#
|
||||||
# Rather than each PBot::Core package having its own version identifier, all
|
# 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
|
# of PBot is considered a single package. The BUILD_REVSION constant is the
|
||||||
|
@ -18,12 +18,25 @@
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package PBot::VERSION;
|
package PBot::VERSION;
|
||||||
|
use parent 'PBot::Core::Class';
|
||||||
|
|
||||||
|
use PBot::Imports;
|
||||||
|
|
||||||
# These are set by the /misc/update_version script
|
# These are set by the /misc/update_version script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 4319,
|
BUILD_REVISION => 4320,
|
||||||
BUILD_DATE => "2021-07-27",
|
BUILD_DATE => "2021-07-27",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sub initialize {}
|
||||||
|
|
||||||
|
sub version {
|
||||||
|
return BUILD_NAME . ' version ' . BUILD_REVISION . ' ' . BUILD_DATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub revision {
|
||||||
|
return BUILD_REVISION;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue