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

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

$plugin = {
	name => 'unread',
	action_imprementation => sub {
		my ($request, $name, $session_id, $param_string) = @_;
		my $cid = $param_string;
		my $channel = $::ib->cid2name($cid);

		::send_message($request, $channel);

		my $buf;
		if(defined($::ib->cid2name($cid))){
			if(defined($::ib->buffer($cid))){
				$buf = ::render_line($::ib->unread($cid), $session_id, $::cf->reverse_unread);
			}
		}

		my $ci = new Keitairc::ClientInfo($request);
		my $view = new Keitairc::View($::cf, $ci);
		return $view->render('unread.html', {
			buf => $buf,
			channel_compact => $::ib->simple_escape(encode($::cf->web_charset(), $::ib->compact_channel_name($cid))),
			cid => $cid,
			stamp => time,
			     });
	}
};

1;
