-#!/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 //= 'default';
- $bg //= 'default';
-
return weechat::color($fg . ",", $bg);
}
config_get => \&config_get,
config_set => \&config_set,
config_has => \&config_has,
- config_save => sub {},
+ config_save => sub { 1 },
config_del => \&config_del,
color => \&colorpair,
module_path => sub { return File::Spec->catfile(weechat::info_get("weechat_dir", ""), 'perl') },
quote => sub { return $_ },
- _debug => sub { 1 },
+ reload => sub { weechat::print("", "Please use \"/script reload ...\" to reload") },
})) {
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();