Skip to content
Open
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: 18 additions & 3 deletions scripts/scriptassist.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use strict;

our $VERSION = '2023111700';
our $VERSION = '2026090900';

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 => 'stefan@pico.ruhr.de',
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 Down Expand Up @@ -1307,10 +1307,24 @@
}
}

# Track if we are in the default command handler, so we can only run the
# unknown command search if "error command" is invoked within it. This avoids
# needing to implement logic to deal with window_number_commands, etc. and
# doesn't result in trying to find a script for an unknown subcommand like
# "/window foo".
my $in_default = 0;

sub sig_default_command {
my ($cmd, $server) = @_;
$in_default = 1;
Irssi::signal_continue(@_);
$in_default = 0;
}

sub sig_error_command {
my ($id, $cmd, $server) = @_;
return unless $id == 0; # CMDERR_UNKNOWN
return unless $in_default;
return unless Irssi::settings_get_bool("scriptassist_check_unknown_commands");
return if ($cmd =~ /^\d+$/ && $irssi_version >= v1.2.0 && Irssi::settings_get_bool("window_number_commands"));
bg_do('unknown '.$cmd);
}

Expand Down Expand Up @@ -1344,6 +1358,7 @@
Irssi::settings_add_bool($IRSSI{name}, 'scriptassist_check_unknown_commands', 1);

Irssi::signal_add_first("default command", 'sig_default_command');
Irssi::signal_add_last("error command", 'sig_error_command');
Irssi::signal_add_first('complete word', 'sig_complete');
Irssi::signal_add_first('command script load', 'sig_command_script_load');
Irssi::signal_add_first('command script unload', 'sig_command_script_load');
Expand Down
Loading