1

add on_unload script routines to clean out hooks

This commit is contained in:
eleksir
2016-10-02 01:48:24 +03:00
parent 72385248d8
commit 05d0b6addd

View File

@@ -13,6 +13,7 @@ sub cdlfunc($); # thread, that checks and downloads stuff
sub is_picture($);
sub urlencode($);
sub hookfn;
sub freehooks;
my $wgetpath;
@@ -25,13 +26,14 @@ if (-f "/bin/wget") {
}
my $script_name = "Image URL Auto Grabber and Downloader, wget flavour";
HexChat::register($script_name, '0.8', 'Automatically grabs and downloads image URLs via wget');
HexChat::register($script_name, '0.8.1', 'Automatically grabs and downloads image URLs via wget', \&freehooks);
HexChat::print("$script_name loaded\n");
HexChat::hook_print('Channel Message', \&hookfn);
HexChat::hook_print('Channel Msg Hilight', \&hookfn);
HexChat::hook_print('Channel Action', \&hookfn);
HexChat::hook_print('Channel Action Hilight', \&hookfn);
my @hooks;
push @hooks, HexChat::hook_print('Channel Message', \&hookfn);
push @hooks, HexChat::hook_print('Channel Msg Hilight', \&hookfn);
push @hooks, HexChat::hook_print('Channel Action', \&hookfn);
push @hooks, HexChat::hook_print('Channel Action Hilight', \&hookfn);
my $active = 0;
share($active);
@@ -127,3 +129,11 @@ sub urlencode($) {
undef $urlobj;
return $url;
}
sub freehooks {
foreach (@hooks) {
HexChat::unhook($_);
}
return HexChat::EAT_ALL;
}