/[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 50 by dpavlin, Sun Mar 18 15:37:05 2007 UTC revision 51 by dpavlin, Sun Mar 18 16:03:24 2007 UTC
# Line 669  POE::Session->create( inline_states => Line 669  POE::Session->create( inline_states =>
669    
670                  } elsif ($msg =~ m/^ping/) {                  } elsif ($msg =~ m/^ping/) {
671                          $res = "ping = " . dump( $ping );                          $res = "ping = " . dump( $ping );
672                  } elsif ($msg =~ m/^(?:twitter)\s+(\S+)\s+(.*?)/) {                  } elsif ($msg =~ m/^conf(?:ig)*\s*(last-size|twitter)*\s*(.*)/) {
                         if ( defined( $2 ) ) {  
                                 meta($nick, $channel, 'twitter', "$1\t$2");  
                                 $res = "saved twitter auth for $1 -- /me on $channel will auto-update twitter status";  
                         } else {  
                                 meta($nick, $channel, 'twitter', '' );  
                                 $res = "removed twitter status update for /me on $channel";  
                         }  
                 } elsif ($msg =~ m/^conf(?:ig)*\s*(last-size)*\s*(\d*)/) {  
673                          if ( ! defined( $1 ) ) {                          if ( ! defined( $1 ) ) {
674                                  my $sth = $dbh->prepare(qq{ select name,value,changed from meta where nick = ? and channel = ? });                                  my $sth = $dbh->prepare(qq{ select name,value,changed from meta where nick = ? and channel = ? });
675                                  $sth->execute( $nick, $channel );                                  $sth->execute( $nick, $channel );
# Line 685  POE::Session->create( inline_states => Line 677  POE::Session->create( inline_states =>
677                                  while ( my ($n,$v) = $sth->fetchrow_array ) {                                  while ( my ($n,$v) = $sth->fetchrow_array ) {
678                                          $res .= "| $n = $v";                                          $res .= "| $n = $v";
679                                  }                                  }
680                          } elsif ( defined( $2 ) ) {                          } elsif ( ! $2 ) {
                                 meta( $nick, $channel, $1, $2 );  
                                 $res = "saved $1 = $2";  
                         } else {  
681                                  my $val = meta( $nick, $channel, $1 );                                  my $val = meta( $nick, $channel, $1 );
682                                  $res = "current $1 = " . ( $val ? $val : 'undefined' );                                  $res = "current $1 = " . ( $val ? $val : 'undefined' );
683                            } else {
684                                    my $validate = {
685                                            'last-size' => qr/^\d+/,
686                                            'twitter' => qr/^\w+\s+\w+/,
687                                    };
688    
689                                    my ( $op, $val ) = ( $1, $2 );
690    
691                                    if ( my $regex = $validate->{$op} ) {
692                                            if ( $val =~ $regex ) {
693                                                    meta( $nick, $channel, $op, $val );
694                                                    $res = "saved $op = $val";
695                                            } else {
696                                                    $res = "config option $op = $val doesn't validate against $regex";
697                                            }
698                                    } else {
699                                            $res = "config option $op doesn't exist";
700                                    }
701                          }                          }
702                  }                  }
703    

Legend:
Removed from v.50  
changed lines
  Added in v.51

  ViewVC Help
Powered by ViewVC 1.1.26