# -*- mode: perl; coding: utf-8 -*-
# keitairc/lib/plugins/00recent
# 未読発言一覧
# $Id: 00recent,v 1.9 2008-06-29 09:54:27 morimoto Exp $
# $Source: /home/ishikawa/work/keitairc/tmp/keitairc/lib/plugins/00recent,v $

# The line number (1 incremented) and filename below must be
# actual. see perlsyn.
# line 10 "keitairc/lib/plugins/00recent"

$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";
				$::ib->clear_unread($cid);
			}
		}

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

1;
