4 # this is where the fun starts!
6 # Copyright (c) 1998 Dirk Koopman G1TLH
11 my ($self, $line) = @_;
12 my @f = split /\s+/, $line, 3;
13 my $spotter = $self->call;
19 return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
20 return (1, $self->msg('e28')) unless $self->registered;
23 if (@bad = BadWords::check($line)) {
24 $self->badcount(($self->badcount||0) + @bad);
25 Log('DXCommand', "$self->{call} swore: $line");
29 # do we have at least two args?
30 return (1, $self->msg('dx2')) unless @f >= 2;
32 # as a result of a suggestion by Steve K9AN, I am changing the syntax of
33 # 'spotted by' things to "dx by g1tlh <freq> <call>" <freq> and <call>
36 if ($f[0] =~ /^by$/i) {
37 return (1, $self->msg('e5')) unless $main::allowdxby || $self->priv;
39 $line =~ s/\s*$f[0]\s+$f[1]\s+//;
41 @f = split /\s+/, $line, 3;
42 return (1, $self->msg('dx2')) unless @f >= 2;
45 # get the freq and callsign either way round
46 if (is_freq($f[1]) && $f[0] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
49 } elsif (is_freq($f[0]) && $f[1] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
53 return (1, $self->msg('dx3'));
56 # make line the rest of the line
58 @f = split /\s+/, $line;
60 # bash down the list of bands until a valid one is reached
67 foreach $bandref (Bands::get_all()) {
68 @bb = @{$bandref->band};
69 for ($i = 0; $i < @bb; $i += 2) {
70 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
80 $freq = $freq * 1000 if $freq;
83 foreach $bandref (Bands::get_all()) {
84 @bb = @{$bandref->band};
85 for ($i = 0; $i < @bb; $i += 2) {
86 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
95 push @out, $self->msg('dx1', $freq) unless $valid;
97 # check we have a callsign :-)
98 if ($spotted le ' ') {
99 push @out, $self->msg('dx2');
103 return (1, @out) unless $valid;
105 # Store it here (but only if it isn't baddx)
106 my $t = (int ($main::systime/60)) * 60;
107 my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall);
108 my $thing = Thingy::Dx->new(user=>$spotter);
109 $thing->from_DXProt(spotdata=>\@spot);
111 if ($DXProt::baddx->in($spotted) || $freq =~ /^69/ || $localonly) {
113 # heaven forfend that we get a 69Mhz band :-)
114 if ($freq =~ /^69/) {
115 $self->badcount(($self->badcount||0) + 1);
118 $thing->queue($self);
120 push @out, $thing->gen_DXCommandmode($self);