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 ); |
676 |
$res = "config for $nick "; |
$res = "config for $nick on $channel"; |
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 |
|
|