/[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 34 - (hide annotations)
Sat Jun 24 22:57:26 2006 UTC (14 years, 7 months ago) by dpavlin
Original Path: trunk/irc-logger.pl
File MIME type: text/plain
File size: 15412 byte(s)
somewhat better logging

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26