use POE::Session;
use FindBin qw/$Bin/;
-my $directory = "$Bin/test_images";
+my $default_directory = "$Bin/test_images";
sub new {
my $proto = shift;
my $self = $class->SUPER::new(@_);
+ $self->{'directory'} =
+ $self->{'config'}{'_config'}{'plugins'}{'Directory'}{'Directory'} || $default_directory;
+
bless ($self, $class);
$self->{'kernel'}->yield('find_photo');
return $self;
sub find_photo {
my $self = shift;
- if (opendir(DIR, $directory)) {
+ if (opendir(DIR, $self->{'directory'})) {
my @files = readdir(DIR);
closedir DIR;
- $self->{'kernel'}->yield('display_photo', join("/", $directory, $files[rand @files]));
+ $self->{'kernel'}->yield('display_photo', join("/", $self->{'directory'}, $files[rand @files]));
} else {
- warn "Failed to open $directory for reading: $!\n";
+ warn "Failed to open $self->{'directory'} for reading: $!\n";
}
}