# -*- mode: perl; coding: utf-8 -*-
# $Id: 03recent,v 1.2 2008-08-03 13:33:40 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/t/02_Plugins/03recent,v $

# WARNING: This file is a part of Keitairc::Plugins test suite, not
# actual working code.

$plugin = {
	name => 'recent',
	action_imprementation => sub {
		my ($request, $name, $session_id, $param_string) = @_;
		my $buf;

		for my $cid ($::ib->channels()){
			my $channel = $::ib->cid2name($cid);
			if($::ib->unread_lines($cid)){
				my $name = $::ib->cid2name($cid);
				Encode::from_to($name, $::cf->irc_charset(), $::cf->web_charset());
				$buf .= sprintf(' <a href="all/%d">%s</a><br />', $cid, $name);
				$buf .= ::render_line($::ib->unread($cid), $session_id, $::cf->reverse_recent);
				$buf .= "<hr />\n";
			}
		}

		my $ci = new Keitairc::ClientInfo($request);
		my $view = new Keitairc::View($::cf, $ci);
		return $view->render('recent.html', { buf => $buf });
	}
};

1;
