-#!/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;
sub colorpair {
my ($fg, $bg) = @_;
- $fg = defined($fg)?$fg:'default';
- $bg = defined($bg)?$bg:'default';
-
return weechat::color($fg . ",", $bg);
}
_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 {
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();