1 package Onis::Plugins::Topics;
6 use Onis::Config (qw(get_config));
7 use Onis::Html (qw(html_escape get_filehandle));
8 use Onis::Language (qw(translate));
9 use Onis::Data::Core (qw(register_plugin get_main_nick nick_to_name));
10 use Onis::Data::Persistent ();
12 our $TopicCache = Onis::Data::Persistent->new ('TopicCache', 'time', qw(text nick));
15 register_plugin ('TOPIC', \&add);
16 register_plugin ('OUTPUT', \&output);
19 if (get_config ('plugin_max'))
21 my $tmp = get_config ('plugin_max');
24 $MAX = $tmp if ($tmp);
28 print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
35 my $text = $data->{'text'};
36 my $nick = $data->{'nick'};
37 my $time = $data->{'epoch'};
39 $TopicCache->put ($time, $text, $nick);
45 for (sort { $b <=> $a } ($TopicCache->keys ()))
48 last if ($i++ >= $MAX);
50 my ($text, $nick) = $TopicCache->get ($time);
51 die unless (defined ($nick));
53 $nick = get_main_nick ($nick);
54 push (@$TopicData, [$text, $nick, $time]);
62 my $fh = get_filehandle ();
64 my $topic = translate ('Topic');
65 my $setby = translate ('Set by');
68 <table class="plugin topics">
70 <td class="invis"> </td>
80 my ($topic, $nick) = @$_;
81 my $name = nick_to_name ($nick) || $nick;
83 $topic = html_escape ($topic);
86 qq# <td class="numeration">$i</td>\n#,
87 qq# <td>$topic</td>\n#,
88 qq# <td class="nick">$name</td>\n#,
92 print $fh "</table>\n\n";