libvideosite: use path argument properly in _config_list_* helpers
[videosite.git] / videosite-weechat.pl
index fdcc5d5..8060679 100644 (file)
@@ -1,5 +1,7 @@
-#!/usr/bin/perl -w
-
+# shim to connect libvideosite to weechat
+#
+# (c) 2007-2008 by Ralf Ertzinger <ralf@camperquake.de>
+# licensed under GNU GPL v2
 use strict;
 use File::Spec;
 use Module::Load;
@@ -65,9 +67,6 @@ sub config_del {
 sub colorpair {
     my ($fg, $bg) = @_;
 
-    $fg = defined($fg)?$fg:'default';
-    $bg = defined($bg)?$bg:'default';
-
     return weechat::color($fg . ",", $bg);
 }
 
@@ -120,19 +119,15 @@ sub videosite_reset {
         _debug => sub { 1 },
     })) {
         weechat::print("", sprintf("videosite API register failed: %s", $libvideosite::error));
-        return;
+        return 0;
     }
 
     unless(libvideosite::init()) {
         weechat::print("", sprintf("videosite init failed: %s", $libvideosite::error));
-        return;
+        return 0;
     }
 
-    weechat::hook_print("", "notify_message", "://", 1, "message_hook", "");
-    weechat::hook_print("", "notify_private", "://", 1, "message_hook", "");
-    weechat::hook_print("", "notify_highlight", "://", 1, "message_hook", "");
-    weechat::hook_print("", "notify_none", "://", 1, "message_hook", "");
-    weechat::hook_command( "videosite", "videosite control functions", "", "", "", "videosite_hook", "");
+    return 1;
 }
 
 sub videosite_init {
@@ -142,7 +137,13 @@ sub videosite_init {
     push(@INC, File::Spec->catfile(weechat::info_get("weechat_dir", ""), 'perl'));
     load 'libvideosite';
 
-    videosite_reset();
+    if (videosite_reset()) {
+        weechat::hook_print("", "notify_message", "://", 1, "message_hook", "");
+        weechat::hook_print("", "notify_private", "://", 1, "message_hook", "");
+        weechat::hook_print("", "notify_highlight", "://", 1, "message_hook", "");
+        weechat::hook_print("", "notify_none", "://", 1, "message_hook", "");
+        weechat::hook_command( "videosite", "videosite control functions", "", "", "", "videosite_hook", "");
+    }
 }
 
 videosite_init();