/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 23 by dpavlin, Sun Mar 26 01:01:10 2006 UTC revision 27 by dpavlin, Mon May 22 16:19:00 2006 UTC
# Line 18  log all conversation on irc channel Line 18  log all conversation on irc channel
18    
19  ## CONFIG  ## CONFIG
20    
21  my $NICK = 'irc-logger-dev';  my $NICK = 'irc-logger';
22  my $CONNECT =  my $CONNECT =
23    {Server => 'irc.freenode.net',    {Server => 'irc.freenode.net',
24     Nick => $NICK,     Nick => $NICK,
# Line 116  sub get_from_log { Line 116  sub get_from_log {
116          $args->{limit} ||= 10;          $args->{limit} ||= 10;
117    
118          $args->{fmt} ||= {          $args->{fmt} ||= {
119                    date => '[%s] ',
120                  time => '{%s} ',                  time => '{%s} ',
121                  time_channel => '{%s %s} ',                  time_channel => '{%s %s} ',
122                  nick => '%s: ',                  nick => '%s: ',
# Line 144  sub get_from_log { Line 145  sub get_from_log {
145    
146          my $sql = $context ? $sql_context : $sql_message;          my $sql = $context ? $sql_context : $sql_message;
147    
148          $sql .= " where message ilike ? " if ($args->{search});          $sql .= " where message ilike ? or nick ilike ? " if ($args->{search});
149          $sql .= " order by log.time desc";          $sql .= " order by log.time desc";
150          $sql .= " limit " . $args->{limit};          $sql .= " limit " . $args->{limit};
151    
# Line 152  sub get_from_log { Line 153  sub get_from_log {
153          if (my $search = $args->{search}) {          if (my $search = $args->{search}) {
154                  $search =~ s/^\s+//;                  $search =~ s/^\s+//;
155                  $search =~ s/\s+$//;                  $search =~ s/\s+$//;
156                  $sth->execute( '%' . $search . '%' );                  $sth->execute( ( '%' . $search . '%' ) x 2 );
157                  warn "search for '$search' returned ", $sth->rows, " results ", $context || '', "\n";                  warn "search for '$search' returned ", $sth->rows, " results ", $context || '', "\n";
158          } else {          } else {
159                  $sth->execute();                  $sth->execute();
# Line 202  sub get_from_log { Line 203  sub get_from_log {
203    
204                  $row->{time} =~ s#\.\d+##;                  $row->{time} =~ s#\.\d+##;
205    
                 my $t;  
                 $t = $row->{date} . ' ' if ($last_row->{date} ne $row->{date});  
                 $t .= $row->{time};  
   
206                  my $msg = '';                  my $msg = '';
207    
208                    $msg = sprintf($args->{fmt}->{date}, $row->{date}) . ' ' if ($last_row->{date} ne $row->{date});
209                    my $t = $row->{time};
210    
211                  if ($last_row->{channel} ne $row->{channel}) {                  if ($last_row->{channel} ne $row->{channel}) {
212                          $msg .= sprintf($args->{fmt}->{time_channel}, $t, $row->{channel});                          $msg .= sprintf($args->{fmt}->{time_channel}, $t, $row->{channel});
213                  } else {                  } else {
# Line 217  sub get_from_log { Line 217  sub get_from_log {
217                  my $append = 1;                  my $append = 1;
218    
219                  my $nick = $row->{nick};                  my $nick = $row->{nick};
220                  $nick =~ s/^_*(.*?)_*$/$1/;                  if ($nick =~ s/^_*(.*?)_*$/$1/) {
221                                    $row->{nick} = $nick;
222                    }
223    
224                  if ($last_row->{nick} ne $nick) {                  if ($last_row->{nick} ne $nick) {
225                          # obfu way to find format for me_nick if needed or fallback to default                          # obfu way to find format for me_nick if needed or fallback to default
226                          my $fmt = $row->{me} ? ( $args->{fmt}->{me_nick} || $args->{fmt}->{nick} ) : $args->{fmt}->{nick};                          my $fmt = $row->{me} ? ( $args->{fmt}->{me_nick} || $args->{fmt}->{nick} ) : $args->{fmt}->{nick};
# Line 485  my $escape_re  = join '|' => keys %escap Line 487  my $escape_re  = join '|' => keys %escap
487  my $style = <<'_END_OF_STYLE_';  my $style = <<'_END_OF_STYLE_';
488  p { margin: 0; padding: 0.1em; }  p { margin: 0; padding: 0.1em; }
489  .time, .channel { color: #808080; font-size: 60%; }  .time, .channel { color: #808080; font-size: 60%; }
490    .date { float: right; clear: right; background: #e0e0e0; color: #404040; font-size: 120%; padding: 0.25em; border: 1px dashed #808080; }
491  .nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; }  .nick { color: #000000; font-size: 80%; padding: 2px; font-family: courier, courier new, monospace ; }
492  .message { color: #000000; font-size: 100%; }  .message { color: #000000; font-size: 100%; }
493  .search { float: right; }  .search { float: right; }
# Line 529  sub root_handler { Line 532  sub root_handler {
532                                  limit => $q->param('last') || 100,                                  limit => $q->param('last') || 100,
533                                  search => $q->param('search') || $q->param('grep') || undef,                                  search => $q->param('search') || $q->param('grep') || undef,
534                                  fmt => {                                  fmt => {
535                                            date => '<hr size="1" style="clear: both;"/><div class="date">%s</div> ',
536                                          time => '<span class="time">%s</span> ',                                          time => '<span class="time">%s</span> ',
537                                          time_channel => '<span class="channel">%s %s</span> ',                                          time_channel => '<span class="channel">%s %s</span> ',
538                                          nick => '%s:&nbsp;',                                          nick => '%s:&nbsp;',

Legend:
Removed from v.23  
changed lines
  Added in v.27

  ViewVC Help
Powered by ViewVC 1.1.26