- Study message before throwing it to the grabbers
[videosite.git] / videosite / Base.pm
index cf8bafa..d8a4e98 100644 (file)
@@ -4,12 +4,11 @@
 package Base;
 
 use strict;
-use Irssi;
 use Data::Dumper;
 
 sub new {
     my $class = shift;
-    my $self = {'_DEBUG' => 0};
+    my $self = {'_DEBUG' => 0, '_OUT' => sub {print shift}};
 
     bless($self, $class);
 
@@ -20,12 +19,11 @@ sub new {
 
 sub error {
     my $self = shift;
-    my @data = @_;
     my $t;
 
     $t = sprintf(shift(@_), @_);
     $t =~ s/%/%%/g;
-    Irssi::print($t);
+    $self->{'_OUT'}($t);
 }
 
 sub debug {
@@ -56,7 +54,7 @@ sub _prepare_parameters {
     my $self = shift;
     my $p;
 
-    $self->{'_CONFIG'} = {'option' => {}};
+    $self->{'_CONFIG'} = {'option' => {'enabled' => {'content' => '1'}}};
 
     foreach $p (keys(%{$self->{'_PARAMS'}})) {
         $self->{'_CONFIG'}->{'option'}->{$p}->{'content'} = $self->{'_PARAMS'}->{$p}->[0];
@@ -86,6 +84,13 @@ sub setval {
     }
 }
 
+sub setio {
+    my $self = shift;
+    my $io = shift;
+
+    $self->{'_OUT'} = $io;
+}
+
 sub getconfstr {
     my $self = shift;
     my $s = 'Options for ' . $self->{'NAME'} . ":\n";