2 # Announce and Talk Handling routines
4 # Copyright (c) 2000 Dirk Koopman
18 use vars qw(%dup $duplth $dupage $filterdef);
20 $duplth = 30; # the length of text to use in the deduping
21 $dupage = 18*3600; # the length of time to hold ann dups
23 # tag, sort, field, priv, special parser
34 ['origin_dxcc', 'nc', 10],
35 ['origin_itu', 'ni', 11],
36 ['origin_zone', 'nz', 12],
37 ['by_state', 'nz', 13],
38 ['origin_state', 'nz', 14],
41 # enter the spot for dup checking and return true if it is already a dup
44 my ($call, $to, $text, $t) = @_;
46 $t ||= $main::systime + $dupage;
49 $text =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
50 # $text = Encode::encode("iso-8859-1", $text) if $main::can_encode && Encode::is_utf8($text, 1);
51 $text =~ s/[^\#a-zA-Z0-9]//g;
52 $text = substr($text, 0, $duplth) if length $text > $duplth;
53 my $dupkey = "A$call|$to|\L$text";
54 return DXDupe::check($dupkey, $t);
59 return DXDupe::listdups('A', $dupage, @_);
62 # is this text field a likely announce to talk substitution?
63 # this may involve all sorts of language dependant heuristics, but
64 # then again, it might not
67 my ($from, $text) = @_;
70 ($call) = $text =~ /^\s*(?:[Xx]|[Tt][Oo]?:?)\s+([\w-]+)/;
71 ($call) = $text =~ /^\s*>\s*([\w-]+)\b/ unless $call;
72 ($call) = $text =~ /^\s*([\w-]+):?\b/ unless $call;
75 return is_callsign($call);