mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 12:12:34 +01:00
Properly update version factoid on refresh
This commit is contained in:
parent
b7ec6b68dd
commit
f8960d79b5
@ -26,7 +26,7 @@ use JSON;
|
|||||||
use PPI;
|
use PPI;
|
||||||
use Safe;
|
use Safe;
|
||||||
|
|
||||||
use PBot::PBot qw($VERSION);
|
use PBot::VERSION qw/version/;
|
||||||
use PBot::FactoidCommands;
|
use PBot::FactoidCommands;
|
||||||
use PBot::FactoidModuleLauncher;
|
use PBot::FactoidModuleLauncher;
|
||||||
use PBot::DualIndexHashObject;
|
use PBot::DualIndexHashObject;
|
||||||
@ -82,6 +82,7 @@ sub load_factoids {
|
|||||||
|
|
||||||
foreach my $channel (keys %{ $self->{factoids}->hash }) {
|
foreach my $channel (keys %{ $self->{factoids}->hash }) {
|
||||||
foreach my $trigger (keys %{ $self->{factoids}->hash->{$channel} }) {
|
foreach my $trigger (keys %{ $self->{factoids}->hash->{$channel} }) {
|
||||||
|
$self->{pbot}->{logger}->log("Missing type for $channel->$trigger\n") if not $self->{factoids}->hash->{$channel}->{$trigger}->{type};
|
||||||
$text++ if $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'text';
|
$text++ if $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'text';
|
||||||
$regex++ if $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'regex';
|
$regex++ if $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'regex';
|
||||||
$modules++ if $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'module';
|
$modules++ if $self->{factoids}->hash->{$channel}->{$trigger}->{type} eq 'module';
|
||||||
@ -96,7 +97,8 @@ sub load_factoids {
|
|||||||
|
|
||||||
sub add_default_factoids {
|
sub add_default_factoids {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->add_factoid('text', '.*', $self->{pbot}->{registry}->get_value('irc', 'botnick'), 'version', "/say $VERSION", 1);
|
my $version = version();
|
||||||
|
$self->add_factoid('text', '.*', $self->{pbot}->{registry}->get_value('irc', 'botnick'), 'version', "/say $version", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub save_factoids {
|
sub save_factoids {
|
||||||
|
15
PBot/PBot.pm
15
PBot/PBot.pm
@ -14,22 +14,12 @@ package PBot::PBot;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use PBot::VERSION;
|
|
||||||
|
|
||||||
BEGIN {
|
|
||||||
use Exporter;
|
|
||||||
our @ISA = 'Exporter';
|
|
||||||
our @EXPORT = qw($VERSION);
|
|
||||||
|
|
||||||
our $VERSION = PBot::VERSION::BUILD_NAME . " revision " . PBot::VERSION::BUILD_REVISION . " " . PBot::VERSION::BUILD_DATE;
|
|
||||||
print "$VERSION\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
# unbuffer stdout
|
# unbuffer stdout
|
||||||
STDOUT->autoflush(1);
|
STDOUT->autoflush(1);
|
||||||
|
|
||||||
use Carp ();
|
use Carp ();
|
||||||
use PBot::Logger;
|
use PBot::Logger;
|
||||||
|
use PBot::VERSION;
|
||||||
use PBot::Registry;
|
use PBot::Registry;
|
||||||
use PBot::SelectHandler;
|
use PBot::SelectHandler;
|
||||||
use PBot::StdinReader;
|
use PBot::StdinReader;
|
||||||
@ -72,6 +62,9 @@ sub initialize {
|
|||||||
# logger created first to allow other modules to log things
|
# logger created first to allow other modules to log things
|
||||||
$self->{logger} = PBot::Logger->new(log_file => $conf{log_file}, %conf);
|
$self->{logger} = PBot::Logger->new(log_file => $conf{log_file}, %conf);
|
||||||
|
|
||||||
|
$self->{version} = PBot::VERSION->new(pbot => $self, %conf);
|
||||||
|
$self->{logger}->log($self->{version}->version . "\n");
|
||||||
|
|
||||||
$self->{atexit} = PBot::Registerable->new(%conf);
|
$self->{atexit} = PBot::Registerable->new(%conf);
|
||||||
$self->{timer} = PBot::Timer->new(timeout => 10, %conf);
|
$self->{timer} = PBot::Timer->new(timeout => 10, %conf);
|
||||||
$self->{commands} = PBot::Commands->new(pbot => $self, %conf);
|
$self->{commands} = PBot::Commands->new(pbot => $self, %conf);
|
||||||
|
@ -49,13 +49,9 @@ sub refresh {
|
|||||||
return "Refreshed all modified modules.\n";
|
return "Refreshed all modified modules.\n";
|
||||||
} else {
|
} else {
|
||||||
$self->{pbot}->{logger}->log("Refreshing module $arguments\n");
|
$self->{pbot}->{logger}->log("Refreshing module $arguments\n");
|
||||||
if ($self->{refresher}->refresh_module_if_modified($arguments)) {
|
$self->{refresher}->refresh_module($arguments);
|
||||||
$self->{pbot}->{logger}->log("Refreshed module.\n");
|
$self->{pbot}->{logger}->log("Refreshed module.\n");
|
||||||
return "Refreshed module.\n";
|
return "Refreshed module.\n";
|
||||||
} else {
|
|
||||||
$self->{pbot}->{logger}->log("Module had no changes; not refreshed.\n");
|
|
||||||
return "Module had no changes; not refreshed.\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,9 +61,11 @@ sub refresh {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# update version factoid
|
# update version factoid
|
||||||
use PBot::VERSION;
|
my $version = $self->{pbot}->{version}->version();
|
||||||
my $version = PBot::VERSION::BUILD_NAME . " revision " . PBot::VERSION::BUILD_REVISION . " " . PBot::VERSION::BUILD_DATE;
|
if ($self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{'version'}->{'action'} ne "/say $version") {
|
||||||
$self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{'version'}->{'action'} = "/say $version";
|
$self->{pbot}->{factoids}->{factoids}->hash->{'.*'}->{'version'}->{'action'} = "/say $version";
|
||||||
|
$self->{pbot}->{logger}->log("New version: $version\n");
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,12 @@ package PBot::VERSION;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
use Exporter;
|
||||||
|
our @ISA = 'Exporter';
|
||||||
|
our @EXPORT_OK = qw(version);
|
||||||
|
}
|
||||||
|
|
||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
@ -21,4 +27,15 @@ use constant {
|
|||||||
BUILD_DATE => "2018-01-22",
|
BUILD_DATE => "2018-01-22",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %conf) = @_;
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
$self->{pbot} = delete $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub version {
|
||||||
|
return BUILD_NAME . " revision " . BUILD_REVISION . " " . BUILD_DATE;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user