/[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 33 - (hide annotations)
Sat Jun 24 22:15:47 2006 UTC (14 years, 7 months ago) by dpavlin
Original Path: trunk/irc-logger.pl
File MIME type: text/plain
File size: 15736 byte(s)
use development settings if hostname is llin, be less chatty

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26