From 1d562536b9c6135697a468ae572cb4afce36db34 Mon Sep 17 00:00:00 2001 From: Ralf Ertzinger Date: Tue, 15 Apr 2008 20:23:58 +0200 Subject: [PATCH] - Remove Irssi deps from plugins --- videosite.pl | 1 + videosite/Base.pm | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/videosite.pl b/videosite.pl index c970e98..3ae1e83 100644 --- a/videosite.pl +++ b/videosite.pl @@ -302,6 +302,7 @@ sub ploader { write_debug(undef, "found $g->{'TYPE'} $g->{'NAME'}"); if ($type eq $g->{'TYPE'}) { push(@g, $g); + $g->setio(sub {Irssi::print(shift)}); } else { write_irssi(undef, '%s has wrong type (got %s, expected %s)', $p, $g->{'TYPE'}, $type); delete($INC{$p}); diff --git a/videosite/Base.pm b/videosite/Base.pm index 51b091c..2db4969 100644 --- a/videosite/Base.pm +++ b/videosite/Base.pm @@ -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 {}}; bless($self, $class); @@ -24,7 +23,7 @@ sub error { $t = sprintf(shift(@_), @_); $t =~ s/%/%%/g; - Irssi::print($t); + $self->{'_OUT'}->($t); } sub debug { @@ -85,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"; -- 1.8.3.1