use Irssi;
use strict;
use vars qw($VERSION %IRSSI);

my %oldtopics;

$VERSION="0.1-zi";
%IRSSI =
(
        authors         => 'Wouter de Geus',
        contact         => 'benv@junerules.com',
        name            => 'topic',
        description     => 'Prints the old topic on topic change: updated by zi',
        license         => 'BSD',
        modules         => 'none',
        url             => '',
        changed         => "$1-$2-$3"
);
Irssi::theme_register([
	'old_topic',          '$0current topic of $1 is: $2'
]);
sub event_topic
{
	my ($server,$channel,$topic,$nick,$address) = @_;
	# See if we can find the window
	my $window = Irssi::window_find_item($channel);
	return unless($window);
	# Now find the channel topic
	my $channel_o = $server->channel_find($channel);
	return unless($channel_o);
	#$window->print("previous topic: ".$channel_o->{'topic'});
	my $whitespace = $nick;
	$whitespace =~ s/././g;
	$whitespace .= ".....";
	$window->printformat(MSGLEVEL_TOPICS, "old_topic", $whitespace, $channel, $channel_o->{'topic'});
}

########################### Hooks #############
Irssi::signal_add_last('message topic', \&event_topic);
