summary refs log tree commit diff stats
path: root/plugins/perl
diff options
context:
space:
mode:
authorberkeviktor@aol.com <berkeviktor@aol.com>2011-02-28 19:23:49 +0100
committerberkeviktor@aol.com <berkeviktor@aol.com>2011-02-28 19:23:49 +0100
commit62d32a125d75e17c8c9db5a880d25ea83b6384f0 (patch)
tree2fe408072466b83795ca2f41011f90e1d72733d4 /plugins/perl
parent6355e6a76e73dfd3b8f49fcec524e7d2bbb5a11c (diff)
parent58c03db835e9bb1f5d4f8525b6bbdb441f2c7c71 (diff)
merge with xchat r1492
Diffstat (limited to 'plugins/perl')
-rw-r--r--plugins/perl/lib/Xchat.pm15
-rw-r--r--plugins/perl/lib/Xchat/List/Network.pm1
2 files changed, 12 insertions, 4 deletions
diff --git a/plugins/perl/lib/Xchat.pm b/plugins/perl/lib/Xchat.pm
index 74914882..1849789b 100644
--- a/plugins/perl/lib/Xchat.pm
+++ b/plugins/perl/lib/Xchat.pm
@@ -212,19 +212,26 @@ sub hook_print {
 		my $cb = $callback;
 		$callback = sub {
 			my @args = @{$_[0]};
+			my $event_data = $_[1];
+			my $event_name = $event;
 			my $last_arg = @args - 1;
 
-			my @new = $cb->( \@args, $_[1], $event );
+			my @new = $cb->( \@args, $event_data, $event_name );
+
+			# allow changing event by returning the new value
+			if( @new > @args ) {
+				$event_name = pop @new;
+			}
 
 			# a filter can either return the new results or it can modify
 			# @_ in place. 
-			if( @new ) {
-				emit_print( $event, @new[ 0 .. $last_arg ] );
+			if( @new == @args ) {
+				emit_print( $event_name, @new[ 0 .. $last_arg ] );
 				return EAT_ALL;
 			} elsif(
 				join( "\0", @{$_[0]} ) ne join( "\0", @args[ 0 .. $last_arg ] )
 			) {
-				emit_print( $event, @args[ 0 .. $last_arg ] );
+				emit_print( $event_name, @args[ 0 .. $last_arg ] );
 				return EAT_ALL;
 			}
 
diff --git a/plugins/perl/lib/Xchat/List/Network.pm b/plugins/perl/lib/Xchat/List/Network.pm
index da2f52dd..5755ede9 100644
--- a/plugins/perl/lib/Xchat/List/Network.pm
+++ b/plugins/perl/lib/Xchat/List/Network.pm
@@ -13,6 +13,7 @@ sub get {
 			(!defined $last_modified || $last_modified != -M $server_file ) ) {
 		$last_modified = -M _;
 
+		@servers = ();
 		if( open my $fh, "<", $server_file ) {
 			local $/ = "\n\n";
 			while( my $record = <$fh> ) {