X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite.pl;h=58ff284bed1e2eaa0c151a18360aa13aa7952e72;hb=26e6f7a1323284793a4ca890461e6cbb336bc27f;hp=1a348eea27ae1c1b12adafd8ba558446b5235f12;hpb=52382d520ce9bc33042e30b6eeee48b35d37bd45;p=videosite.git diff --git a/videosite.pl b/videosite.pl index 1a348ee..58ff284 100644 --- a/videosite.pl +++ b/videosite.pl @@ -6,6 +6,7 @@ # Based on youtube.pl by Christian Garbs # which in turn is # based on trigger.pl by Wouter Coekaerts +# This is helena use strict; use Irssi 20020324 qw (command_bind command_runsub signal_add_first signal_add_last); @@ -19,7 +20,8 @@ my @getters; my $getter; my $conf; my $conffile = File::Spec->catfile(Irssi::get_irssi_dir(), 'videosite.xml'); -my $plugindir = File::Spec->catfile(Irssi::get_irssi_dir(), 'scripts', 'videosite'); +my $scriptdir = File::Spec->catfile(Irssi::get_irssi_dir(), 'scripts'); +my $plugindir = File::Spec->catfile($scriptdir, 'videosite'); my $PARAMS = { 'getter' => '', @@ -272,9 +274,9 @@ sub cmd_help { } else { write_irssi(undef, <<'EOT'); Supported commands: - save: Save the current configuration - help [modulename]: Display this help, or module specific help - show [modulename]: Show loaded modules, or the current parameters of a module + save: save the current configuration + help [modulename]: display this help, or module specific help + show [modulename]: show loaded modules, or the current parameters of a module set modulename parameter value: set a module parameter to a new value getter [modulename]: display or set the getter to use enable [modulename]: enable the usage of this module (grabbers only) @@ -292,8 +294,8 @@ sub cmd_getter { my $p; if (defined($target)) { - foreach $p (@getters, @grabbers) { - if (($p->{'NAME'} eq $target) && ($p->{'TYPE'} eq 'getter')) { + foreach $p (@getters) { + if ($p->{'NAME'} eq $target) { $getter = $p; $conf->{'videosite'}->{'getter'} = $target; return; @@ -346,13 +348,13 @@ sub ploader { foreach $p (@list) { write_debug(undef, "Trying to load $p:"); $p =~ s/\.pm$//; - eval qq{ require $p; }; + eval qq{ require videosite::$p; }; if ($@) { write_irssi(undef, "Failed to load plugin: $@"); next; } - $g = eval $p.q{->new();}; + $g = eval qq{ videosite::$p->new(); }; if ($@) { write_irssi(undef, "Failed to instanciate: $@"); delete($INC{$p}); @@ -449,15 +451,35 @@ sub sig_complete { if ('/videosite' eq $linestart) { # No command enterd so far. Produce a list of possible follow-ups - @matches = sort grep {/^$word/} keys (%{$videosite_commands}); + @matches = grep {/^$word/} keys (%{$videosite_commands}); } elsif ('/videosite set' eq $linestart) { # 'set' command entered. Produce a list of modules foreach (@grabbers, @getters) { push(@matches, $_->{'NAME'}) if $_->{'NAME'} =~ m|^$word|; }; + } elsif ($linestart =~ m|^/videosite set (\w+)$|) { + my $module = $1; + + foreach my $p (@getters, @grabbers) { + if ($p->{'NAME'} eq $module) { + @matches = $p->getparamlist($word); + last; + } + } + } elsif ($linestart =~ m|/videosite set (\w+) (\w+)$|) { + my $module = $1; + my $param = $2; + + foreach my $p (@getters, @grabbers) { + if ($p->{'NAME'} eq $module) { + @matches = $p->getparamvalues($param, $word); + last; + } + } } - push(@{$complist}, @matches); + + push(@{$complist}, sort @matches); ${$want_space} = 0; Irssi::signal_stop(); @@ -472,5 +494,5 @@ sub cmdhandler { } } -unshift(@INC, $plugindir); +unshift(@INC, $scriptdir); init_videosite(1);