665 |
return; |
return; |
666 |
} |
} |
667 |
|
|
668 |
|
$_stat->{rss}->{url2link}->{ $args->{url} } = $feed->link; |
669 |
|
|
670 |
my ( $total, $updates ) = ( 0, 0 ); |
my ( $total, $updates ) = ( 0, 0 ); |
671 |
for my $entry ($feed->entries) { |
for my $entry ($feed->entries) { |
672 |
$total++; |
$total++; |
957 |
} |
} |
958 |
} elsif ($msg =~ m/^rss-update/) { |
} elsif ($msg =~ m/^rss-update/) { |
959 |
$res = rss_fetch_all( $_[KERNEL] ); |
$res = rss_fetch_all( $_[KERNEL] ); |
|
} elsif ($msg =~ m/^rss-clean/) { |
|
|
$_stat->{rss} = undef; |
|
|
$dbh->do( qq{ update feeds set last_update = now() - delay } ); |
|
|
$res = "OK, cleaned RSS cache"; |
|
960 |
} elsif ($msg =~ m/^rss-list/) { |
} elsif ($msg =~ m/^rss-list/) { |
961 |
my $sth = $dbh->prepare(qq{ select url,name,last_update,active,channel,nick,private from feeds }); |
my $sth = $dbh->prepare(qq{ select url,name,last_update,active,channel,nick,private from feeds }); |
962 |
$sth->execute; |
$sth->execute; |
964 |
$_[KERNEL]->post( $irc => privmsg => $nick, join(' | ',@row) ); |
$_[KERNEL]->post( $irc => privmsg => $nick, join(' | ',@row) ); |
965 |
} |
} |
966 |
$res = ''; |
$res = ''; |
967 |
} elsif ($msg =~ m!^rss-(add|remove|stop|start)(?:-(private))?\s+(http://\S+)\s*(.*)!) { |
} elsif ($msg =~ m!^rss-(add|remove|stop|start|clean)(?:-(private))?\s+(http://\S+)\s*(.*)!) { |
968 |
my ( $command, $sub, $url, $arg ) = ( $1,$2,$3,$4 ); |
my ( $command, $sub, $url, $arg ) = ( $1,$2,$3,$4 ); |
969 |
|
|
970 |
my $channel = $1 if ( $arg =~ s/\s*(#\S+)\s*// ); |
my $channel = $1 if ( $arg =~ s/\s*(#\S+)\s*// ); |
975 |
# remove => qq{ delete from feeds where url = ? and name = ? }, |
# remove => qq{ delete from feeds where url = ? and name = ? }, |
976 |
start => qq{ update feeds set active = true where url = ? }, |
start => qq{ update feeds set active = true where url = ? }, |
977 |
stop => qq{ update feeds set active = false where url = ? }, |
stop => qq{ update feeds set active = false where url = ? }, |
978 |
|
clean => qq{ update feeds set last_update = now() - delay where url = ? }, |
979 |
}; |
}; |
980 |
|
|
981 |
if ( $command eq 'add' && ! $channel ) { |
if ( $command eq 'add' && ! $channel ) { |
991 |
if ($@) { |
if ($@) { |
992 |
$res = "ERROR: $@"; |
$res = "ERROR: $@"; |
993 |
} else { |
} else { |
994 |
$res = "OK, RSS [$command|$sub|$url|$arg]"; |
$res = "OK, RSS executed $command " . ( $sub ? "-$sub" : '' ) ."on $channel url $url"; |
995 |
|
if ( $command eq 'clean' ) { |
996 |
|
my $seen = $_stat->{rss}->{seen} || die "no seen?"; |
997 |
|
my $want_link = $_stat->{rss}->{url2link}->{$url} || warn "no url2link($url)"; |
998 |
|
foreach my $c ( keys %$seen ) { |
999 |
|
my $c_hash = $seen->{$c} || die "no seen->{$c}"; |
1000 |
|
die "not HASH with rss links but ", dump($c_hash) unless ref($c_hash) eq 'HASH'; |
1001 |
|
foreach my $link ( keys %$c_hash ) { |
1002 |
|
next unless $link eq $want_link; |
1003 |
|
_log "RSS removed seen $c $url $link"; |
1004 |
|
} |
1005 |
|
} |
1006 |
|
} |
1007 |
} |
} |
1008 |
} else { |
} else { |
1009 |
$res = "ERROR: don't know what to do with: $msg"; |
$res = "ERROR: don't know what to do with: $msg"; |
1010 |
} |
} |
1011 |
|
} elsif ($msg =~ m/^rss-clean/) { |
1012 |
|
# this makes sense because we didn't catch rss-clean http://... before! |
1013 |
|
$_stat->{rss} = undef; |
1014 |
|
$dbh->do( qq{ update feeds set last_update = now() - delay } ); |
1015 |
|
$res = "OK, cleaned RSS cache"; |
1016 |
} |
} |
1017 |
|
|
1018 |
if ($res) { |
if ($res) { |