--- trunk/bin/irc-logger.pl 2008/03/07 15:49:23 97
+++ trunk/bin/irc-logger.pl 2008/03/08 00:14:41 100
@@ -117,11 +117,11 @@
# protect HTML from wiki modifications
sub e {
my $t = shift;
- return 'uri_unescape{' . uri_escape($t) . '}';
+ return 'uri_unescape{' . uri_escape($t, '^a-zA-Z0-9') . '}';
}
$m =~ s/($escape_re)/$escape{$1}/gs;
- $m =~ s#($RE{URI}{HTTP})#e(qq{$1})#egs ||
+ $m =~ s#($RE{URI}{HTTP})#e(qq{$1})#egs;
$m =~ s#\/(\w+)\/#$1#gs;
$m =~ s#$tag_regex#e(qq{$1})#egs;
$m =~ s#\*(\w+)\*#$1#gs;
@@ -339,25 +339,26 @@
my @where;
my @args;
+ my $msg;
if (my $search = $args->{search}) {
$search =~ s/^\s+//;
$search =~ s/\s+$//;
push @where, 'message ilike ? or nick ilike ?';
push @args, ( ( '%' . $search . '%' ) x 2 );
- _log "search for '$search'";
+ $msg = "Search for '$search'";
}
if ($args->{tag} && $tags->{ $args->{tag} }) {
push @where, 'id in (' . join(',', @{ $tags->{ $args->{tag} } }) . ')';
- _log "search for tags $args->{tag}";
+ $msg = "Search for tags $args->{tag}";
}
if (my $date = $args->{date} ) {
$date = check_date( $date );
push @where, 'date(time) = ?';
push @args, $date;
- _log "search for date $date";
+ $msg = "search for date $date";
}
$sql .= " where " . join(" and ", @where) if @where;
@@ -371,6 +372,8 @@
eval { $sth->execute( @args ) };
return if $@;
+ my $nr_results = $sth->rows;
+
my $last_row = {
date => '',
time => '',
@@ -391,10 +394,14 @@
return @rows if ($args->{full_rows});
- my @msgs = (
- "Showing " . ($#rows + 1) . " messages..."
+ $msg .= ' produced ' . (
+ $nr_results == 0 ? 'no results' :
+ $nr_results == 0 ? 'one result' :
+ $nr_results . ' results'
);
+ my @msgs = ( $msg );
+
if ($context) {
my @ids = @rows;
@rows = ();
@@ -655,7 +662,6 @@
} elsif ( $link !~ m!^http! ) {
$link = $args->{url} . $link;
}
- $link =~ s!//+!/!g;
my $msg;
$msg .= prefix( 'From: ' , $args->{name} || $feed->title );
@@ -938,7 +944,9 @@
stop => qq{ update feeds set active = false where url = ? },
};
- if (my $q = $sql->{$command} ) {
+ if ( $command eq 'add' && ! $channel ) {
+ $res = "ERROR: got '$msg' which doesn't have #channel in it, ignoring!";
+ } elsif (my $q = $sql->{$command} ) {
my $sth = $dbh->prepare( $q );
my @data = ( $url );
if ( $command eq 'add' ) {
@@ -954,7 +962,6 @@
} else {
$res = "ERROR: don't know what to do with: $msg";
}
-
}
if ($res) {