2 # Announce and Talk Handling routines
4 # Copyright (c) 2000 Dirk Koopman
20 use vars qw(%dup $duplth $dupage $filterdef);
22 $duplth = 30; # the length of text to use in the deduping
23 $dupage = 18*3600; # the length of time to hold ann dups
25 # tag, sort, field, priv, special parser
36 ['origin_dxcc', 'nc', 10],
37 ['origin_itu', 'ni', 11],
38 ['origin_zone', 'nz', 12],
39 ['by_state', 'nz', 13],
40 ['origin_state', 'nz', 14],
48 @anncache = DXLog::search(0, $maxcache, $main::systime, 'ann');
49 shift @anncache while @anncache > $maxcache;
51 dbg("AnnTalk: loaded last $l announcements into cache");
56 push @anncache, [ $main::systime, @_ ];
57 shift @anncache while @anncache > $maxcache;
60 # enter the spot for dup checking and return true if it is already a dup
63 my ($call, $to, $text, $t) = @_;
65 $t ||= $main::systime + $dupage;
68 $text =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
69 # $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
70 $text =~ s/[^\#a-zA-Z0-9]//g;
71 $text = substr($text, 0, $duplth) if length $text > $duplth;
72 my $dupkey = "A$call|$to|\L$text";
73 return DXDupe::check($dupkey, $t);
78 return DXDupe::listdups('A', $dupage, @_);
81 # is this text field a likely announce to talk substitution?
82 # this may involve all sorts of language dependant heuristics, but
83 # then again, it might not
86 my ($from, $text) = @_;
89 ($call) = $text =~ /^\s*(?:[Xx]|[Tt][Oo]?:?)\s+([\w-]+)/;
90 ($call) = $text =~ /^\s*>\s*([\w-]+)\b/ unless $call;
91 ($call) = $text =~ /^\s*([\w-]+):?\b/ unless $call;
94 return is_callsign($call);