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;
23 return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
24 return (1, $self->msg('e28')) unless $self->isregistered;
27 my $addr = $self->hostname || '127.0.0.1';
28 Log('cmd', "$self->{call}|$addr|dx|$line");
31 if (@bad = BadWords::check($line)) {
32 $self->badcount(($self->badcount||0) + @bad);
33 LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
37 # do we have at least two args?
38 return (1, $self->msg('dx2')) unless @f >= 2;
40 # as a result of a suggestion by Steve K9AN, I am changing the syntax of
41 # 'spotted by' things to "dx by g1tlh <freq> <call>" <freq> and <call>
44 if ($f[0] =~ /^by$/i) {
45 return (1, $self->msg('e5')) unless $main::allowdxby || $self->priv > 1;
47 $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
48 @f = split /\s+/, $line, 3;
49 return (1, $self->msg('dx2')) unless @f >= 2;
53 @f = split /\s+/, $line, 3;
55 return (1, $self->msg('e5')) unless $spotter && $self->priv > 1;
56 if (is_ipaddr($f[1])) {
59 return (1, $self->msg('dx4', $f[1]));
61 $line =~ s/^\s*$f[0]\s+$f[1]\s+//;
62 @f = split /\s+/, $line, 3;
66 # get the freq and callsign either way round
67 if (is_freq($f[1]) && $f[0] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
70 } elsif (is_freq($f[0]) && $f[1] =~ m{^[\w\d]+(?:/[\w\d]+){0,2}$}) {
74 return (1, $self->msg('dx3'));
76 $line =~ s/^\s*$f[0]//;
77 $line =~ s/^\s*$f[1]//;
78 $line =~ unpad($line);
79 $line =~ s/\t+/ /g; # do this here because it needs to be stopped ASAP!
82 if ($self->conn && $self->conn->peerhost) {
83 $ipaddr ||= $addr; # force a PC61
84 } elsif ($self->inscript) {
88 # check some other things
89 # remove ssid from calls
90 my $spotternoid = basecall($spotter);
91 my $callnoid = basecall($self->{call});
95 if ($DXProt::baddx->in($spotted)) {
98 if ($DXProt::badspotter->in($spotternoid) || $self->badip) {
99 LogDbg('DXCommand', "badspotter $spotternoid as $spotter ($oline) from $addr");
103 dbg "spotter $spotternoid/$callnoid\n";
105 if (($spotted =~ /$spotternoid/ || $spotted =~ /$callnoid/) && $freq < $Spot::minselfspotqrg) {
106 LogDbg('DXCommand', "$spotternoid/$callnoid trying to self spot below ${Spot::minselfspotqrg}KHz ($oline) from $addr, not passed on to cluster");
110 # bash down the list of bands until a valid one is reached
117 foreach $bandref (Bands::get_all()) {
118 @bb = @{$bandref->band};
119 for ($i = 0; $i < @bb; $i += 2) {
120 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
130 $freq = $freq * 1000 if $freq;
133 foreach $bandref (Bands::get_all()) {
134 @bb = @{$bandref->band};
135 for ($i = 0; $i < @bb; $i += 2) {
136 if ($freq >= $bb[$i] && $freq <= $bb[$i+1]) {
145 push @out, $self->msg('dx1', $freq) unless $valid;
147 # check we have a callsign :-)
148 if ($spotted le ' ') {
149 push @out, $self->msg('dx2');
153 return (1, @out) unless $valid;
155 # Store it here (but only if it isn't baddx)
156 my $t = (int ($main::systime/60)) * 60;
157 return (1, $self->msg('dup')) if Spot::dup($freq, $spotted, $t, $line, $spotter, $main::mycall);
158 my @spot = Spot::prepare($freq, $spotted, $t, $line, $spotter, $main::mycall, $ipaddr);
162 if ($freq =~ /^69/ || $localonly) {
164 # heaven forfend that we get a 69Mhz band :-)
165 if ($freq =~ /^69/) {
166 $self->badcount(($self->badcount||0) + 1);
169 $self->dx_spot(undef, undef, @spot);
173 # send orf to the users
174 $ipaddr ||= $main::mycall; # emergency backstop
175 my $spot = DXProt::pc61($spotter, $freq, $spotted, unpad($line), $ipaddr);
177 $self->dx_spot(undef, undef, @spot);
178 if ($self->isslugged) {
179 push @{$self->{sluggedpcs}}, [61, $spot, \@spot];
181 # store in spots database
183 DXProt::send_dx_spot($self, $spot, @spot);