started the addition of help files
[spider.git] / cmd / dx.pl
1 #
2 # the DX command
3 #
4 # this is where the fun starts!
5 #
6 # Copyright (c) 1998 Dirk Koopman G1TLH
7 #
8 # $Id$
9 #
10
11 my ($self, $line) = @_;
12 my @f = split /\s+/, $line;
13 my $spotter = $self->call;
14 my $spotted;
15 my $freq;
16 my @out;
17
18 # first lets see if we think we have a callsign as the first argument
19 if ($f[0] =~ /[A-Za-z]/) {
20   $spotter = uc $f[0];
21   $freq = $f[1];
22   $spotted = uc $f[2];
23   $line =~ s/^$f[0]\s+$f[1]\s+$f[2]\s*//;
24 } else {
25   $freq = $f[0];
26   $spotted = uc $f[1]; 
27   $line =~ s/^$f[0]\s+$f[1]\s*//;
28 }
29
30 # check the freq, if the number is < 1800 it is in Mhz (probably)
31 $freq = $freq * 1000 if $freq < 1800;
32
33 # bash down the list of bands until a valid one is reached
34 my $valid = 0;
35 my $bandref;
36 my @bb;
37 my $i;
38
39 L1:
40 foreach $bandref (Bands::get_all()) {
41   @bb = @{$bandref->band};
42   for ($i = 0; $i < @bb; $i += 2) {
43     if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
44           $valid = 1;
45           last L1;
46         }
47   }
48 }
49
50 push @out, "Frequency $freq not in band [usage: DX freq call comments]" if !$valid;
51 return (1, @out) if !$valid;
52
53 # send orf to the users
54 my $buf = sprintf "DX de %-7.7s %13.1f %-12.12s %-30.30s %5.5s\a\a", $spotter, $freq, $spotted, $line, ztime(time);
55 DXProt::broadcast_users($buf);
56
57 # Store it here
58 Spot::add($freq, $spotted, time, $line, $spotter);
59
60 # send it orf to the cluster (hang onto your tin helmets)!
61 DXProt::broadcast_ak1a(DXProt::pc11($spotter, $freq, $spotted, $line));
62
63 return (1, @out);