use strict;
use Irssi 20030709; # irssi 0.8.6.CVS (20030709 2336)

use vars qw($VERSION %IRSSI);
$VERSION = "0.5";
%IRSSI = (
	authors         => "David O\'Rourke",
	contact         => "EFNet\://phyber\@\#irssi",
	name            => "noticecurrent",
	description     => "Prints notices in the current window",
	licence         => "Public Domain"
);

my $insig = 0;

sub event_notice_current {
	my ($dest, $text, $stripped) = @_;
	my $server = $dest->{server};
	
	# ignore non-notices and notices in channels (from noticemove.pl)
	return if (!$server ||
		!($dest->{level} & MSGLEVEL_NOTICES) ||
		$server->ischannel($dest->{target}));
	return if ($insig);
	$insig = 1;
	
	my $channel = Irssi::active_win();
	$channel->print($text, MSGLEVEL_NOTICES);
	Irssi::signal_stop();
	$insig = 0;
}

Irssi::signal_add_first('print text', 'event_notice_current');