X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FAnnTalk.pm;h=8c702e4edffc214a3dac6f311454690e31418f35;hb=refs%2Fheads%2Fstaging;hp=f6b4653d28d497b9a854de43a206dc470eb86a58;hpb=99077d96c91df307092394bf1028212adeec4c37;p=spider.git diff --git a/perl/AnnTalk.pm b/perl/AnnTalk.pm index f6b4653d..8c702e4e 100644 --- a/perl/AnnTalk.pm +++ b/perl/AnnTalk.pm @@ -10,15 +10,17 @@ package AnnTalk; use strict; +use DXVars; use DXUtil; use DXDebug; use DXDupe; -use DXVars; +use DXLog; +use DXLogPrint; use vars qw(%dup $duplth $dupage $filterdef); $duplth = 30; # the length of text to use in the deduping -$dupage = 5*3600; # the length of time to hold ann dups +$dupage = 18*3600; # the length of time to hold ann dups $filterdef = bless ([ # tag, sort, field, priv, special parser ['by', 'c', 0], @@ -36,7 +38,24 @@ $filterdef = bless ([ ['origin_zone', 'nz', 12], ['by_state', 'nz', 13], ['origin_state', 'nz', 14], - ], 'Filter::Cmd'); + ], 'Filter::Cmd'); + +our $maxcache = 130; +our @anncache; + +sub init +{ + @anncache = DXLog::search(0, $maxcache, $main::systime, 'ann'); + shift @anncache while @anncache > $maxcache; + my $l = @anncache; + dbg("AnnTalk: loaded last $l announcements into cache"); +} + +sub add_anncache +{ + push @anncache, [ $main::systime, @_ ]; + shift @anncache while @anncache > $maxcache; +} # enter the spot for dup checking and return true if it is already a dup sub dup @@ -66,6 +85,7 @@ sub is_talk_candidate { my ($from, $text) = @_; my $call; + ($call) = $text =~ /^\s*(?:[Xx]|[Tt][Oo]?:?)\s+([\w-]+)/; ($call) = $text =~ /^\s*>\s*([\w-]+)\b/ unless $call; ($call) = $text =~ /^\s*([\w-]+):?\b/ unless $call;