/[irc-logger]/trunk/bin/irc-logger.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/bin/irc-logger.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (hide annotations)
Mon Jun 19 11:32:16 2006 UTC (14 years, 7 months ago) by dpavlin
Original Path: trunk/irc-logger.pl
File MIME type: text/plain
File size: 15612 byte(s)
real-time update of tag clound, search nukes arguments
1 dpavlin 4 #!/usr/bin/perl -w
2     use strict;
3     $|++;
4    
5 dpavlin 5 =head1 NAME
6    
7     irc-logger.pl
8    
9     =head1 SYNOPSIS
10    
11     ./irc-logger.pl
12    
13     =head1 DESCRIPTION
14    
15     log all conversation on irc channel
16    
17     =cut
18    
19 dpavlin 4 ## CONFIG
20    
21 dpavlin 29 my $NICK = 'irc-logger';
22 dpavlin 4 my $CONNECT =
23     {Server => 'irc.freenode.net',
24     Nick => $NICK,
25 dpavlin 8 Ircname => "try /msg $NICK help",
26 dpavlin 4 };
27     my $CHANNEL = '#razmjenavjestina';
28     my $IRC_ALIAS = "log";
29    
30     my %FOLLOWS =
31     (
32     ACCESS => "/var/log/apache/access.log",
33     ERROR => "/var/log/apache/error.log",
34     );
35    
36 dpavlin 19 my $DSN = 'DBI:Pg:dbname=' . $NICK;
37 dpavlin 5
38 dpavlin 14 my $ENCODING = 'ISO-8859-2';
39    
40 dpavlin 4 ## END CONFIG
41    
42 dpavlin 5
43    
44 dpavlin 13 use POE qw(Component::IRC Wheel::FollowTail Component::Server::HTTP);
45     use HTTP::Status;
46 dpavlin 5 use DBI;
47 dpavlin 30 use Encode qw/from_to is_utf8/;
48 dpavlin 15 use Regexp::Common qw /URI/;
49 dpavlin 16 use CGI::Simple;
50 dpavlin 28 use HTML::TagCloud;
51 dpavlin 5
52     my $dbh = DBI->connect($DSN,"","", { RaiseError => 1, AutoCommit => 1 }) || die $DBI::errstr;
53    
54 dpavlin 19 eval {
55     $dbh->do(qq{ select count(*) from log });
56     };
57 dpavlin 5
58 dpavlin 19 if ($@) {
59     warn "creating database table in $DSN\n";
60     $dbh->do(<<'_SQL_SCHEMA_');
61    
62 dpavlin 5 create table log (
63     id serial,
64     time timestamp default now(),
65     channel text not null,
66 dpavlin 19 me boolean default false,
67 dpavlin 5 nick text not null,
68     message text not null,
69     primary key(id)
70     );
71    
72     create index log_time on log(time);
73     create index log_channel on log(channel);
74     create index log_nick on log(nick);
75    
76 dpavlin 19 _SQL_SCHEMA_
77     }
78 dpavlin 5
79     my $sth = $dbh->prepare(qq{
80     insert into log
81 dpavlin 19 (channel, me, nick, message)
82     values (?,?,?,?)
83 dpavlin 5 });
84    
85 dpavlin 28 my $tags;
86 dpavlin 31 my $tag_regex = '\b([\w-_]+)//';
87 dpavlin 28
88 dpavlin 11 =head2 get_from_log
89 dpavlin 5
90 dpavlin 11 my @messages = get_from_log(
91     limit => 42,
92     search => '%what to stuff in ilike%',
93 dpavlin 13 fmt => {
94     time => '{%s} ',
95     time_channel => '{%s %s} ',
96     nick => '%s: ',
97 dpavlin 20 me_nick => '***%s ',
98 dpavlin 13 message => '%s',
99     },
100 dpavlin 20 filter => {
101     message => sub {
102     # modify message content
103     return shift;
104     }
105 dpavlin 21 },
106     context => 5,
107 dpavlin 11 );
108    
109 dpavlin 20 Order is important. Fields are first passed through C<filter> (if available) and
110     then throgh C<< sprintf($fmt->{message}, $message >> if available.
111    
112 dpavlin 21 C<context> defines number of messages around each search hit for display.
113    
114 dpavlin 11 =cut
115    
116     sub get_from_log {
117     my $args = {@_};
118    
119     $args->{limit} ||= 10;
120    
121 dpavlin 13 $args->{fmt} ||= {
122 dpavlin 26 date => '[%s] ',
123 dpavlin 13 time => '{%s} ',
124     time_channel => '{%s %s} ',
125     nick => '%s: ',
126 dpavlin 20 me_nick => '***%s ',
127 dpavlin 13 message => '%s',
128     };
129    
130 dpavlin 21 my $sql_message = qq{
131 dpavlin 11 select
132     time::date as date,
133     time::time as time,
134     channel,
135 dpavlin 20 me,
136 dpavlin 11 nick,
137     message
138     from log
139     };
140 dpavlin 21
141     my $sql_context = qq{
142     select
143     id
144     from log
145     };
146    
147     my $context = $1 if ($args->{search} && $args->{search} =~ s/\s*\+(\d+)\s*/ /);
148    
149     my $sql = $context ? $sql_context : $sql_message;
150    
151 dpavlin 25 $sql .= " where message ilike ? or nick ilike ? " if ($args->{search});
152 dpavlin 28 $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} });
153 dpavlin 11 $sql .= " order by log.time desc";
154     $sql .= " limit " . $args->{limit};
155    
156     my $sth = $dbh->prepare( $sql );
157 dpavlin 21 if (my $search = $args->{search}) {
158     $search =~ s/^\s+//;
159     $search =~ s/\s+$//;
160 dpavlin 25 $sth->execute( ( '%' . $search . '%' ) x 2 );
161 dpavlin 21 warn "search for '$search' returned ", $sth->rows, " results ", $context || '', "\n";
162 dpavlin 28 } elsif (my $tag = $args->{tag}) {
163     $sth->execute();
164     warn "tag '$tag' returned ", $sth->rows, " results ", $context || '', "\n";
165 dpavlin 11 } else {
166     $sth->execute();
167     }
168     my $last_row = {
169     date => '',
170     time => '',
171     channel => '',
172     nick => '',
173     };
174    
175     my @rows;
176    
177     while (my $row = $sth->fetchrow_hashref) {
178     unshift @rows, $row;
179     }
180    
181 dpavlin 16 my @msgs = (
182     "Showing " . ($#rows + 1) . " messages..."
183     );
184 dpavlin 11
185 dpavlin 21 if ($context) {
186     my @ids = @rows;
187     @rows = ();
188    
189     my $last_to = 0;
190    
191     my $sth = $dbh->prepare( $sql_message . qq{ where id >= ? and id < ? } );
192     foreach my $row_id (sort { $a->{id} <=> $b->{id} } @ids) {
193     my $id = $row_id->{id} || die "can't find id in row";
194    
195     my ($from, $to) = ($id - $context, $id + $context);
196     $from = $last_to if ($from < $last_to);
197     $last_to = $to;
198     $sth->execute( $from, $to );
199    
200     #warn "## id: $id from: $from to: $to returned: ", $sth->rows, "\n";
201    
202     while (my $row = $sth->fetchrow_hashref) {
203     push @rows, $row;
204     }
205    
206     }
207     }
208    
209 dpavlin 11 foreach my $row (@rows) {
210    
211     $row->{time} =~ s#\.\d+##;
212    
213     my $msg = '';
214    
215 dpavlin 26 $msg = sprintf($args->{fmt}->{date}, $row->{date}) . ' ' if ($last_row->{date} ne $row->{date});
216     my $t = $row->{time};
217    
218 dpavlin 13 if ($last_row->{channel} ne $row->{channel}) {
219     $msg .= sprintf($args->{fmt}->{time_channel}, $t, $row->{channel});
220     } else {
221     $msg .= sprintf($args->{fmt}->{time}, $t);
222     }
223 dpavlin 11
224 dpavlin 12 my $append = 1;
225 dpavlin 11
226 dpavlin 22 my $nick = $row->{nick};
227 dpavlin 24 if ($nick =~ s/^_*(.*?)_*$/$1/) {
228     $row->{nick} = $nick;
229     }
230    
231 dpavlin 22 if ($last_row->{nick} ne $nick) {
232 dpavlin 20 # obfu way to find format for me_nick if needed or fallback to default
233     my $fmt = $row->{me} ? ( $args->{fmt}->{me_nick} || $args->{fmt}->{nick} ) : $args->{fmt}->{nick};
234     $fmt ||= '%s';
235    
236     $nick = $args->{filter}->{nick}->($nick) if (ref($args->{filter}->{nick}) eq 'CODE');
237    
238     $msg .= sprintf( $fmt, $nick );
239 dpavlin 12 $append = 0;
240     }
241    
242 dpavlin 20 $args->{fmt}->{message} ||= '%s';
243     if (ref($args->{filter}->{message}) eq 'CODE') {
244 dpavlin 15 $msg .= sprintf($args->{fmt}->{message},
245 dpavlin 20 $args->{filter}->{message}->(
246 dpavlin 15 $row->{message}
247     )
248     );
249     } else {
250     $msg .= sprintf($args->{fmt}->{message}, $row->{message});
251     }
252 dpavlin 11
253 dpavlin 12 if ($append && @msgs) {
254     $msgs[$#msgs] .= " " . $msg;
255     } else {
256     push @msgs, $msg;
257     }
258 dpavlin 11
259     $last_row = $row;
260     }
261    
262     return @msgs;
263     }
264    
265    
266 dpavlin 4 my $SKIPPING = 0; # if skipping, how many we've done
267     my $SEND_QUEUE; # cache
268    
269     POE::Component::IRC->new($IRC_ALIAS);
270    
271     POE::Session->create
272     (inline_states =>
273     {_start => sub {
274 dpavlin 7 $_[KERNEL]->post($IRC_ALIAS => register => 'all');
275     $_[KERNEL]->post($IRC_ALIAS => connect => $CONNECT);
276 dpavlin 4 },
277 dpavlin 9 irc_255 => sub { # server is done blabbing
278 dpavlin 7 $_[KERNEL]->post($IRC_ALIAS => join => $CHANNEL);
279     $_[KERNEL]->post($IRC_ALIAS => join => '#logger');
280     $_[KERNEL]->yield("heartbeat"); # start heartbeat
281     # $_[KERNEL]->yield("my_add", $_) for keys %FOLLOWS;
282 dpavlin 11 $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "IDENTIFY $NICK" );
283 dpavlin 4 },
284     irc_public => sub {
285 dpavlin 7 my $kernel = $_[KERNEL];
286     my $nick = (split /!/, $_[ARG0])[0];
287     my $channel = $_[ARG1]->[0];
288     my $msg = $_[ARG2];
289 dpavlin 4
290 dpavlin 14 from_to($msg, 'UTF-8', $ENCODING);
291 dpavlin 6
292 dpavlin 7 print "$channel: <$nick> $msg\n";
293 dpavlin 19 $sth->execute($channel, 0, $nick, $msg);
294 dpavlin 30 add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef),
295     message => $msg);
296 dpavlin 4 },
297 dpavlin 19 irc_ctcp_action => sub {
298     my $kernel = $_[KERNEL];
299     my $nick = (split /!/, $_[ARG0])[0];
300     my $channel = $_[ARG1]->[0];
301     my $msg = $_[ARG2];
302    
303     from_to($msg, 'UTF-8', $ENCODING);
304    
305     print "$channel ***$nick $msg\n";
306     $sth->execute($channel, 1, $nick, $msg);
307 dpavlin 30 add_tag( id => $dbh->last_insert_id(undef,undef,"log",undef),
308     message => $msg);
309 dpavlin 19 },
310 dpavlin 7 irc_msg => sub {
311     my $kernel = $_[KERNEL];
312     my $nick = (split /!/, $_[ARG0])[0];
313     my $msg = $_[ARG2];
314 dpavlin 14 from_to($msg, 'UTF-8', $ENCODING);
315 dpavlin 7
316 dpavlin 8 my $res = "unknown command '$msg', try /msg $NICK help!";
317 dpavlin 11 my @out;
318 dpavlin 7
319     print "<< $msg\n";
320    
321 dpavlin 8 if ($msg =~ m/^help/i) {
322 dpavlin 7
323 dpavlin 11 $res = "usage: /msg $NICK comand | commands: stat - user/message stat | last - show backtrace | grep foobar - find foobar";
324 dpavlin 8
325 dpavlin 10 } elsif ($msg =~ m/^msg\s+(\S+)\s+(.*)$/i) {
326    
327     print ">> /msg $1 $2\n";
328     $_[KERNEL]->post( $IRC_ALIAS => privmsg => $1, $2 );
329     $res = '';
330    
331 dpavlin 8 } elsif ($msg =~ m/^stat.*?\s*(\d*)/i) {
332    
333 dpavlin 7 my $nr = $1 || 10;
334    
335     my $sth = $dbh->prepare(qq{
336     select nick,count(*) from log group by nick order by count desc limit $nr
337     });
338     $sth->execute();
339     $res = "Top $nr users: ";
340 dpavlin 8 my @users;
341 dpavlin 7 while (my $row = $sth->fetchrow_hashref) {
342 dpavlin 8 push @users,$row->{nick} . ': ' . $row->{count};
343 dpavlin 7 }
344 dpavlin 8 $res .= join(" | ", @users);
345     } elsif ($msg =~ m/^last.*?\s*(\d*)/i) {
346    
347 dpavlin 11 foreach my $res (get_from_log( limit => $1 )) {
348     print "last: $res\n";
349 dpavlin 14 from_to($res, $ENCODING, 'UTF-8');
350 dpavlin 11 $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );
351 dpavlin 8 }
352    
353 dpavlin 11 $res = '';
354 dpavlin 8
355 dpavlin 21 } elsif ($msg =~ m/^(search|grep)\s+(.*)\s*$/i) {
356 dpavlin 8
357 dpavlin 11 my $what = $2;
358 dpavlin 8
359 dpavlin 21 foreach my $res (get_from_log(
360     limit => 20,
361     search => $what,
362     )) {
363 dpavlin 11 print "search [$what]: $res\n";
364 dpavlin 14 from_to($res, $ENCODING, 'UTF-8');
365 dpavlin 8 $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );
366     }
367    
368     $res = '';
369 dpavlin 11
370 dpavlin 7 }
371    
372 dpavlin 8 if ($res) {
373     print ">> [$nick] $res\n";
374 dpavlin 14 from_to($res, $ENCODING, 'UTF-8');
375 dpavlin 8 $_[KERNEL]->post( $IRC_ALIAS => privmsg => $nick, $res );
376     }
377 dpavlin 7
378     },
379 dpavlin 10 irc_477 => sub {
380     print "# irc_477: ",$_[ARG1], "\n";
381     $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "register $NICK" );
382     },
383 dpavlin 7 irc_505 => sub {
384 dpavlin 10 print "# irc_505: ",$_[ARG1], "\n";
385 dpavlin 7 $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "register $NICK" );
386 dpavlin 10 # $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "set hide email on" );
387     # $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "set email dpavlin\@rot13.org" );
388 dpavlin 8 },
389     irc_registered => sub {
390 dpavlin 10 warn "## indetify $NICK\n";
391 dpavlin 7 $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "IDENTIFY $NICK" );
392 dpavlin 10 },
393 dpavlin 11 # irc_433 => sub {
394     # print "# irc_433: ",$_[ARG1], "\n";
395     # warn "## indetify $NICK\n";
396     # $_[KERNEL]->post( $IRC_ALIAS => privmsg => 'nickserv', "IDENTIFY $NICK" );
397     # },
398 dpavlin 10 irc_372 => sub {
399     print "MOTD: ", $_[ARG1], "\n";
400     },
401     irc_snotice => sub {
402     print "(server notice): ", $_[ARG0], "\n";
403     },
404 dpavlin 4 (map
405     {
406     ;"irc_$_" => sub { }}
407 dpavlin 10 qw(
408 dpavlin 5 )),
409 dpavlin 10 # join
410     # ctcp_version
411     # connected snotice ctcp_action ping notice mode part quit
412     # 001 002 003 004 005
413     # 250 251 252 253 254 265 266
414     # 332 333 353 366 372 375 376
415     # 477
416 dpavlin 4 _child => sub {},
417     _default => sub {
418     printf "%s: session %s caught an unhandled %s event.\n",
419     scalar localtime(), $_[SESSION]->ID, $_[ARG0];
420     print "The $_[ARG0] event was given these parameters: ",
421     join(" ", map({"ARRAY" eq ref $_ ? "[@$_]" : "$_"} @{$_[ARG1]})), "\n";
422     0; # false for signals
423     },
424     my_add => sub {
425     my $trailing = $_[ARG0];
426     my $session = $_[SESSION];
427     POE::Session->create
428     (inline_states =>
429     {_start => sub {
430     $_[HEAP]->{wheel} =
431     POE::Wheel::FollowTail->new
432     (
433     Filename => $FOLLOWS{$trailing},
434     InputEvent => 'got_line',
435     );
436     },
437     got_line => sub {
438     $_[KERNEL]->post($session => my_tailed =>
439     time, $trailing, $_[ARG0]);
440     },
441     },
442     );
443    
444     },
445     my_tailed => sub {
446     my ($time, $file, $line) = @_[ARG0..ARG2];
447     ## $time will be undef on a probe, or a time value if a real line
448    
449     ## PoCo::IRC has throttling built in, but no external visibility
450     ## so this is reaching "under the hood"
451     $SEND_QUEUE ||=
452     $_[KERNEL]->alias_resolve($IRC_ALIAS)->get_heap->{send_queue};
453    
454     ## handle "no need to keep skipping" transition
455     if ($SKIPPING and @$SEND_QUEUE < 1) {
456     $_[KERNEL]->post($IRC_ALIAS => privmsg => $CHANNEL =>
457     "[discarded $SKIPPING messages]");
458     $SKIPPING = 0;
459     }
460    
461     ## handle potential message display
462     if ($time) {
463     if ($SKIPPING or @$SEND_QUEUE > 3) { # 3 msgs per 10 seconds
464     $SKIPPING++;
465     } else {
466     my @time = localtime $time;
467     $_[KERNEL]->post($IRC_ALIAS => privmsg => $CHANNEL =>
468     sprintf "%02d:%02d:%02d: %s: %s",
469     ($time[2] + 11) % 12 + 1, $time[1], $time[0],
470     $file, $line);
471     }
472     }
473    
474     ## handle re-probe/flush if skipping
475     if ($SKIPPING) {
476     $_[KERNEL]->delay($_[STATE] => 0.5); # $time will be undef
477     }
478    
479     },
480     my_heartbeat => sub {
481     $_[KERNEL]->yield(my_tailed => time, "heartbeat", "beep");
482     $_[KERNEL]->delay($_[STATE] => 10);
483     }
484     },
485     );
486    
487 dpavlin 28 # tags support
488    
489     my $cloud = HTML::TagCloud->new;
490    
491     =head2 add_tag
492    
493     add_tag( id => 42, message => 'irc message' );
494    
495     =cut
496    
497     sub add_tag {
498     my $arg = {@_};
499    
500     return unless ($arg->{id} && $arg->{message});
501    
502 dpavlin 30 my $m = $arg->{message};
503     from_to('UTF-8', 'iso-8859-2', $m) if (is_utf8($m));
504    
505 dpavlin 31 while ($m =~ s#$tag_regex##s) {
506 dpavlin 28 my $tag = $1;
507     next if (! $tag || $tag =~ m/https?:/i);
508     push @{ $tags->{$tag} }, $arg->{id};
509 dpavlin 31 warn "+tag $tag: $arg->{id}\n";
510 dpavlin 32 $cloud->add($tag, "?tag=$tag", scalar @{$tags->{$tag}} + 1);
511 dpavlin 28 }
512     }
513    
514     =head2 seed_tags
515    
516     Read all tags from database and create in-memory cache for tags
517    
518     =cut
519    
520     sub seed_tags {
521     my $sth = $dbh->prepare(qq{ select id,message from log where message like '%//%' });
522     $sth->execute;
523     while (my $row = $sth->fetchrow_hashref) {
524     add_tag( %$row );
525     }
526    
527     foreach my $tag (keys %$tags) {
528     $cloud->add($tag, "?tag=$tag", scalar @{$tags->{$tag}} + 1);
529     }
530     }
531    
532     seed_tags;
533    
534 dpavlin 13 # http server
535    
536     my $httpd = POE::Component::Server::HTTP->new(
537 dpavlin 14 Port => $NICK =~ m/-dev/ ? 8001 : 8000,
538 dpavlin 13 ContentHandler => { '/' => \&root_handler },
539     Headers => { Server => 'irc-logger' },
540     );
541    
542 dpavlin 18 my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
543     my $escape_re = join '|' => keys %escape;
544    
545 dpavlin 13 my $style = <<'_END_OF_STYLE_';
546 dpavlin 16 p { margin: 0; padding: 0.1em; }
547 dpavlin 13 .time, .channel { color: #808080; font-size: 60%; }
548 dpavlin 28 .date { float: right; background: #e0e0e0; color: #404040; font-size: 120%; padding: 0.25em; border: 1px dashed #808080; }
549 dpavlin 20 .nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; }
550 dpavlin 13 .message { color: #000000; font-size: 100%; }
551 dpavlin 16 .search { float: right; }
552 dpavlin 20 .col-0 { background: #ffff66 }
553     .col-1 { background: #a0ffff }
554     .col-2 { background: #99ff99 }
555     .col-3 { background: #ff9999 }
556     .col-4 { background: #ff66ff }
557 dpavlin 31 a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none }
558     a:hover.tag { border: 1px solid #eee }
559 dpavlin 13 _END_OF_STYLE_
560    
561 dpavlin 20 my $max_color = 4;
562    
563     my %nick_enumerator;
564    
565 dpavlin 13 sub root_handler {
566     my ($request, $response) = @_;
567     $response->code(RC_OK);
568 dpavlin 14 $response->content_type("text/html; charset=$ENCODING");
569 dpavlin 16
570     my $q;
571    
572     if ( $request->method eq 'POST' ) {
573     $q = new CGI::Simple( $request->content );
574     } elsif ( $request->uri =~ /\?(.+)$/ ) {
575     $q = new CGI::Simple( $1 );
576     } else {
577     $q = new CGI::Simple;
578     }
579    
580     my $search = $q->param('search') || $q->param('grep') || '';
581    
582 dpavlin 13 $response->content(
583 dpavlin 28 qq{<html><head><title>$NICK</title><style type="text/css">$style} .
584     $cloud->css .
585     qq{</style></head><body>} .
586     qq{
587 dpavlin 32 <form method="post" class="search" action="/">
588 dpavlin 16 <input type="text" name="search" value="$search" size="10">
589     <input type="submit" value="search">
590     </form>
591     } .
592 dpavlin 31 $cloud->html(500) .
593 dpavlin 28 qq{<p>} .
594 dpavlin 16 join("</p><p>",
595 dpavlin 13 get_from_log(
596 dpavlin 23 limit => $q->param('last') || 100,
597 dpavlin 28 search => $search || undef,
598 dpavlin 29 tag => $q->param('tag') || undef,
599 dpavlin 13 fmt => {
600 dpavlin 27 date => '<hr size="1" style="clear: both;"/><div class="date">%s</div> ',
601 dpavlin 13 time => '<span class="time">%s</span> ',
602     time_channel => '<span class="channel">%s %s</span> ',
603 dpavlin 20 nick => '%s:&nbsp;',
604     me_nick => '***%s&nbsp;',
605 dpavlin 13 message => '<span class="message">%s</span>',
606     },
607 dpavlin 20 filter => {
608     message => sub {
609     my $m = shift || return;
610     $m =~ s/($escape_re)/$escape{$1}/gs;
611     $m =~ s#($RE{URI}{HTTP})#<a href="$1">$1</a>#gs;
612 dpavlin 31 $m =~ s#$tag_regex#<a href="?tag=$1" class="tag">$1</a>#g;
613 dpavlin 20 return $m;
614     },
615     nick => sub {
616     my $n = shift || return;
617     if (! $nick_enumerator{$n}) {
618     my $max = scalar keys %nick_enumerator;
619     $nick_enumerator{$n} = $max + 1;
620     }
621     return '<span class="nick col-' .
622     ( $nick_enumerator{$n} % $max_color ) .
623     '">' . $n . '</span>';
624     },
625 dpavlin 15 },
626 dpavlin 13 )
627     ) .
628 dpavlin 16 qq{</p></body></html>}
629 dpavlin 13 );
630     return RC_OK;
631     }
632    
633 dpavlin 4 POE::Kernel->run;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26