X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FSpot.pm;h=9c10796b8ef4f924f9dc46cbb4eeb9c5053d5cb2;hb=9a1ffd3bd057a47c24e46f380d35aebf29453f93;hp=e2b5c7eff3cd889f9780b153fa02d0049f10950e;hpb=4e359e198dfc0ca889413a72ea20e698b995e094;p=spider.git diff --git a/perl/Spot.pm b/perl/Spot.pm index e2b5c7ef..9c10796b 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,61 @@ $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'); + + +# create a Spot Object +sub new +{ + my $class = shift; + my $self = [ @_ ]; + return bless $self, $class; +} + +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 { @@ -66,7 +121,7 @@ sub add my $spotter_cq = (@dxcc > 0 ) ? $dxcc[1]->cq() : 0; push @out, $spotter_dxcc; push @out, $spot[5]; - + my $buf = join("\^", @out); # compare dates to see whether need to open another save file (remember, redefining $fp