diff --git a/img_url_wget.pl b/img_url_wget.pl index 8f84494..b440b65 100644 --- a/img_url_wget.pl +++ b/img_url_wget.pl @@ -26,7 +26,7 @@ if (-f "/bin/wget") { } my $script_name = "Image URL Auto Grabber and Downloader, wget flavour"; -HexChat::register($script_name, '0.8.2', 'Automatically grabs and downloads image URLs via wget', \&freehooks); +HexChat::register($script_name, '0.8.4', 'Automatically grabs and downloads image URLs via wget', \&freehooks); HexChat::print("$script_name loaded\n"); my @hooks; @@ -45,7 +45,15 @@ sub hookfn { foreach (@words) { if ($_ =~ m{https?://([a-zA-Z0-9.-]+\.[a-zA-Z]+)/(?:.*)}) { $active = 1; - threads->create(\&cdlfunc, $_)->detach; + my $t = undef; + + do { + $t = threads->create('cdlfunc', $_); + sleep 1 unless(defined($t)); + } unless (defined($t)); + + $t->detach; + undef $t; if ($active == 1) { HexChat::hook_timer( 100, sub { return REMOVE if ($active == 0); return KEEP; } ); @@ -53,6 +61,9 @@ sub hookfn { } } + @words = -1; undef @words; + undef $nick; undef $text; undef $modechar; + return HexChat::EAT_NONE; } @@ -70,9 +81,11 @@ sub cdlfunc($) { } dlfunc($url, $savepath); + undef $savepath; } $active = 0; + undef $url; undef $extension; } sub dlfunc(@) { @@ -93,9 +106,11 @@ sub dlfunc(@) { $rename = 0 if (($format =~ /^PNG/) and ($file =~ /png$/i)); rename $file, sprintf("%s.%s", $file, lc($format)) if ($rename == 1); } + + undef $im; undef $rename; } - return 0; + undef $url; undef $file; } sub is_picture($) { @@ -104,6 +119,11 @@ sub is_picture($) { my $r = undef; $r = `$wgetpath --no-check-certificate -q --method=HEAD -S --timeout=5 "$url" 2>&1`; + undef $url; + + if ($? != 0) { + return undef; + } foreach (split(/\n/, $r)) { next unless($_ =~ /Content\-Type: (.+)/); @@ -112,14 +132,17 @@ sub is_picture($) { } if (defined($r)) { - if ($r =~ /^image\/gif/) {return 'gif';}; - if ($r =~ /^image\/jpe?g/){return 'jpeg';}; - if ($r =~ /^image\/png/) {return 'png';}; - if ($r =~ /^video\/webm/) {return 'webm';}; - if ($r =~ /^video\/mp4/) {return 'mp4';}; + if ($r =~ /^image\/gif/) { $r = 'gif'; } + elsif ($r =~ /^image\/jpe?g/){ $r = 'jpeg';} + elsif ($r =~ /^image\/png/) { $r = 'png'; } + elsif ($r =~ /^video\/webm/) { $r = 'webm';} + elsif ($r =~ /^video\/mp4/) { $r = 'mp4'; } + else { $r = undef; } + } else { + $r = undef; } - return undef; + return $r; } sub urlencode($) { diff --git a/notifications.pl b/notifications.pl index 4a2670e..9086b5d 100644 --- a/notifications.pl +++ b/notifications.pl @@ -23,7 +23,7 @@ my $help = 'Usage: /notify show - shows whitelists and their statuses '; -register($script_name, '0.7.1', 'Sends *nix desktop notifications', \&freehooks); +register($script_name, '0.7.2', 'Sends *nix desktop notifications', \&freehooks); HexChat::print("$script_name loaded\n"); my @hooks; @@ -31,7 +31,7 @@ push @hooks, hook_print('Channel Message', \&hookfn); push @hooks, hook_print('Channel Msg Hilight', \&hookfn); push @hooks, hook_print('Channel Action', \&hookfn); push @hooks, hook_print('Channel Action Hilight', \&hookfn); -push @hooks, hook_command 'notify', \¬ify_cmd, { 'help_text' => $help }; +push @hooks, hook_command('notify', \¬ify_cmd); my $active = 0; share($active); @@ -91,7 +91,7 @@ sub hookfn { my $t = undef; do { - $t = threads->create(\¬ify, $topic, $text); + $t = threads->create('notify', $topic, $text); sleep 1 unless(defined($t)); } unless (defined($t)); @@ -101,6 +101,11 @@ sub hookfn { hook_timer( 500, \&timeraction); } + undef $nick; undef $text; undef $modechar; + undef $channel; undef $network; + undef $flag; + undef $nicklist; undef $chanlist; undef $netlist; + return EAT_NONE; } @@ -108,6 +113,7 @@ sub notify(@) { my($topic, $text) = @_; system("notify-send", "-u", "normal", "-t", "12000", "-a", "hexchat", $topic, "-i", "hexchat", $text); $active = 0; + undef $topic; undef $text; } sub timeraction { @@ -318,11 +324,13 @@ sub notify_cmd { sub loadliststatus($){ my $listtype = shift; my $list = HexChat::plugin_pref_get($listtype); + unless (defined($list)) { savesetting('list', '0'); $list = 0; } + undef $listtype; return $list; } @@ -335,6 +343,7 @@ sub loadlist($){ $val = ''; } + undef $setting; return $val; } @@ -347,6 +356,7 @@ sub savesetting(@) { return undef; } + undef $setting; return 1; }