use Irssi;
Irssi::signal_add_last("exec input", 'redirect_text');

sub redirect_text {
	my ($process, $text) = @_;
	my $witem = $process->{target_win};

	if($text =~ /^IRSSICMD/)
	{
		my @text_array = split / /, $text;
		if($text_array[1] eq "clear") {
			$witem->command("/clear");
			Irssi::signal_stop();
		}

	}
	else {
		Irssi::signal_continue($process, $text);
	}
}
