Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[scriptassist] update to 2023111700 #862

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions scripts/scriptassist.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use strict;

our $VERSION = '2023091200';
our $VERSION = '2023111700';

Check warning on line 8 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Code before warnings are enabled
our %IRSSI = (
authors => 'Stefan \'tommie\' Tomanek',
contact => '[email protected]',
Expand All @@ -29,7 +29,7 @@

# GnuPG is not always needed
$have_gpg = 0;
eval "use GnuPG qw(:algo :trust);";

Check warning on line 32 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Expression form of "eval"
$have_gpg = 1 if not ($@);

my $irssi_version = qv('v'.Irssi::parse_special('$J') =~ s/[^.\d].*//r);
Expand Down Expand Up @@ -96,7 +96,7 @@
sub call_openurl {
my ($url) = @_;
# check for a loaded openurl
if (my $code = Irssi::Script::openurl::->can('launch_url')) {

Check warning on line 99 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Bareword "Irssi::Script::openurl::" refers to nonexistent package
$code->($url);
} else {
print CLIENTCRAP "%R>>%n Please install openurl.pl";
Expand All @@ -116,7 +116,7 @@
$forked = 1;
if ($pid > 0) {
print CLIENTCRAP "%R>>%n Please wait...";
close $wh;

Check warning on line 119 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Return value of "close" ignored
Irssi::pidwait_add($pid);
my $pipetag;
my @args = ($rh, \$pipetag, $func);
Expand Down Expand Up @@ -184,7 +184,7 @@
print($wh CPAN::Meta::YAML->new(+{data=>+{error=>$@}})
->write_string());
}
close($wh);

Check warning on line 187 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Return value of "close" ignored
POSIX::_exit(1);
}
}
Expand Down Expand Up @@ -216,7 +216,7 @@
my $dir = Irssi::get_irssi_dir()."/scripts/";
if ($db && exists $db->{$plname}) {
# $found = 1;
} elsif (-e $dir.$plname || -e $dir."autorun/".$plname) {

Check warning on line 219 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Mismatched operator

Check warning on line 219 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Mismatched operator
# $found = 1;
} else {
# not found
Expand Down Expand Up @@ -327,7 +327,7 @@
my $modules = $n->{db}{modules};
foreach my $mod (split(/ /, $modules)) {
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
$mod = $1 if $1;

Check warning on line 330 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Capture variable used outside conditional

Check warning on line 330 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Capture variable used outside conditional
$r{modules}{$mod}{optional} = $opt;
$r{modules}{$mod}{installed} = module_exist($mod);
}
Expand All @@ -335,7 +335,7 @@
my $modules = $n->{irssi}{modules};
foreach my $mod (split(/ /, $modules)) {
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
$mod = $1 if $1;

Check warning on line 338 in scripts/scriptassist.pl

View workflow job for this annotation

GitHub Actions / test

Capture variable used outside conditional
$r{modules}{$mod}{optional} = $opt;
$r{modules}{$mod}{installed} = module_exist($mod);
}
Expand All @@ -356,6 +356,8 @@

sub get_rate_url {
my ($src) = @_;
if (ref $src) { ($src) = grep { $_ } map { $_->{source} } values %$src; }
die("No script source address found\n") unless $src;
my $ua = LWP::UserAgent->new(env_proxy=>1, keep_alive=>1, timeout=>30);
$ua->agent('ScriptAssist/'.$VERSION);
my $request = HTTP::Request->new('GET', $src);
Expand All @@ -364,6 +366,9 @@
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
die("Fetching ratings location failed: $error");
}
if (my $error = $response->header('X-Died')) {
die("$error\n");
}
my $votes_url;
for my $tag ($response->content() =~ /<script([^>]*)>/g) {
my $attr = " $tag ";
Expand All @@ -375,7 +380,7 @@
}
$request = HTTP::Request->new('GET', $votes_url);
$response = $ua->request($request);
if (!$response->is_success) {
if (!$response->is_success || $response->header('X-Died')) {
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
die("Fetching ratings failed: $error");
}
Expand All @@ -387,7 +392,7 @@
sub rate_script {
my ($script, $stars) = @_;
my $xml = get_scripts();
my $votes = get_rate_url(map { $_->{source} } values %$xml);
my $votes = get_rate_url($xml);
my $n = get_names($script, $xml, $votes);
die "Script $script not found\n" unless $n->{votes};
return $n->{votes}{u}
Expand All @@ -396,7 +401,7 @@
sub get_ratings {
my ($scripts, $limit) = @_;
my $xml = get_scripts();
my $votes = get_rate_url(map { $_->{source} } values %$xml);
my $votes = get_rate_url($xml);
foreach (keys %{$votes}) {
if ($xml->{$_}) {
$xml->{$_}{votes} = $votes->{$_}{v};
Expand Down Expand Up @@ -968,6 +973,10 @@
$error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
next;
}
if (my $died = $response->header('X-Died')) {
$error = $died;
next;
}
$fetched = 1;
my $data = $response->content();
my $src = $site;
Expand Down Expand Up @@ -1117,7 +1126,7 @@
$ua->agent('ScriptAssist/'.2003020803);
my $request = HTTP::Request->new('GET', $site.'/scripts/'.$n->{plname});
my $response = $ua->request($request);
if ($response->is_success()) {
if ($response->is_success() && !$response->header('X-Died')) {
my $file = $response->content();
mkdir $dir.'/scripts/' unless (-e $dir.'/scripts/');
open(my $f, '>', $dir.'/scripts/'.$n->{plname}.'.new');
Expand All @@ -1128,7 +1137,7 @@
$ua->agent('ScriptAssist/'.2003020803);
my $request2 = HTTP::Request->new('GET', $site.'/signatures/'.$n->{plname}.'.asc');
my $response2 = $ua->request($request2);
if ($response2->is_success()) {
if ($response2->is_success() && !$response->header('X-Died')) {
my $sig_dir = $dir.'/scripts/signatures/';
mkdir $sig_dir unless (-e $sig_dir);
open(my $s, '>', $sig_dir.$n->{plname}.'.asc');
Expand Down