mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Factoids now exported to data_dir
This commit is contained in:
parent
ad5fd971a9
commit
e6039b6369
@ -48,15 +48,10 @@ sub new {
|
|||||||
sub initialize {
|
sub initialize {
|
||||||
my ($self, %conf) = @_;
|
my ($self, %conf) = @_;
|
||||||
|
|
||||||
my $filename = delete $conf{filename};
|
my $filename = $conf{filename};
|
||||||
my $export_path = delete $conf{export_path};
|
my $pbot = $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
||||||
my $export_site = delete $conf{export_site};
|
|
||||||
|
|
||||||
my $pbot = delete $conf{pbot} // Carp::croak("Missing pbot reference to " . __FILE__);
|
|
||||||
|
|
||||||
$self->{factoids} = PBot::DualIndexHashObject->new(name => 'Factoids', filename => $filename, pbot => $pbot);
|
$self->{factoids} = PBot::DualIndexHashObject->new(name => 'Factoids', filename => $filename, pbot => $pbot);
|
||||||
$self->{export_path} = $export_path;
|
|
||||||
$self->{export_site} = $export_site;
|
|
||||||
|
|
||||||
$self->{pbot} = $pbot;
|
$self->{pbot} = $pbot;
|
||||||
$self->{commands} = PBot::FactoidCommands->new(pbot => $pbot);
|
$self->{commands} = PBot::FactoidCommands->new(pbot => $pbot);
|
||||||
@ -148,7 +143,7 @@ sub export_factoids {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $filename;
|
my $filename;
|
||||||
|
|
||||||
if (@_) { $filename = shift; } else { $filename = $self->export_path; }
|
if (@_) { $filename = shift; } else { $filename = $self->{pbot}->{registry}->get_value('general', 'data_dir') . '/factoids.html'; }
|
||||||
return if not defined $filename;
|
return if not defined $filename;
|
||||||
|
|
||||||
open FILE, "> $filename" or return "Could not open export path.";
|
open FILE, "> $filename" or return "Could not open export path.";
|
||||||
@ -261,8 +256,7 @@ sub export_factoids {
|
|||||||
|
|
||||||
close(FILE);
|
close(FILE);
|
||||||
|
|
||||||
#$self->{pbot}->{logger}->log("$i factoids exported to path: " . $self->export_path . ", site: " . $self->export_site . "\n");
|
return "/say $i factoids exported.";
|
||||||
return "/say $i factoids exported to " . $self->export_site;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub find_factoid {
|
sub find_factoid {
|
||||||
@ -1141,35 +1135,4 @@ sub handle_action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub export_path {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
if (@_) { $self->{export_path} = shift; }
|
|
||||||
return $self->{export_path};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub logger {
|
|
||||||
my $self = shift;
|
|
||||||
if (@_) { $self->{logger} = shift; }
|
|
||||||
return $self->{logger};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub export_site {
|
|
||||||
my $self = shift;
|
|
||||||
if (@_) { $self->{export_site} = shift; }
|
|
||||||
return $self->{export_site};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub factoids {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->{factoids};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub filename {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
if (@_) { $self->{filename} = shift; }
|
|
||||||
return $self->{filename};
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -203,13 +203,7 @@ sub initialize {
|
|||||||
$self->{interpreter}->register(sub { return $self->{commands}->interpreter(@_); });
|
$self->{interpreter}->register(sub { return $self->{commands}->interpreter(@_); });
|
||||||
$self->{interpreter}->register(sub { return $self->{factoids}->interpreter(@_); });
|
$self->{interpreter}->register(sub { return $self->{factoids}->interpreter(@_); });
|
||||||
|
|
||||||
$self->{factoids} = PBot::Factoids->new(
|
$self->{factoids} = PBot::Factoids->new(pbot => $self, filename => "$data_dir/factoids", %conf);
|
||||||
pbot => $self,
|
|
||||||
filename => "$data_dir/factoids",
|
|
||||||
export_path => $conf{export_factoids_path},
|
|
||||||
export_site => $conf{export_factoids_site},
|
|
||||||
%conf
|
|
||||||
);
|
|
||||||
|
|
||||||
$self->{plugins} = PBot::Plugins->new(pbot => $self, %conf);
|
$self->{plugins} = PBot::Plugins->new(pbot => $self, %conf);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user