73 |
use HTML::CalendarMonthSimple; |
use HTML::CalendarMonthSimple; |
74 |
use Getopt::Long; |
use Getopt::Long; |
75 |
use DateTime; |
use DateTime; |
76 |
|
use URI::Escape; |
77 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
78 |
|
use DateTime::Format::ISO8601; |
79 |
|
|
80 |
my $use_twitter = 1; |
my $use_twitter = 1; |
81 |
eval { require Net::Twitter; }; |
eval { require Net::Twitter; }; |
262 |
|
|
263 |
$sql .= " where message ilike ? or nick ilike ? " if ($args->{search}); |
$sql .= " where message ilike ? or nick ilike ? " if ($args->{search}); |
264 |
$sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} }); |
$sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} }); |
265 |
$sql .= " where date(time) = ? " if ($args->{date}); |
if ($args->{date}) { |
266 |
|
my $date = eval { DateTime::Format::ISO8601->parse_datetime( $args->{date} )->ymd; }; |
267 |
|
if ( $@ ) { |
268 |
|
warn "invalid date ", $args->{date}, $/; |
269 |
|
$date = DateTime->now->ymd; |
270 |
|
} |
271 |
|
$sql .= " where date(time) = ? "; |
272 |
|
$args->{date} = $date; |
273 |
|
} |
274 |
$sql .= " order by log.time desc"; |
$sql .= " order by log.time desc"; |
275 |
$sql .= " limit " . $args->{limit} if ($args->{limit}); |
$sql .= " limit " . $args->{limit} if ($args->{limit}); |
276 |
|
|
560 |
save_message( channel => $channel, me => 1, nick => $nick, msg => $msg); |
save_message( channel => $channel, me => 1, nick => $nick, msg => $msg); |
561 |
|
|
562 |
if ( $use_twitter ) { |
if ( $use_twitter ) { |
563 |
if ( my $twitter = meta( $nick, $channel, 'twitter' ) ) { |
if ( my $twitter = meta( $nick, $NICK, 'twitter' ) ) { |
564 |
my ($login,$passwd) = split(/\s+/,$twitter,2); |
my ($login,$passwd) = split(/\s+/,$twitter,2); |
565 |
_log("sending twitter for $nick/$login on $channel "); |
_log("sending twitter for $nick/$login on $channel "); |
566 |
my $bot = Net::Twitter->new( username=>$login, password=>$passwd ); |
my $bot = Net::Twitter->new( username=>$login, password=>$passwd ); |
612 |
|
|
613 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
614 |
select |
select |
615 |
nick, |
trim(both '_' from nick) as nick, |
616 |
count(*) as count, |
count(*) as count, |
617 |
sum(length(message)) as len |
sum(length(message)) as len |
618 |
from log |
from log |
619 |
group by nick |
group by trim(both '_' from nick) |
620 |
order by len desc,count desc |
order by len desc,count desc |
621 |
limit $nr |
limit $nr |
622 |
}); |
}); |
845 |
.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 ; } |
846 |
.message { color: #000000; font-size: 100%; } |
.message { color: #000000; font-size: 100%; } |
847 |
.search { float: right; } |
.search { float: right; } |
848 |
|
a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none } |
849 |
|
a:hover.tag { border: 1px solid #eee } |
850 |
|
hr { border: 1px dashed #ccc; height: 1px; clear: both; } |
851 |
|
/* |
852 |
.col-0 { background: #ffff66 } |
.col-0 { background: #ffff66 } |
853 |
.col-1 { background: #a0ffff } |
.col-1 { background: #a0ffff } |
854 |
.col-2 { background: #99ff99 } |
.col-2 { background: #99ff99 } |
855 |
.col-3 { background: #ff9999 } |
.col-3 { background: #ff9999 } |
856 |
.col-4 { background: #ff66ff } |
.col-4 { background: #ff66ff } |
857 |
a:link.tag, a:visited.tag { border: 1px dashed #ccc; backgound: #ccc; text-decoration: none } |
*/ |
|
a:hover.tag { border: 1px solid #eee } |
|
|
hr { border: 1px dashed #ccc; height: 1px; clear: both; } |
|
858 |
_END_OF_STYLE_ |
_END_OF_STYLE_ |
859 |
|
|
860 |
my $max_color = 4; |
my $max_color = 4; |
861 |
|
|
862 |
|
my @cols = qw( |
863 |
|
#ffcccc #ccffe6 #ccccff #e6ccff #ffccff #ffcce6 #ff9999 #ffcc99 #ffff99 |
864 |
|
#ccff99 #99ff99 #99ffcc #99ccff #9999ff #cc99ff #ff6666 #ffb366 #ffff66 |
865 |
|
#66ff66 #66ffb3 #66b3ff #6666ff #ff3333 #33ff33 #3399ff #3333ff #ff3399 |
866 |
|
#a0a0a0 #ff0000 #ffff00 #80ff00 #0000ff #8000ff #ff00ff #ff0080 #994d00 |
867 |
|
#999900 #009900 #cc0066 #c0c0c0 #ccff99 #99ff33 #808080 #660033 #ffffff |
868 |
|
); |
869 |
|
|
870 |
|
$max_color = 0; |
871 |
|
foreach my $c (@cols) { |
872 |
|
$style .= ".col-${max_color} { background: $c }\n"; |
873 |
|
$max_color++; |
874 |
|
} |
875 |
|
warn "defined $max_color colors for users...\n"; |
876 |
|
|
877 |
my %nick_enumerator; |
my %nick_enumerator; |
878 |
|
|
879 |
sub root_handler { |
sub root_handler { |
951 |
filter => { |
filter => { |
952 |
message => sub { |
message => sub { |
953 |
my $m = shift || return; |
my $m = shift || return; |
954 |
|
|
955 |
|
# protect HTML from wiki modifications |
956 |
|
sub e { |
957 |
|
my $t = shift; |
958 |
|
return 'uri_unescape{' . uri_escape($t) . '}'; |
959 |
|
} |
960 |
|
|
961 |
$m =~ s/($escape_re)/$escape{$1}/gs; |
$m =~ s/($escape_re)/$escape{$1}/gs; |
962 |
$m =~ s#($RE{URI}{HTTP})#<a href="$1">$1</a>#gs; |
$m =~ s#($RE{URI}{HTTP})#e(qq{<a href="$1">$1</a>})#egs; |
963 |
$m =~ s#$tag_regex#<a href="?tag=$1" class="tag">$1</a>#g; |
$m =~ s#$tag_regex#e(qq{<a href="?tag=$1" class="tag">$1</a>})#egs; |
964 |
|
$m =~ s#\*(\w+)\*#<b>$1</b>#gs; |
965 |
|
$m =~ s#_(\w+)_#<u>$1</u>#gs; |
966 |
|
$m =~ s#\/(\w+)\/#<i>$1</i>#gs; |
967 |
|
|
968 |
|
$m =~ s#uri_unescape{([^}]+)}#uri_unescape($1)#egs; |
969 |
return $m; |
return $m; |
970 |
}, |
}, |
971 |
nick => sub { |
nick => sub { |