videosite-weechat: make hooking of signals dependant on successful init
authorRalf Ertzinger <ralf@skytale.net>
Tue, 30 Apr 2013 14:04:53 +0000 (16:04 +0200)
committerRalf Ertzinger <ralf@skytale.net>
Tue, 30 Apr 2013 14:04:53 +0000 (16:04 +0200)
videosite-weechat.pl

index fdcc5d5..62c8870 100644 (file)
@@ -120,19 +120,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 +138,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();