2 # Announce and Talk Handling routines
4 # Copyright (c) 2000 Dirk Koopman
18 use vars qw(%dup $duplth $dupage $filterdef);
20 $duplth = 60; # the length of text to use in the deduping
21 $dupage = 5*24*3600; # the length of time to hold spot 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 use vars qw($VERSION $BRANCH);
42 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
43 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
44 $main::build += $VERSION;
45 $main::branch += $BRANCH;
47 # enter the spot for dup checking and return true if it is already a dup
50 my ($call, $to, $text) = @_;
54 $text =~ s/\%([0-9A-F][0-9A-F])/chr(hex($1))/eg;
55 $text = substr($text, 0, $duplth) if length $text > $duplth;
56 $text = pack("C*", map {$_ & 127} unpack("C*", $text));
57 $text =~ s/[^a-zA-Z0-9]//g;
58 my $dupkey = "A$to|\L$text";
59 return DXDupe::check($dupkey, $main::systime + $dupage);
64 return DXDupe::listdups('A', $dupage, @_);
67 # is this text field a likely announce to talk substitution?
68 # this may involve all sorts of language dependant heuristics, but
69 # then again, it might not
72 my ($from, $text) = @_;
74 ($call) = $text =~ /^\s*(?:[Xx]|[Tt][Oo]?:?)\s+([\w-]+)/;
75 ($call) = $text =~ /^\s*>\s*([\w-]+)\b/ unless $call;
76 ($call) = $text =~ /^\s*([\w-]+):?\b/ unless $call;
79 return is_callsign($call);