/[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 53 by dpavlin, Sun Mar 18 17:00:16 2007 UTC
# Line 74  use HTML::CalendarMonthSimple; Line 74  use HTML::CalendarMonthSimple;
74  use Getopt::Long;  use Getopt::Long;
75  use DateTime;  use DateTime;
76  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
77    use Net::Twitter;
78    
79  my $import_dircproxy;  my $import_dircproxy;
80  my $log_path;  my $log_path;
# Line 545  POE::Session->create( inline_states => Line 546  POE::Session->create( inline_states =>
546    
547                  save_message( channel => $channel, me => 1, nick => $nick, msg => $msg);                  save_message( channel => $channel, me => 1, nick => $nick, msg => $msg);
548    
549                  if ( my $twitter = ( $nick, $channel, 'twitter' ) ) {                  if ( my $twitter = meta( $nick, $channel, 'twitter' ) ) {
550                          _log("FIXME: send twitter for $nick on $channel [$twitter]");                          my ($login,$passwd) = split(/\s+/,$twitter,2);
551                            _log("sending twitter for $nick/$login on $channel ");
552                            my $bot = Net::Twitter->new( username=>$login, password=>$passwd );
553                            $bot->update("<${channel}> $msg");
554                  }                  }
555    
556      },      },
# Line 669  POE::Session->create( inline_states => Line 673  POE::Session->create( inline_states =>
673    
674                  } elsif ($msg =~ m/^ping/) {                  } elsif ($msg =~ m/^ping/) {
675                          $res = "ping = " . dump( $ping );                          $res = "ping = " . dump( $ping );
676                  } 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*)/) {  
677                          if ( ! defined( $1 ) ) {                          if ( ! defined( $1 ) ) {
678                                  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 = ? });
679                                  $sth->execute( $nick, $channel );                                  $sth->execute( $nick, $channel );
680                                  $res = "config for $nick ";                                  $res = "config for $nick on $channel";
681                                  while ( my ($n,$v) = $sth->fetchrow_array ) {                                  while ( my ($n,$v) = $sth->fetchrow_array ) {
682                                          $res .= "| $n = $v";                                          $res .= " | $n = $v";
683                                  }                                  }
684                          } elsif ( defined( $2 ) ) {                          } elsif ( ! $2 ) {
                                 meta( $nick, $channel, $1, $2 );  
                                 $res = "saved $1 = $2";  
                         } else {  
685                                  my $val = meta( $nick, $channel, $1 );                                  my $val = meta( $nick, $channel, $1 );
686                                  $res = "current $1 = " . ( $val ? $val : 'undefined' );                                  $res = "current $1 = " . ( $val ? $val : 'undefined' );
687                            } else {
688                                    my $validate = {
689                                            'last-size' => qr/^\d+/,
690                                            'twitter' => qr/^\w+\s+\w+/,
691                                    };
692    
693                                    my ( $op, $val ) = ( $1, $2 );
694    
695                                    if ( my $regex = $validate->{$op} ) {
696                                            if ( $val =~ $regex ) {
697                                                    meta( $nick, $channel, $op, $val );
698                                                    $res = "saved $op = $val";
699                                            } else {
700                                                    $res = "config option $op = $val doesn't validate against $regex";
701                                            }
702                                    } else {
703                                            $res = "config option $op doesn't exist";
704                                    }
705                          }                          }
706                  }                  }
707    

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

  ViewVC Help
Powered by ViewVC 1.1.26