X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite%2FBase.pm;h=cf8bafa51e4e99f2a513d00e4f2d5b17f48436d4;hb=ffc24eec49bbdb6117e3a67e6080c119fba6575d;hp=5aa8eaea2c0b57a69167b9fc7a6c0721605ed27c;hpb=2044d5ff60e639a2eafbeed3a70224564e94c84c;p=videosite.git diff --git a/videosite/Base.pm b/videosite/Base.pm index 5aa8eae..cf8bafa 100644 --- a/videosite/Base.pm +++ b/videosite/Base.pm @@ -5,6 +5,7 @@ package Base; use strict; use Irssi; +use Data::Dumper; sub new { my $class = shift; @@ -20,8 +21,11 @@ sub new { sub error { my $self = shift; my @data = @_; + my $t; - Irssi::print(sprintf(shift(@_), @_)); + $t = sprintf(shift(@_), @_); + $t =~ s/%/%%/g; + Irssi::print($t); } sub debug { @@ -37,6 +41,8 @@ sub mergeconfig { my $c = shift; my $o; + return $self->{'_CONFIG'} unless defined($c); + foreach $o (keys(%{$c->{'option'}})) { if (exists($self->{'_CONFIG'}->{'option'}->{$o})) { $self->{'_CONFIG'}->{'option'}->{$o}->{'content'} = $c->{'option'}->{$o}->{'content'}; @@ -50,8 +56,7 @@ sub _prepare_parameters { my $self = shift; my $p; - $self->{'_CONFIG'} = { 'module' => $self->{'NAME'}, - 'option' => {}}; + $self->{'_CONFIG'} = {'option' => {}}; foreach $p (keys(%{$self->{'_PARAMS'}})) { $self->{'_CONFIG'}->{'option'}->{$p}->{'content'} = $self->{'_PARAMS'}->{$p}->[0]; @@ -61,8 +66,12 @@ sub _prepare_parameters { sub _getval { my $self = shift; my $key = shift; + my $val; + + $val = $self->{'_CONFIG'}->{'option'}->{$key}->{'content'}; + $self->debug('Returning %s=%s', $key, $val); - return $self->{'_CONFIG'}->{'option'}->{$key}->{'content'} + return $val; } sub setval { @@ -87,7 +96,7 @@ sub getconfstr { $p = $self->{'_CONFIG'}->{'option'}->{$k}->{'content'}; $p =~ s/%/%%/g; $s .= sprintf(" %s: %s", $k, $p); - if ($self->{'_CONFIG'}->{'option'}->{$k}->{'content'} == $self->{'_PARAMS'}->{$k}->[0]) { + if ($self->{'_CONFIG'}->{'option'}->{$k}->{'content'} eq $self->{'_PARAMS'}->{$k}->[0]) { $s .= " (default)\n"; } else { $s .= "\n";