X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=videosite-irssi.pl;h=441ad3ecb541993cdb584300ff3ae82d461d3bd4;hb=f6f36c640976a5e70a5244a793d6f0a6b4c856b6;hp=f5c6ef1ee2ef4726d69484278fccfb4dc7a7c093;hpb=6a9455d53fe12634ee4b587a3ed1a9d13e66e2e7;p=videosite.git diff --git a/videosite-irssi.pl b/videosite-irssi.pl index f5c6ef1..441ad3e 100644 --- a/videosite-irssi.pl +++ b/videosite-irssi.pl @@ -233,6 +233,22 @@ sub message_hook { } sub videosite_reset { + my $libpath; + + # Find out the script directory, and add it to @INC. + # This is necessary to find libvideosite.pm + $libpath = File::Spec->catfile(Irssi::get_irssi_dir(), 'scripts'); + + # If the library is already loaded unload it + foreach (keys(%INC)) { + if ($INC{$_} eq File::Spec->catfile($libpath, 'libvideosite.pm')) { + delete($INC{$_}); + } + } + + push(@INC, $libpath); + load 'libvideosite'; + unless(libvideosite::register_api({ io => sub { Irssi::print($_[0]) }, config_init => \&config_init, @@ -244,6 +260,7 @@ sub videosite_reset { color => \&colorpair, module_path => sub { return File::Spec->catfile(Irssi::get_irssi_dir(), 'scripts') }, quote => sub { s/%/%%/g; return $_ }, + reload => \&videosite_reset, _debug => sub { 1 }, })) { Irssi::print(sprintf("videosite API register failed: %s", $libvideosite::error)); @@ -259,16 +276,11 @@ sub videosite_reset { } sub videosite_init { - # Find out the script directory, and add it to @INC. - # This is necessary to find libvideosite.pm - - push(@INC, File::Spec->catfile(Irssi::get_irssi_dir(), 'scripts')); - load 'libvideosite'; if (videosite_reset()) { signal_add_last("message public", sub { message_hook(@_) }); signal_add_last("message own_public", sub { message_hook($_[0], $_[1], undef, undef, $_[2]) }); - signal_add_last("message private", sub { message_hooK($_[0], $_[1], $_[2], $_[3], $_[2]) }); + signal_add_last("message private", sub { message_hook($_[0], $_[1], $_[2], $_[3], $_[2]) }); signal_add_last("message own_private", sub { message_hook($_[0], $_[1], undef, undef, $_[2]) }); signal_add_last("message irc action", sub { message_hook(@_) }); signal_add_last("message irc own_action", sub { message_hook($_[0], $_[1], undef, undef, $_[2]) });