X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FSpot.pm;h=4c7ab06e3bd94b15b7f6be5afcc4a6f5085244f2;hb=211b54d504170a8c9dad2bf25b9ed686d5eeac11;hp=e7a619e0c7e0e42b272b35e2ed1175d5ef3b7103;hpb=44bab9382ffb0bf12639af84729d1c42ac4d9ae2;p=spider.git diff --git a/perl/Spot.pm b/perl/Spot.pm index e7a619e0..4c7ab06e 100644 --- a/perl/Spot.pm +++ b/perl/Spot.pm @@ -18,7 +18,7 @@ use Prefix; use DXDupe; use strict; -use vars qw($fp $maxspots $defaultspots $maxdays $dirprefix $duplth $dupage); +use vars qw($fp $maxspots $defaultspots $maxdays $dirprefix $duplth $dupage $filterdef); $fp = undef; $maxspots = 50; # maximum spots to return @@ -27,6 +27,53 @@ $maxdays = 35; # normal maximum no of days to go back $dirprefix = "spots"; $duplth = 20; # the length of text to use in the deduping $dupage = 3*3600; # the length of time to hold spot dups +$filterdef = bless ([ + # tag, sort, field, priv, special parser + ['freq', 'r', 0, 0, \&decodefreq], + ['call', 'c', 1], + ['info', 't', 3], + ['by', 'c', 4], + ['call_dxcc', 'n', 5], + ['by_dxcc', 'n', 6], + ['origin', 'c', 7, 9], + ['call_itu', 'n', 8], + ['call_zone', 'n', 9], + ['by_itu', 'n', 10], + ['by_zone', 'n', 11], + ['channel', 'n', 12, 9], + ], 'Filter::Cmd'); + + +sub decodefreq +{ + my $dxchan = shift; + my $l = shift; + my @f = split /,/, $l; + my @out; + my $f; + + foreach $f (@f) { + my ($a, $b); + if (m{^\d+/\d+$}) { + push @out, $f; + } elsif (($a, $b) = $f =~ m{^(\w+)(?:/(\w+))?$}) { + $b = lc $b if $b; + my @fr = Bands::get_freq(lc $a, $b); + if (@fr) { + while (@fr) { + $a = shift @fr; + $b = shift @fr; + push @out, "$a/$b"; # add them as ranges + } + } else { + return ('dfreq', $dxchan->msg('dfreq1', $f)); + } + } else { + return ('dfreq', $dxchan->msg('e20', $f)); + } + } + return (0, join(',', @out)); +} sub init { @@ -215,7 +262,8 @@ sub dup chomp $text; $text = substr($text, 0, $duplth) if length $text > $duplth; unpad($text); - my $dupkey = "X$freq|$call|$d|$text"; + $text =~ s/[^a-zA-Z0-9]//g; + my $dupkey = "X$freq|$call|$d|\L$text"; return DXDupe::check($dupkey, $main::systime+$dupage); }