10 "Ralf Ertzinger (ralf\@skytale.net)",
13 "videosite Video URL grabber script (usage: /videosite)",
18 # Reading a configuration value. Called by the core
22 my $item = join('.', @{$path});
24 if (weechat::config_is_set_plugin($item)) {
25 return weechat::config_get_plugin($item);
32 # Returns a true value if the config item exists
36 my $item = join('.', @{$path});
38 return weechat::config_is_set_plugin($item);
42 # Setting a configuration value. Called by the core
47 my $item = join('.', @{$path});
49 weechat::config_set_plugin($item, $value);
53 # Delete a configuration value. Called by the core.
57 my $item = join('.', @{$path});
59 weechat::config_unset_plugin($item);
63 # Return a color code. Called by the core
68 $fg = defined($fg)?$fg:'default';
69 $bg = defined($bg)?$bg:'default';
71 return weechat::color($fg . ",", $bg);
75 # Handle commands (/videosite ...)
78 my ($data, $buffer, $args) = @_;
81 ewpf => sub { weechat::print($buffer, @_) },
84 libvideosite::handle_command(\%event);
86 return weechat::WEECHAT_RC_OK;
90 # Handle a received message.
91 # Create an event structure and hand it off to libvideosite
94 my ($data, $buffer, $date, $tags, $displayed, $highlight, $prefix, $message ) = @_;
97 ewpf => sub { weechat::print($buffer, @_) },
100 libvideosite::check_for_link(\%event);
102 return weechat::WEECHAT_RC_OK;
108 sub videosite_reset {
109 unless(libvideosite::register_api({
110 io => sub { weechat::print("", @_) },
111 config_init => sub {},
112 config_get => \&config_get,
113 config_set => \&config_set,
114 config_has => \&config_has,
115 config_save => sub {},
116 config_del => \&config_del,
117 color => \&colorpair,
118 module_path => sub { return File::Spec->catfile(weechat::info_get("weechat_dir", ""), 'perl') },
119 quote => sub { return $_ },
122 weechat::print("", sprintf("videosite API register failed: %s", $libvideosite::error));
126 unless(libvideosite::init()) {
127 weechat::print("", sprintf("videosite init failed: %s", $libvideosite::error));
131 weechat::hook_print("", "notify_message", "://", 1, "message_hook", "");
132 weechat::hook_print("", "notify_private", "://", 1, "message_hook", "");
133 weechat::hook_print("", "notify_highlight", "://", 1, "message_hook", "");
134 weechat::hook_print("", "notify_none", "://", 1, "message_hook", "");
135 weechat::hook_command( "videosite", "videosite control functions", "", "", "", "videosite_hook", "");
139 # Find out the script directory, and add it to @INC.
140 # This is necessary to find libvideosite.pm
142 push(@INC, File::Spec->catfile(weechat::info_get("weechat_dir", ""), 'perl'));