--- trunk/bin/irc-logger.pl 2008/03/07 00:43:45 89 +++ trunk/bin/irc-logger.pl 2008/03/07 09:50:53 90 @@ -20,12 +20,6 @@ =item --log=irc-logger.log -Name of log file - -=item --follow=file.log - -Follows new messages in file - =back =head1 DESCRIPTION @@ -50,9 +44,6 @@ $CHANNEL = '#irc-logger' if ($HOSTNAME =~ m/llin/); my $IRC_ALIAS = "log"; -# default log to follow and announce messages -my $follows_path = 'follows.log'; - my $DSN = 'DBI:Pg:dbname=' . $NICK; my $TIMESTAMP = '%Y-%m-%d %H:%M:%S'; @@ -72,7 +63,7 @@ ## END CONFIG -use POE qw(Component::IRC Wheel::FollowTail Component::Server::HTTP); +use POE qw(Component::IRC Component::Server::HTTP); use HTTP::Status; use DBI; use Regexp::Common qw /URI/; @@ -97,7 +88,6 @@ my $log_path; GetOptions( 'import-dircproxy:s' => \$import_dircproxy, - 'follows:s' => \$follows_path, 'log:s' => \$log_path, ); @@ -111,24 +101,6 @@ print strftime($TIMESTAMP,localtime()) . ' ' . join(" ",@_) . $/; } -# LOG following - -my %FOLLOWS = - ( -# ACCESS => "/var/log/apache/access.log", -# ERROR => "/var/log/apache/error.log", - ); - -sub add_follow_path { - my $path = shift; - my $name = $path; - $name =~ s/\..*$//; - warn "# using $path to announce messages from $name\n"; - $FOLLOWS{$name} = $path; -} - -add_follow_path( $follows_path ) if ( -e $follows_path ); - # HTML formatters my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); @@ -670,7 +642,7 @@ } my $msg; - $msg .= prefix( 'From: ' , $feed->title ); + $msg .= prefix( 'From: ' , $args->{name} || $feed->title ); $msg .= prefix( ' by ' , $entry->author ); $msg .= prefix( ' -- ' , $entry->link ); # $msg .= prefix( ' id ' , $entry->id ); @@ -719,7 +691,7 @@ my $kernel = shift; my $last_t = $_rss->{last_poll} || time(); my $t = time(); - if ( $last_t - $t > $rss_min_delay ) { + if ( $t - $last_t > $rss_min_delay ) { $_rss->{last_poll} = $t; _log rss_fetch_all( $kernel ); } @@ -732,8 +704,6 @@ # POE handing part # -my $SKIPPING = 0; # if skipping, how many we've done -my $SEND_QUEUE; # cache my $ping; # ping stats POE::Component::IRC->new($IRC_ALIAS); @@ -925,6 +895,7 @@ $res = rss_fetch_all( $_[KERNEL] ); } elsif ($msg =~ m/^rss-clean/) { $_rss = undef; + $dbh->do( qq{ update feeds set last_update = now() - delay } ); $res = "OK, cleaned RSS cache"; } elsif ($msg =~ m!^rss-(add|remove|stop|start)\s+(http://\S+)\s*(.*)!) { my $sql = { @@ -940,7 +911,7 @@ eval { $sth->execute( $2, $3 ) }; } - $res ||= "OK, RSS $1 : $2 - $3"; + $res = "OK, RSS $1 : $2 - $3"; } if ($res) {