From f27407be6f922a2bede01b97795c12db9bba4077 Mon Sep 17 00:00:00 2001 From: Thomas Stagner Date: Sat, 21 Jan 2017 05:12:33 -0700 Subject: Make active server and window item visible to scriptlets --- scripts/perlalias.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/perlalias.pl b/scripts/perlalias.pl index 9a3e1fa..bb3b306 100644 --- a/scripts/perlalias.pl +++ b/scripts/perlalias.pl @@ -26,6 +26,7 @@ Creates or updates an alias. Like any perl code, multiple statements must be sep No replacement of parameter values is done: any $text is a perl variable. The arguments given to the /alias when typed are put into $_ and are also split on whitespace and put into @_. +In addition, the variables $server and $witem will refer to the active server and window item respectively. Examples: @@ -74,7 +75,7 @@ use POSIX qw(strftime); { package Irssi::Nick; } # Keeps trying to look for this package but for some reason it doesn't get loaded. -our $VERSION = '1.0'; +our $VERSION = '1.1'; our %IRSSI = ( authors => 'aquanight', contact => 'aquanight@gmail.com', @@ -103,14 +104,14 @@ sub exec_perlalias { exists $cmds{$cmd} or return; defined $cmds{$cmd}->{cmpcmd} or return; local $_ = $data; - $cmds{$cmd}->{cmpcmd}->(split / +/, $data); + $cmds{$cmd}->{cmpcmd}->($server, $witem, split / +/, $data); } # Bind a command sub setup_command { my ($cmd, $data) = @_; # Compile the script. - my $code = qq{package Irssi::Scripts::perlalias::aliaspkg;\nno warnings;\nsub {\n#line 1 "perlalias $cmd"\n$data}\n}; + my $code = qq{package Irssi::Scripts::perlalias::aliaspkg;\nno warnings;\nsub {my \$server = shift; my \$witem = shift;\n#line 1 "perlalias $cmd"\n$data}\n}; my $proc = eval $code; if ($@) { Irssi::printformat(MSGLEVEL_CLIENTERROR, perlalias_compile_error => $cmd); -- cgit v1.2.3