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 LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
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 # check some other things
57 # remove ssid from calls
58 my $callnoid = $self->call;
59 $callnoid =~ s/-\d+$//;
60 my $spotternoid = $spotter;
61 $spotternoid =~ s/-\d+$//;
62 if ($DXProt::baddx->in($spotted)) {
65 if ($DXProt::badspotter->in($callnoid)) {
66 LogDbg('DXCommand', "$self->{call} badspotter with $callnoid ($line)");
69 if ($callnoid ne $spotternoid && $DXProt::badspotter->in($spotternoid)) {
70 LogDbg('DXCommand', "$self->{call} badspotter with $spotternoid ($line)");
74 # make line the rest of the line
76 @f = split /\s+/, $line;
78 # bash down the list of bands until a valid one is reached
85 foreach $bandref (Bands::get_all()) {
86 @bb = @{$bandref->band};
87 for ($i = 0; $i < @bb; $i += 2) {
88 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
98 $freq = $freq * 1000 if $freq;
101 foreach $bandref (Bands::get_all()) {
102 @bb = @{$bandref->band};
103 for ($i = 0; $i < @bb; $i += 2) {
104 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
113 push @out, $self->msg('dx1', $freq) unless $valid;
115 # check we have a callsign :-)
116 if ($spotted le ' ') {
117 push @out, $self->msg('dx2');
121 return (1, @out) unless $valid;
125 if ($self->conn->peerhost) {
126 my $addr = $self->conn->peerhost;
127 $ipaddr = $addr unless !is_ipaddr($addr) || $addr =~ /^127\./ || $addr =~ /^::[0-9a-f]+$/;
130 # Store it here (but only if it isn't baddx)
131 my $t = (int ($main::systime/60)) * 60;
132 return (1, $self->msg('dup')) if Spot::dup($freq, $spotted, $t, $line, $spotter);
133 my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall, $ipaddr);
135 if ($freq =~ /^69/ || $localonly) {
137 # heaven forfend that we get a 69Mhz band :-)
138 if ($freq =~ /^69/) {
139 $self->badcount(($self->badcount||0) + 1);
142 $self->dx_spot(undef, undef, @spot);
149 # send orf to the users
151 DXProt::send_dx_spot($self, DXProt::pc61($spotter, $freq, $spotted, $line, $ipaddr), @spot);
153 DXProt::send_dx_spot($self, DXProt::pc11($spotter, $freq, $spotted, $line), @spot);