mirror of
https://github.com/irssi/irssi.git
synced 2026-08-19 16:42:30 +02:00
run syncscripts.sh
autoop 1.10 -> 1.11 mail 2.92 -> 2.93 scriptassist 2022053100 -> 2023111700
This commit is contained in:
parent
6c72dc14fa
commit
d145f24c22
3 changed files with 265 additions and 144 deletions
|
|
@ -5,7 +5,7 @@ use Irssi;
|
||||||
use strict;
|
use strict;
|
||||||
use vars qw($VERSION %IRSSI);
|
use vars qw($VERSION %IRSSI);
|
||||||
|
|
||||||
$VERSION = "1.10";
|
$VERSION = "1.11";
|
||||||
%IRSSI = (
|
%IRSSI = (
|
||||||
authors => 'Timo Sirainen & Jostein Kjønigsen',
|
authors => 'Timo Sirainen & Jostein Kjønigsen',
|
||||||
name => 'autoop',
|
name => 'autoop',
|
||||||
|
|
@ -98,10 +98,11 @@ sub load_autoops {
|
||||||
%opnicks = ();
|
%opnicks = ();
|
||||||
open(CONF, "<", "$file") or return;
|
open(CONF, "<", "$file") or return;
|
||||||
while (my $line = <CONF>) {
|
while (my $line = <CONF>) {
|
||||||
if ($line !=~ /^\s*$/) {
|
chomp($line);
|
||||||
cmd_autoop($line);
|
if ($line !~ /^\s*$/) {
|
||||||
$count++;
|
cmd_autoop($line);
|
||||||
}
|
$count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close(CONF);
|
close(CONF);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use strict;
|
use strict;
|
||||||
use vars qw($VERSION %IRSSI);
|
use vars qw($VERSION %IRSSI);
|
||||||
$VERSION = "2.92";
|
$VERSION = "2.93";
|
||||||
%IRSSI = (
|
%IRSSI = (
|
||||||
authors => "Timo Sirainen, Matti Hiljanen, Joost Vunderink, Bart Matthaei",
|
authors => "Timo Sirainen, Matti Hiljanen, Joost Vunderink, Bart Matthaei",
|
||||||
contact => "tss\@iki.fi, matti\@hiljanen.com, joost\@carnique.nl, bart\@dreamflow.nl",
|
contact => "tss\@iki.fi, matti\@hiljanen.com, joost\@carnique.nl, bart\@dreamflow.nl",
|
||||||
|
|
@ -63,8 +63,8 @@ sub cmd_print_help {
|
||||||
"/MAILBOX SHOW\n".
|
"/MAILBOX SHOW\n".
|
||||||
" - Shows a list of the defined mailboxes.\n\n".
|
" - Shows a list of the defined mailboxes.\n\n".
|
||||||
"Use the following commands to change the behaviour:\n\n".
|
"Use the following commands to change the behaviour:\n\n".
|
||||||
"/SET MAILDIRMODE on|off\n".
|
"/SET MAILDIR_MODE on|off\n".
|
||||||
" - If maildirmode is on, the mailboxes in the list are assumed to be ".
|
" - If maildir_mode is on, the mailboxes in the list are assumed to be ".
|
||||||
"directories. Otherwise they are assumed to be spool files.\n".
|
"directories. Otherwise they are assumed to be spool files.\n".
|
||||||
" Default: off.\n".
|
" Default: off.\n".
|
||||||
"/SET MAIL_OLDNOTNEW on|off\n".
|
"/SET MAIL_OLDNOTNEW on|off\n".
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
our $VERSION = '2022053100';
|
our $VERSION = '2023111700';
|
||||||
our %IRSSI = (
|
our %IRSSI = (
|
||||||
authors => 'Stefan \'tommie\' Tomanek',
|
authors => 'Stefan \'tommie\' Tomanek',
|
||||||
contact => 'stefan@pico.ruhr.de',
|
contact => 'stefan@pico.ruhr.de',
|
||||||
|
|
@ -22,6 +22,8 @@ our ($forked, %remote_db, $have_gpg, @complist);
|
||||||
use Irssi 20020324;
|
use Irssi 20020324;
|
||||||
use CPAN::Meta::YAML;
|
use CPAN::Meta::YAML;
|
||||||
use LWP::UserAgent;
|
use LWP::UserAgent;
|
||||||
|
use Hash::Util qw(lock_ref_keys);
|
||||||
|
use JSON::PP;
|
||||||
use POSIX;
|
use POSIX;
|
||||||
use version;
|
use version;
|
||||||
|
|
||||||
|
|
@ -43,7 +45,7 @@ sub show_help {
|
||||||
/scriptassist info <scripts>
|
/scriptassist info <scripts>
|
||||||
Display information about <scripts>
|
Display information about <scripts>
|
||||||
/scriptassist ratings <scripts|all>
|
/scriptassist ratings <scripts|all>
|
||||||
Retrieve the average ratings of the the scripts
|
Retrieve the average ratings of the scripts
|
||||||
/scriptassist top <num>
|
/scriptassist top <num>
|
||||||
Retrieve the first <num> top rated scripts
|
Retrieve the first <num> top rated scripts
|
||||||
/scriptassist new <num>
|
/scriptassist new <num>
|
||||||
|
|
@ -199,87 +201,163 @@ sub get_unknown {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_names {
|
sub get_names {
|
||||||
my ($sname, $db) = shift;
|
my ($sname, $db, $votes) = @_;
|
||||||
$sname =~ s/\s+$//;
|
$sname =~ s/\s+$//;
|
||||||
$sname =~ s/\.pl$//;
|
my $ext = 'pl'; # default extension
|
||||||
my $plname = "$sname.pl";
|
if ($sname =~ s/\.(\w{2,3})$//) {
|
||||||
|
$ext = $1;
|
||||||
|
}
|
||||||
|
my $plname = "$sname.$ext";
|
||||||
$sname =~ s/^.*\///;
|
$sname =~ s/^.*\///;
|
||||||
my $xname = $sname;
|
my $xname = $sname;
|
||||||
$xname =~ s/\W/_/g;
|
$xname =~ s/\W/_/g;
|
||||||
my $pname = "${xname}::";
|
my $pname = "${xname}::";
|
||||||
if ($xname ne $sname || $sname =~ /_/) {
|
if ($xname ne $sname || $sname =~ /_/) {
|
||||||
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
||||||
if ($db && exists $db->{"$sname.pl"}) {
|
if ($db && exists $db->{$plname}) {
|
||||||
# $found = 1;
|
# $found = 1;
|
||||||
} elsif (-e $dir.$plname || -e $dir."$sname.pl" || -e $dir."autorun/$sname.pl") {
|
} elsif (-e $dir.$plname || -e $dir."autorun/".$plname) {
|
||||||
# $found = 1;
|
# $found = 1;
|
||||||
} else {
|
} else {
|
||||||
# not found
|
# not found
|
||||||
my $pat = $xname; $pat =~ y/_/?/;
|
my $pat = $xname; $pat =~ y/_/?/;
|
||||||
my $re = "\Q$xname"; $re =~ s/\Q_/./g;
|
my $re = "\Q$xname"; $re =~ s/\Q_/./g;
|
||||||
if ($db) {
|
if ($db) {
|
||||||
my ($cand) = grep /^$re\.pl$/, sort keys %$db;
|
my ($cand) = grep /^$re\.\Q$ext\E$/, sort keys %$db;
|
||||||
if ($cand) {
|
if ($cand) {
|
||||||
return get_names($cand, $db);
|
return get_names($cand, $db, $votes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my ($cand) = glob "'$dir$pat.pl' '${dir}autorun/$pat.pl'";
|
my ($cand) = glob "'$dir$pat.$ext' '${dir}autorun/$pat.$ext'";
|
||||||
if ($cand) {
|
if ($cand) {
|
||||||
$cand =~ s/^.*\///;
|
$cand =~ s/^.*\///;
|
||||||
return get_names($cand, $db);
|
return get_names($cand, $db, $votes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
($sname, $plname, $pname, $xname)
|
my ($script_stash, $script_irssi, $script_db, $local_version);
|
||||||
|
$script_db = $db->{$plname} if $db && exists $db->{$plname};
|
||||||
|
if (lc $ext eq 'pl') {
|
||||||
|
$script_stash = $Irssi::Script::{$pname};
|
||||||
|
}
|
||||||
|
elsif (lc $ext eq 'py' && is_python_loaded()) {
|
||||||
|
my $filename;
|
||||||
|
capture_print_text_command(
|
||||||
|
'py list',
|
||||||
|
sub {
|
||||||
|
for my $line (@_[ 1 .. $#_ ]) {
|
||||||
|
my ($script, $fn) = split ' ', $line, 2;
|
||||||
|
if ($script eq $sname) {
|
||||||
|
$filename = $fn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (defined $filename) {
|
||||||
|
my $filename_quoted = $filename;
|
||||||
|
$filename_quoted =~ s/[\\']/\\$&/g;
|
||||||
|
capture_print_text_command(
|
||||||
|
# make sure the command line stays short
|
||||||
|
'py exec ' .
|
||||||
|
(join ';', split /\n/, <<PYTHON
|
||||||
|
import ast as A, types as _, json
|
||||||
|
i = 'IRSSI'
|
||||||
|
v = '__version__'
|
||||||
|
T = isinstance
|
||||||
|
f = '$filename_quoted'
|
||||||
|
a = lambda _: T(_, A.Assign)
|
||||||
|
n = lambda _: T(_, A.Name)
|
||||||
|
y = lambda _: _.id
|
||||||
|
t = lambda _: list(map(y, filter(n, _.targets)))
|
||||||
|
C = lambda e: lambda _: a(_) and t(_) == [e]
|
||||||
|
O = _.SimpleNamespace(value=A.Constant(None))
|
||||||
|
P = A.parse(open(f).read(), filename=f)
|
||||||
|
f = lambda e: A.literal_eval(next(filter(C(e), P.body), O).value)
|
||||||
|
print(json.dumps({ i: f(i), v: f(v) }))
|
||||||
|
PYTHON
|
||||||
|
),
|
||||||
|
sub {
|
||||||
|
eval {
|
||||||
|
my $doc = decode_json("@_");
|
||||||
|
$script_stash = { IRSSI => $doc->{IRSSI}, VERSION => \($doc->{__version__}) };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (defined $script_stash) {
|
||||||
|
$script_irssi = $script_stash->{IRSSI};
|
||||||
|
$local_version = ${$script_stash->{VERSION}}
|
||||||
|
if $script_stash->{VERSION};
|
||||||
|
}
|
||||||
|
lock_ref_keys({
|
||||||
|
sname => $ext eq 'pl' ? $sname : $plname,
|
||||||
|
plname => $plname,
|
||||||
|
pname => $pname,
|
||||||
|
xname => $xname,
|
||||||
|
stash => $script_stash,
|
||||||
|
irssi => $script_irssi,
|
||||||
|
db => $script_db,
|
||||||
|
db_version => ($script_db ? $script_db->{version} : undef),
|
||||||
|
local_version => $local_version,
|
||||||
|
($votes ? (votes => $votes->{$plname}) : ()),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
sub script_info {
|
sub script_info {
|
||||||
my ($scripts) = @_;
|
my ($scripts) = @_;
|
||||||
my %result;
|
my %result;
|
||||||
my $xml = get_scripts();
|
my $xml = get_scripts();
|
||||||
|
my $py = is_python_loaded();
|
||||||
foreach (@{$scripts}) {
|
foreach (@{$scripts}) {
|
||||||
my ($sname, $plname, $pname) = get_names($_, $xml);
|
my %r;
|
||||||
next unless (defined $xml->{$plname} || ( exists $Irssi::Script::{$pname} && exists $Irssi::Script::{$pname}{IRSSI} ));
|
my $n = get_names($_, $xml);
|
||||||
$result{$sname}{version} = get_remote_version($sname, $xml);
|
next unless (defined $n->{db} || defined $n->{irssi});
|
||||||
|
$r{version} = $n->{db_version};
|
||||||
my @headers = ('authors', 'contact', 'description', 'license', 'source');
|
my @headers = ('authors', 'contact', 'description', 'license', 'source');
|
||||||
foreach my $entry (@headers) {
|
foreach my $entry (@headers) {
|
||||||
$result{$sname}{$entry} = $Irssi::Script::{$pname}{IRSSI}{$entry};
|
$r{$entry} = $n->{irssi}{$entry};
|
||||||
if (defined $xml->{$plname}{$entry}) {
|
if ($n->{db} && defined $n->{db}{$entry}) {
|
||||||
$result{$sname}{$entry} = $xml->{$plname}{$entry};
|
$r{$entry} = $n->{db}{$entry};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($xml->{$plname}{signature_available}) {
|
if ($n->{db} && $n->{db}{signature_available}) {
|
||||||
$result{$sname}{signature_available} = 1;
|
$r{signature_available} = 1;
|
||||||
}
|
}
|
||||||
if (defined $xml->{$plname}{modules}) {
|
if ($n->{db} && defined $n->{db}{modules}) {
|
||||||
my $modules = $xml->{$plname}{modules};
|
my $modules = $n->{db}{modules};
|
||||||
foreach my $mod (split(/ /, $modules)) {
|
foreach my $mod (split(/ /, $modules)) {
|
||||||
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
|
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
|
||||||
$mod = $1 if $1;
|
$mod = $1 if $1;
|
||||||
$result{$sname}{modules}{$mod}{optional} = $opt;
|
$r{modules}{$mod}{optional} = $opt;
|
||||||
$result{$sname}{modules}{$mod}{installed} = module_exist($mod);
|
$r{modules}{$mod}{installed} = module_exist($mod);
|
||||||
}
|
}
|
||||||
} elsif (defined $Irssi::Script::{$pname}{IRSSI}{modules}) {
|
} elsif ($n->{irssi} && defined $n->{irssi}{modules}) {
|
||||||
my $modules = $Irssi::Script::{$pname}{IRSSI}{modules};
|
my $modules = $n->{irssi}{modules};
|
||||||
foreach my $mod (split(/ /, $modules)) {
|
foreach my $mod (split(/ /, $modules)) {
|
||||||
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
|
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
|
||||||
$mod = $1 if $1;
|
$mod = $1 if $1;
|
||||||
$result{$sname}{modules}{$mod}{optional} = $opt;
|
$r{modules}{$mod}{optional} = $opt;
|
||||||
$result{$sname}{modules}{$mod}{installed} = module_exist($mod);
|
$r{modules}{$mod}{installed} = module_exist($mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# if (defined $xml->{$plname}{depends}) {
|
if (!$py && $n->{db} && $n->{db}{language} eq 'Python') { # py
|
||||||
# my $depends = $xml->{$plname}{depends};
|
$r{modules}{'irssi-python module'}{installed} = 0;
|
||||||
|
}
|
||||||
|
# if (defined $n->{db}{depends}) {
|
||||||
|
# my $depends = $n->{db}{depends};
|
||||||
# foreach my $dep (split(/ /, $depends)) {
|
# foreach my $dep (split(/ /, $depends)) {
|
||||||
# $result{$sname}{depends}{$dep}{installed} = 1; #(defined ${ 'Irssi::Script::'.$dep });
|
# $r{depends}{$dep}{installed} = 1; #(defined ${ 'Irssi::Script::'.$dep });
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
|
$result{$n->{sname}} = \%r;
|
||||||
}
|
}
|
||||||
return \%result;
|
return \%result;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_rate_url {
|
sub get_rate_url {
|
||||||
my ($src) = @_;
|
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);
|
my $ua = LWP::UserAgent->new(env_proxy=>1, keep_alive=>1, timeout=>30);
|
||||||
$ua->agent('ScriptAssist/'.$VERSION);
|
$ua->agent('ScriptAssist/'.$VERSION);
|
||||||
my $request = HTTP::Request->new('GET', $src);
|
my $request = HTTP::Request->new('GET', $src);
|
||||||
|
|
@ -288,6 +366,9 @@ sub get_rate_url {
|
||||||
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
|
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
|
||||||
die("Fetching ratings location failed: $error");
|
die("Fetching ratings location failed: $error");
|
||||||
}
|
}
|
||||||
|
if (my $error = $response->header('X-Died')) {
|
||||||
|
die("$error\n");
|
||||||
|
}
|
||||||
my $votes_url;
|
my $votes_url;
|
||||||
for my $tag ($response->content() =~ /<script([^>]*)>/g) {
|
for my $tag ($response->content() =~ /<script([^>]*)>/g) {
|
||||||
my $attr = " $tag ";
|
my $attr = " $tag ";
|
||||||
|
|
@ -299,7 +380,7 @@ sub get_rate_url {
|
||||||
}
|
}
|
||||||
$request = HTTP::Request->new('GET', $votes_url);
|
$request = HTTP::Request->new('GET', $votes_url);
|
||||||
$response = $ua->request($request);
|
$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()), '';
|
my $error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
|
||||||
die("Fetching ratings failed: $error");
|
die("Fetching ratings failed: $error");
|
||||||
}
|
}
|
||||||
|
|
@ -311,16 +392,16 @@ sub get_rate_url {
|
||||||
sub rate_script {
|
sub rate_script {
|
||||||
my ($script, $stars) = @_;
|
my ($script, $stars) = @_;
|
||||||
my $xml = get_scripts();
|
my $xml = get_scripts();
|
||||||
my $votes = get_rate_url(map { $_->{source} } values %$xml);
|
my $votes = get_rate_url($xml);
|
||||||
my ($sname, $plname, $pname) = get_names($script, $xml);
|
my $n = get_names($script, $xml, $votes);
|
||||||
die "Script $script not found\n" unless $votes->{$plname};
|
die "Script $script not found\n" unless $n->{votes};
|
||||||
return $votes->{$plname}{u}
|
return $n->{votes}{u}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_ratings {
|
sub get_ratings {
|
||||||
my ($scripts, $limit) = @_;
|
my ($scripts, $limit) = @_;
|
||||||
my $xml = get_scripts();
|
my $xml = get_scripts();
|
||||||
my $votes = get_rate_url(map { $_->{source} } values %$xml);
|
my $votes = get_rate_url($xml);
|
||||||
foreach (keys %{$votes}) {
|
foreach (keys %{$votes}) {
|
||||||
if ($xml->{$_}) {
|
if ($xml->{$_}) {
|
||||||
$xml->{$_}{votes} = $votes->{$_}{v};
|
$xml->{$_}{votes} = $votes->{$_}{v};
|
||||||
|
|
@ -329,9 +410,9 @@ sub get_ratings {
|
||||||
my %result;
|
my %result;
|
||||||
if (@{$scripts}) {
|
if (@{$scripts}) {
|
||||||
foreach (@{$scripts}) {
|
foreach (@{$scripts}) {
|
||||||
my ($sname, $plname, $pname) = get_names($_, $xml);
|
my $n = get_names($_, $xml);
|
||||||
next unless (defined $xml->{$plname} || ( exists $Irssi::Script::{$pname} && exists $Irssi::Script::{$pname}{IRSSI} ));
|
next unless ($n->{db} || $n->{irssi});
|
||||||
$result{$plname} = [$xml->{$plname}{votes}];
|
$result{$n->{plname}} = [$n->{db}{votes}];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
my @keys = sort { $xml->{$b}{votes} <=> $xml->{$a}{votes}
|
my @keys = sort { $xml->{$b}{votes} <=> $xml->{$a}{votes}
|
||||||
|
|
@ -371,16 +452,22 @@ sub debug_scripts {
|
||||||
my ($scripts) = @_;
|
my ($scripts) = @_;
|
||||||
my %result;
|
my %result;
|
||||||
my $xml = get_scripts();
|
my $xml = get_scripts();
|
||||||
|
my $py = is_python_loaded();
|
||||||
foreach (@{$scripts}) {
|
foreach (@{$scripts}) {
|
||||||
my ($sname, $plname) = get_names($_, $xml);
|
my %r;
|
||||||
if (defined $xml->{$plname}{modules}) {
|
my $n = get_names($_, $xml);
|
||||||
my $modules = $xml->{$plname}{modules};
|
if ($n->{db} && defined $n->{db}{modules}) {
|
||||||
|
my $modules = $n->{db}{modules};
|
||||||
foreach my $mod (split(/ /, $modules)) {
|
foreach my $mod (split(/ /, $modules)) {
|
||||||
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
|
my $opt = ($mod =~ /\((.*)\)/)? 1 : 0;
|
||||||
$mod = $1 if $1;
|
$mod = $1 if $1;
|
||||||
$result{$sname}{$mod}{optional} = $opt;
|
$r{$mod}{optional} = $opt;
|
||||||
$result{$sname}{$mod}{installed} = module_exist($mod);
|
$r{$mod}{installed} = module_exist($mod);
|
||||||
}
|
}
|
||||||
|
$result{$n->{sname}} = \%r;
|
||||||
|
}
|
||||||
|
if (!$py && $n->{db} && $n->{db}{language} eq 'Python') { # py
|
||||||
|
$result{$n->{sname}}{'irssi-python module'}{installed} = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(\%result);
|
return(\%result);
|
||||||
|
|
@ -391,11 +478,11 @@ sub install_scripts {
|
||||||
my %success;
|
my %success;
|
||||||
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
||||||
foreach (@{$scripts}) {
|
foreach (@{$scripts}) {
|
||||||
my ($sname, $plname, $pname) = get_names($_, $xml);
|
my $n = get_names($_, $xml);
|
||||||
if (get_local_version($sname) && (-e $dir.$plname)) {
|
if ($n->{stash} && (-e $dir.$n->{plname})) {
|
||||||
$success{$sname}{installed} = -2;
|
$success{$n->{sname}}{installed} = -2;
|
||||||
} else {
|
} else {
|
||||||
$success{$sname} = download_script($sname, $xml);
|
$success{$n->{sname}} = download_script($n->{sname}, $xml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return \%success;
|
return \%success;
|
||||||
|
|
@ -406,24 +493,24 @@ sub update_scripts {
|
||||||
$list = loaded_scripts() if ($list->[0] eq "all" || scalar(@$list) == 0);
|
$list = loaded_scripts() if ($list->[0] eq "all" || scalar(@$list) == 0);
|
||||||
my %status;
|
my %status;
|
||||||
foreach (@{$list}) {
|
foreach (@{$list}) {
|
||||||
my ($sname) = get_names($_, $database);
|
my $n = get_names($_, $database);
|
||||||
my $local = get_local_version($sname);
|
my $local = $n->{local_version};
|
||||||
my $remote = get_remote_version($sname, $database);
|
my $remote = $n->{db_version};
|
||||||
next if $local eq '' || $remote eq '';
|
next if $local eq '' || $remote eq '';
|
||||||
if (compare_versions($local, $remote) eq "older") {
|
if (compare_versions($local, $remote) eq "older") {
|
||||||
$status{$sname} = download_script($sname, $database);
|
$status{$n->{sname}} = download_script($n->{sname}, $database);
|
||||||
} else {
|
} else {
|
||||||
$status{$sname}{installed} = -2;
|
$status{$n->{sname}}{installed} = -2;
|
||||||
}
|
}
|
||||||
$status{$sname}{remote} = $remote;
|
$status{$n->{sname}}{remote} = $remote;
|
||||||
$status{$sname}{local} = $local;
|
$status{$n->{sname}}{local} = $local;
|
||||||
}
|
}
|
||||||
return \%status;
|
return \%status;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub search_scripts {
|
sub search_scripts {
|
||||||
my ($query, $database) = @_;
|
my ($query, $database) = @_;
|
||||||
$query =~ s/\.pl\Z//;
|
$query =~ s/\.pl\Z//; # pl
|
||||||
my %result;
|
my %result;
|
||||||
foreach (sort keys %{$database}) {
|
foreach (sort keys %{$database}) {
|
||||||
my %entry = %{$database->{$_}};
|
my %entry = %{$database->{$_}};
|
||||||
|
|
@ -432,7 +519,7 @@ sub search_scripts {
|
||||||
$string .= $entry{description} if defined $entry{description};
|
$string .= $entry{description} if defined $entry{description};
|
||||||
if ($string =~ /$query/i) {
|
if ($string =~ /$query/i) {
|
||||||
my $name = $_;
|
my $name = $_;
|
||||||
$name =~ s/\.pl$//;
|
$name =~ s/\.pl$//; # pl
|
||||||
if (defined $entry{description}) {
|
if (defined $entry{description}) {
|
||||||
$result{$name}{desc} = $entry{description};
|
$result{$name}{desc} = $entry{description};
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -443,7 +530,7 @@ sub search_scripts {
|
||||||
} else {
|
} else {
|
||||||
$result{$name}{authors} = "";
|
$result{$name}{authors} = "";
|
||||||
}
|
}
|
||||||
if (get_local_version($name)) {
|
if (get_names($name, $database)->{stash}) {
|
||||||
$result{$name}{installed} = 1;
|
$result{$name}{installed} = 1;
|
||||||
} else {
|
} else {
|
||||||
$result{$name}{installed} = 0;
|
$result{$name}{installed} = 0;
|
||||||
|
|
@ -531,8 +618,8 @@ sub print_unknown {
|
||||||
my $text .= "The command '/".$cmd."' is provided by the script '".$data->{$cmd}{$_}{name}."'.\n";
|
my $text .= "The command '/".$cmd."' is provided by the script '".$data->{$cmd}{$_}{name}."'.\n";
|
||||||
$text .= "This script is currently not installed on your system.\n";
|
$text .= "This script is currently not installed on your system.\n";
|
||||||
$text .= "If you want to install the script, enter\n";
|
$text .= "If you want to install the script, enter\n";
|
||||||
my ($name) = get_names($_);
|
my $n = get_names($_);
|
||||||
$text .= " %U/script install ".$name."%U ";
|
$text .= " %U/script install ".$n->{sname}."%U ";
|
||||||
my $output = draw_box("ScriptAssist", $text, "'".$_."' missing", 1);
|
my $output = draw_box("ScriptAssist", $text, "'".$_."' missing", 1);
|
||||||
print CLIENTCRAP $output;
|
print CLIENTCRAP $output;
|
||||||
}
|
}
|
||||||
|
|
@ -541,10 +628,10 @@ sub print_unknown {
|
||||||
|
|
||||||
sub check_autorun {
|
sub check_autorun {
|
||||||
my ($script) = @_;
|
my ($script) = @_;
|
||||||
my (undef, $plname) = get_names($script);
|
my $n = get_names($script);
|
||||||
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
||||||
if (-e $dir."/autorun/".$plname) {
|
if (-e $dir."/autorun/".$n->{plname}) {
|
||||||
if (readlink($dir."/autorun/".$plname) eq "../".$plname) {
|
if (readlink($dir."/autorun/".$n->{plname}) eq "../".$n->{plname}) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -582,14 +669,15 @@ sub print_info {
|
||||||
my $line;
|
my $line;
|
||||||
foreach my $script (sort keys(%data)) {
|
foreach my $script (sort keys(%data)) {
|
||||||
my ($local, $autorun);
|
my ($local, $autorun);
|
||||||
if (get_local_version($script)) {
|
my $n = get_names($script);
|
||||||
|
if ($n->{stash}) {
|
||||||
$line .= "%go%n ";
|
$line .= "%go%n ";
|
||||||
$local = get_local_version($script);
|
$local = $n->{local_version};
|
||||||
} else {
|
} else {
|
||||||
$line .= "%ro%n ";
|
$line .= "%ro%n ";
|
||||||
$local = undef;
|
$local = undef;
|
||||||
}
|
}
|
||||||
if (defined $local || check_autorun($script)) {
|
if ($n->{stash} || check_autorun($script)) {
|
||||||
$autorun = "no";
|
$autorun = "no";
|
||||||
$autorun = "yes" if check_autorun($script);
|
$autorun = "yes" if check_autorun($script);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -643,7 +731,7 @@ sub print_ratings {
|
||||||
my @table;
|
my @table;
|
||||||
foreach my $script (sort {$data{$b}{rating}<=>$data{$a}{rating}} keys(%data)) {
|
foreach my $script (sort {$data{$b}{rating}<=>$data{$a}{rating}} keys(%data)) {
|
||||||
my @line;
|
my @line;
|
||||||
if (get_local_version($script)) {
|
if (get_names($script)->{stash}) {
|
||||||
push @line, "%go%n";
|
push @line, "%go%n";
|
||||||
} else {
|
} else {
|
||||||
push @line, "%yo%n";
|
push @line, "%yo%n";
|
||||||
|
|
@ -660,13 +748,13 @@ sub print_new {
|
||||||
my @table;
|
my @table;
|
||||||
foreach (sort {$list->{$b}{modified} cmp $list->{$a}{modified}} keys %$list) {
|
foreach (sort {$list->{$b}{modified} cmp $list->{$a}{modified}} keys %$list) {
|
||||||
my @line;
|
my @line;
|
||||||
my ($name) = get_names($_);
|
my $n = get_names($_);
|
||||||
if (get_local_version($name)) {
|
if ($n->{stash}) {
|
||||||
push @line, "%go%n";
|
push @line, "%go%n";
|
||||||
} else {
|
} else {
|
||||||
push @line, "%yo%n";
|
push @line, "%yo%n";
|
||||||
}
|
}
|
||||||
push @line, "%9".$name."%9";
|
push @line, "%9".$n->{sname}."%9";
|
||||||
push @line, $list->{$_}{modified};
|
push @line, $list->{$_}{modified};
|
||||||
push @table, \@line;
|
push @table, \@line;
|
||||||
}
|
}
|
||||||
|
|
@ -678,14 +766,23 @@ sub print_debug {
|
||||||
my $line;
|
my $line;
|
||||||
foreach my $script (sort keys %data) {
|
foreach my $script (sort keys %data) {
|
||||||
$line .= "%ro%n %9".$script."%9 failed to load\n";
|
$line .= "%ro%n %9".$script."%9 failed to load\n";
|
||||||
$line .= " Make sure you have the following perl modules installed:\n";
|
my $py = $data{$script}{'irssi-python module'};
|
||||||
|
if ($py) { # py
|
||||||
|
$line .= " You are attempting to load a Python script!\n";
|
||||||
|
} else {
|
||||||
|
$line .= " Make sure you have the following perl modules installed:\n";
|
||||||
|
}
|
||||||
foreach (sort keys %{$data{$script}}) {
|
foreach (sort keys %{$data{$script}}) {
|
||||||
if ( $data{$script}{$_}{installed} == 1 ) {
|
if ( $data{$script}{$_}{installed} == 1 ) {
|
||||||
$line .= " %g->%n ".$_." (found)";
|
$line .= " %g->%n ".$_." (found)";
|
||||||
} else {
|
} else {
|
||||||
$line .= " %r->%n ".$_." (not found)\n";
|
$line .= " %r->%n ".$_." (not found)\n";
|
||||||
$line .= " [This module is optional]\n" if $data{$script}{$_}{optional};
|
$line .= " [This module is optional]\n" if $data{$script}{$_}{optional};
|
||||||
$line .= " [Try /scriptassist cpan ".$_."]";
|
if ($py) { # py
|
||||||
|
$line .= " [If you have it installed, try: /load python]";
|
||||||
|
} else {
|
||||||
|
$line .= " [Try /scriptassist cpan ".$_."]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$line .= "\n";
|
$line .= "\n";
|
||||||
}
|
}
|
||||||
|
|
@ -695,7 +792,13 @@ sub print_debug {
|
||||||
|
|
||||||
sub load_script {
|
sub load_script {
|
||||||
my ($script) = @_;
|
my ($script) = @_;
|
||||||
Irssi::command('script load '.$script);
|
if ($script =~ s/\.py$//i) { # py
|
||||||
|
if (is_python_loaded()) {
|
||||||
|
Irssi::command('py load '.$script);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Irssi::command('script load '.$script); # pl
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub print_install {
|
sub print_install {
|
||||||
|
|
@ -715,7 +818,7 @@ sub print_install {
|
||||||
} else {
|
} else {
|
||||||
load_script($script) unless (lc($script) eq lc($IRSSI{name}));
|
load_script($script) unless (lc($script) eq lc($IRSSI{name}));
|
||||||
}
|
}
|
||||||
if (get_local_version($script) && not lc($script) eq lc($IRSSI{name})) {
|
if (get_names($script)->{stash} && not lc($script) eq lc($IRSSI{name})) {
|
||||||
$line .= "%go%n %9".$script."%9 installed\n";
|
$line .= "%go%n %9".$script."%9 installed\n";
|
||||||
push @installed, $script;
|
push @installed, $script;
|
||||||
} elsif (lc($script) eq lc($IRSSI{name})) {
|
} elsif (lc($script) eq lc($IRSSI{name})) {
|
||||||
|
|
@ -751,16 +854,14 @@ sub list_sbitems {
|
||||||
my ($scripts) = @_;
|
my ($scripts) = @_;
|
||||||
my $text;
|
my $text;
|
||||||
foreach (@$scripts) {
|
foreach (@$scripts) {
|
||||||
next unless exists $Irssi::Script::{"${_}::"};
|
my $n = get_names($_);
|
||||||
next unless exists $Irssi::Script::{"${_}::"}{IRSSI};
|
next unless $n->{irssi}{sbitems};
|
||||||
my $header = $Irssi::Script::{"${_}::"}{IRSSI};
|
|
||||||
next unless $header->{sbitems};
|
|
||||||
$text .= '%9"'.$_.'"%9 provides the following statusbar item(s):'."\n";
|
$text .= '%9"'.$_.'"%9 provides the following statusbar item(s):'."\n";
|
||||||
$text .= ' ->'.$_."\n" foreach (split / /, $header->{sbitems});
|
$text .= ' ->'.$_."\n" foreach (split / /, $n->{irssi}{sbitems});
|
||||||
}
|
}
|
||||||
return unless $text;
|
return unless $text;
|
||||||
$text .= "\n";
|
$text .= "\n";
|
||||||
$text .= "Enter '/statusbar window add <item>' to add an item.";
|
$text .= "Enter '/statusbar additem <item> window' to add an item.";
|
||||||
print CLIENTCRAP draw_box('ScriptAssist', $text, 'sbitems', 1);
|
print CLIENTCRAP draw_box('ScriptAssist', $text, 'sbitems', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -838,14 +939,12 @@ sub print_update {
|
||||||
|
|
||||||
sub contact_author {
|
sub contact_author {
|
||||||
my ($script) = @_;
|
my ($script) = @_;
|
||||||
my ($sname, $plname, $pname) = get_names($script);
|
my $n = get_names($script);
|
||||||
return unless exists $Irssi::Script::{$pname};
|
if ($n->{irssi} && defined $n->{irssi}{contact}) {
|
||||||
my $header = $Irssi::Script::{$pname}{IRSSI};
|
my @ads = split(/ |,/, $n->{irssi}{contact});
|
||||||
if ($header && defined $header->{contact}) {
|
|
||||||
my @ads = split(/ |,/, $header->{contact});
|
|
||||||
my $address = $ads[0];
|
my $address = $ads[0];
|
||||||
$address .= '?subject='.$script;
|
$address .= '?subject='.$script;
|
||||||
$address .= '_'.get_local_version($script) if defined get_local_version($script);
|
$address .= '_'.$n->{local_version} if $n->{local_version};
|
||||||
call_openurl($address) if $address =~ /[\@:]/;
|
call_openurl($address) if $address =~ /[\@:]/;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -874,6 +973,10 @@ sub get_scripts {
|
||||||
$error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
|
$error = join "\n", $response->status_line(), (grep / at .* line \d+/, split "\n", $response->content()), '';
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
if (my $died = $response->header('X-Died')) {
|
||||||
|
$error = $died;
|
||||||
|
next;
|
||||||
|
}
|
||||||
$fetched = 1;
|
$fetched = 1;
|
||||||
my $data = $response->content();
|
my $data = $response->content();
|
||||||
my $src = $site;
|
my $src = $site;
|
||||||
|
|
@ -929,20 +1032,6 @@ sub get_scripts {
|
||||||
return $remote_db{db};
|
return $remote_db{db};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_remote_version {
|
|
||||||
my ($script, $database) = @_;
|
|
||||||
my $plname = (get_names($script, $database))[1];
|
|
||||||
return $database->{$plname}{version};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub get_local_version {
|
|
||||||
my ($script) = @_;
|
|
||||||
my $pname = (get_names($script))[2];
|
|
||||||
return unless exists $Irssi::Script::{$pname};
|
|
||||||
my $vref = $Irssi::Script::{$pname}{VERSION};
|
|
||||||
return $vref ? $$vref : undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub compare_versions {
|
sub compare_versions {
|
||||||
my ($ver1, $ver2) = @_;
|
my ($ver1, $ver2) = @_;
|
||||||
for ($ver1, $ver2) {
|
for ($ver1, $ver2) {
|
||||||
|
|
@ -959,11 +1048,42 @@ sub compare_versions {
|
||||||
return 'equal';
|
return 'equal';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub is_python_loaded {
|
||||||
|
!! grep { $_->{cmd} eq 'py' } Irssi::commands
|
||||||
|
}
|
||||||
|
|
||||||
|
my @print_text_capture;
|
||||||
|
sub capture_print_text {
|
||||||
|
my ($dest, $text, $plain) = @_;
|
||||||
|
push @print_text_capture, $plain;
|
||||||
|
Irssi::signal_stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub capture_print_text_command {
|
||||||
|
my ($command, $sub) = @_;
|
||||||
|
Irssi::signal_add_first('print text', 'capture_print_text');
|
||||||
|
@print_text_capture = ();
|
||||||
|
Irssi::command($command);
|
||||||
|
my @capture = @print_text_capture;
|
||||||
|
Irssi::signal_remove('print text', 'capture_print_text');
|
||||||
|
@print_text_capture = ();
|
||||||
|
$sub->(@capture);
|
||||||
|
}
|
||||||
|
|
||||||
sub loaded_scripts {
|
sub loaded_scripts {
|
||||||
my @modules;
|
my @modules;
|
||||||
foreach (sort grep(s/::$//, keys %Irssi::Script::)) {
|
foreach (sort grep(s/::$//, keys %Irssi::Script::)) { # pl
|
||||||
push @modules, $_;
|
push @modules, $_;
|
||||||
}
|
}
|
||||||
|
if (is_python_loaded()) {
|
||||||
|
capture_print_text_command(
|
||||||
|
'py list', sub {
|
||||||
|
for my $line (@_[ 1 .. $#_ ]) {
|
||||||
|
my ($script, $file) = split ' ', $line, 2;
|
||||||
|
push @modules, "$script.py";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return \@modules;
|
return \@modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -971,9 +1091,9 @@ sub check_scripts {
|
||||||
my ($data) = @_;
|
my ($data) = @_;
|
||||||
my %versions;
|
my %versions;
|
||||||
foreach (@{loaded_scripts()}) {
|
foreach (@{loaded_scripts()}) {
|
||||||
my ($sname) = get_names($_, $data);
|
my $n = get_names($_, $data);
|
||||||
my $remote = get_remote_version($sname, $data);
|
my $remote = $n->{db_version};
|
||||||
my $local = get_local_version($sname);
|
my $local = $n->{local_version};
|
||||||
my $state;
|
my $state;
|
||||||
if ($local && $remote) {
|
if ($local && $remote) {
|
||||||
$state = compare_versions($local, $remote);
|
$state = compare_versions($local, $remote);
|
||||||
|
|
@ -986,9 +1106,9 @@ sub check_scripts {
|
||||||
$remote = '/';
|
$remote = '/';
|
||||||
}
|
}
|
||||||
if ($state) {
|
if ($state) {
|
||||||
$versions{$sname}{state} = $state;
|
$versions{$n->{sname}}{state} = $state;
|
||||||
$versions{$sname}{remote} = $remote;
|
$versions{$n->{sname}}{remote} = $remote;
|
||||||
$versions{$sname}{local} = $local;
|
$versions{$n->{sname}}{local} = $local;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return \%versions;
|
return \%versions;
|
||||||
|
|
@ -996,40 +1116,40 @@ sub check_scripts {
|
||||||
|
|
||||||
sub download_script {
|
sub download_script {
|
||||||
my ($script, $xml) = @_;
|
my ($script, $xml) = @_;
|
||||||
my ($sname, $plname) = get_names($script, $xml);
|
my $n = get_names($script, $xml);
|
||||||
|
my $site = $n->{db}{source};
|
||||||
my %result;
|
my %result;
|
||||||
my $site = $xml->{$plname}{source};
|
|
||||||
$result{installed} = 0;
|
$result{installed} = 0;
|
||||||
$result{signed} = 0;
|
$result{signed} = 0;
|
||||||
my $dir = Irssi::get_irssi_dir();
|
my $dir = Irssi::get_irssi_dir();
|
||||||
my $ua = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1,timeout => 30);
|
my $ua = LWP::UserAgent->new(env_proxy => 1, keep_alive => 1, timeout => 30);
|
||||||
$ua->agent('ScriptAssist/'.2003020803);
|
$ua->agent('ScriptAssist/'.2003020803);
|
||||||
my $request = HTTP::Request->new('GET', $site.'/scripts/'.$script.'.pl');
|
my $request = HTTP::Request->new('GET', $site.'/scripts/'.$n->{plname});
|
||||||
my $response = $ua->request($request);
|
my $response = $ua->request($request);
|
||||||
if ($response->is_success()) {
|
if ($response->is_success() && !$response->header('X-Died')) {
|
||||||
my $file = $response->content();
|
my $file = $response->content();
|
||||||
mkdir $dir.'/scripts/' unless (-e $dir.'/scripts/');
|
mkdir $dir.'/scripts/' unless (-e $dir.'/scripts/');
|
||||||
open(my $F, '>', $dir.'/scripts/'.$plname.'.new');
|
open(my $f, '>', $dir.'/scripts/'.$n->{plname}.'.new');
|
||||||
print $F $file;
|
print $f $file;
|
||||||
close($F);
|
close($f);
|
||||||
if ($have_gpg && Irssi::settings_get_bool('scriptassist_use_gpg')) {
|
if ($have_gpg && Irssi::settings_get_bool('scriptassist_use_gpg')) {
|
||||||
my $ua2 = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1,timeout => 30);
|
my $ua2 = LWP::UserAgent->new(env_proxy => 1,keep_alive => 1,timeout => 30);
|
||||||
$ua->agent('ScriptAssist/'.2003020803);
|
$ua->agent('ScriptAssist/'.2003020803);
|
||||||
my $request2 = HTTP::Request->new('GET', $site.'/signatures/'.$plname.'.asc');
|
my $request2 = HTTP::Request->new('GET', $site.'/signatures/'.$n->{plname}.'.asc');
|
||||||
my $response2 = $ua->request($request2);
|
my $response2 = $ua->request($request2);
|
||||||
if ($response2->is_success()) {
|
if ($response2->is_success() && !$response->header('X-Died')) {
|
||||||
my $sig_dir = $dir.'/scripts/signatures/';
|
my $sig_dir = $dir.'/scripts/signatures/';
|
||||||
mkdir $sig_dir unless (-e $sig_dir);
|
mkdir $sig_dir unless (-e $sig_dir);
|
||||||
open(my $S, '>', $sig_dir.$plname.'.asc');
|
open(my $s, '>', $sig_dir.$n->{plname}.'.asc');
|
||||||
my $file2 = $response2->content();
|
my $file2 = $response2->content();
|
||||||
print $S $file2;
|
print $s $file2;
|
||||||
close($S);
|
close($s);
|
||||||
my $sig;
|
my $sig;
|
||||||
foreach (1..2) {
|
foreach (1..2) {
|
||||||
# FIXME gpg needs two rounds to load the key
|
# FIXME gpg needs two rounds to load the key
|
||||||
my $gpg = new GnuPG();
|
my $gpg = new GnuPG();
|
||||||
eval {
|
eval {
|
||||||
$sig = $gpg->verify( file => $dir.'/scripts/'.$plname.'.new', signature => $sig_dir.$plname.'.asc' );
|
$sig = $gpg->verify( file => $dir.'/scripts/'.$n->{plname}.'.new', signature => $sig_dir.$n->{plname}.'.asc' );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (defined $sig->{user}) {
|
if (defined $sig->{user}) {
|
||||||
|
|
@ -1055,8 +1175,8 @@ sub download_script {
|
||||||
if ($result{installed}) {
|
if ($result{installed}) {
|
||||||
my $old_dir = "$dir/scripts/old/";
|
my $old_dir = "$dir/scripts/old/";
|
||||||
mkdir $old_dir unless (-e $old_dir);
|
mkdir $old_dir unless (-e $old_dir);
|
||||||
rename "$dir/scripts/$plname", "$old_dir/$plname.old" if -e "$dir/scripts/$plname";
|
rename "$dir/scripts/".$n->{plname}, "$old_dir/".$n->{plname}.".old" if -e "$dir/scripts/".$n->{plname};
|
||||||
rename "$dir/scripts/$plname.new", "$dir/scripts/$plname";
|
rename "$dir/scripts/".$n->{plname}.".new", "$dir/scripts/".$n->{plname};
|
||||||
}
|
}
|
||||||
return \%result;
|
return \%result;
|
||||||
}
|
}
|
||||||
|
|
@ -1083,23 +1203,23 @@ sub print_check {
|
||||||
|
|
||||||
sub toggle_autorun {
|
sub toggle_autorun {
|
||||||
my ($script) = @_;
|
my ($script) = @_;
|
||||||
my ($sname, $plname) = get_names($script);
|
my $n = get_names($script);
|
||||||
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
my $dir = Irssi::get_irssi_dir()."/scripts/";
|
||||||
mkdir $dir."autorun/" unless (-e $dir."autorun/");
|
mkdir $dir."autorun/" unless (-e $dir."autorun/");
|
||||||
return unless (-e $dir.$plname);
|
return unless (-e $dir.$n->{plname});
|
||||||
if (-e $dir."/autorun/".$plname) {
|
if (-e $dir."/autorun/".$n->{plname}) {
|
||||||
if (readlink($dir."/autorun/".$plname) eq "../".$plname) {
|
if (readlink($dir."/autorun/".$n->{plname}) eq "../".$n->{plname}) {
|
||||||
if (unlink($dir."/autorun/".$plname)) {
|
if (unlink($dir."/autorun/".$n->{plname})) {
|
||||||
print CLIENTCRAP "%R>>%n Autorun of ".$sname." disabled";
|
print CLIENTCRAP "%R>>%n Autorun of ".$n->{sname}." disabled";
|
||||||
} else {
|
} else {
|
||||||
print CLIENTCRAP "%R>>%n Unable to delete link";
|
print CLIENTCRAP "%R>>%n Unable to delete link";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print CLIENTCRAP "%R>>%n ".$dir."/autorun/".$plname." is not a correct link";
|
print CLIENTCRAP "%R>>%n ".$dir."/autorun/".$n->{plname}." is not a correct link";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (symlink("../".$plname, $dir."/autorun/".$plname)) {
|
if (symlink("../".$n->{plname}, $dir."/autorun/".$n->{plname})) {
|
||||||
print CLIENTCRAP "%R>>%n Autorun of ".$sname." enabled";
|
print CLIENTCRAP "%R>>%n Autorun of ".$n->{sname}." enabled";
|
||||||
} else {
|
} else {
|
||||||
print CLIENTCRAP "%R>>%n Unable to create autorun link";
|
print CLIENTCRAP "%R>>%n Unable to create autorun link";
|
||||||
}
|
}
|
||||||
|
|
@ -1178,9 +1298,9 @@ sub cmd_help {
|
||||||
|
|
||||||
sub sig_command_script_load {
|
sub sig_command_script_load {
|
||||||
my ($script, $server, $witem) = @_;
|
my ($script, $server, $witem) = @_;
|
||||||
my ($sname, $plname, $pname, $xname) = get_names($script);
|
my $n = get_names($script);
|
||||||
if ( exists $Irssi::Script::{$pname} ) {
|
if ( $n->{stash} ) {
|
||||||
if (my $code = "Irssi::Script::${pname}"->can('pre_unload')) {
|
if (my $code = ("Irssi::Script::".$n->{pname})->can('pre_unload')) {
|
||||||
print CLIENTCRAP "%R>>%n Triggering pre_unload function of $script...";
|
print CLIENTCRAP "%R>>%n Triggering pre_unload function of $script...";
|
||||||
$code->();
|
$code->();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue