]> gb7djk.dxcluster.net Git - spider.git/blob - cmd/set/wantrbn.pl
fix missing fields in rbn_cache, add timings
[spider.git] / cmd / set / wantrbn.pl
1 #
2 # set the want rbn (at all)
3 #
4 # Copyright (c) 2020 - Dirk Koopman
5 #
6 #
7 #
8
9 my ($self, $line) = @_;
10 my @args = split /\s+/, uc $line;
11 my $call;
12 my @out;
13
14 my @calls;
15 my @want;
16
17 dbg('set/skimmer @args = "' . join(', ', @args) . '"') if isdbg('set/skim');
18
19 while (@args) {
20         my $a = shift @args;
21         dbg("set/skimmer \$a = $a") if isdbg('set/skim');;
22         if ($a !~ /^(?:FT|BCN|BEA|DXF|CW|PSK|MSK|FSK|RTT|NO)/ && is_callsign($a)) {
23                 return (1, $self->msg('e5')) if $a ne $self->call       && $self->priv < 9;
24                 push @calls, $a;
25                 next;
26         }
27         last unless $a;
28
29         dbg("set/skimmer \$a = $a") if isdbg('set/skim');;
30
31         my ($want) = $a =~ /^(FT|BCN|BEA|DXF|CW|PSK|MSK|FSK|RTT|NO)/;
32         return (1, $self->msg('e39', $a)) unless $want;
33         push @want, $want;
34 }
35
36 dbg('set/skimmer @calls = "' . join(', ', @calls) . '"') if isdbg('set/skim');
37 dbg('set/skimmer @want = "' . join(', ', @want) . '"') if isdbg('set/skim');
38
39 my $s = '';
40
41 push @calls, $self->call unless @calls;
42
43 foreach $call (@calls) {
44         $call = uc $call;
45         my $user = DXUser::get_current($call);
46         if ($user) {
47
48                 dbg(sprintf("set/skimmer before rbn:%d ft:%d bcn:%d cw:%d psk:%d rtty:%d",
49                                         $user->wantrbn,
50                                         $user->wantft,
51                                         $user->wantbeacon,
52                                         $user->wantcw,
53                                         $user->wantpsk,
54                                         $user->wantrtty,
55                                    )) if isdbg('set/skim');
56                 
57                 $user->wantrbn(1);
58                 if (@want) {
59                         $user->wantft(0);
60                         $user->wantbeacon(0);
61                         $user->wantcw(0);
62                         $user->wantpsk(0);
63                         $user->wantrtty(0);
64                         for (@want) {
65                                 $user->wantrbn(0) if /^NO/;
66                                 $user->wantft(1) if /^FT/;
67                                 $user->wantbeacon(1) if /^BCN|BEA|DXF/;
68                                 $user->wantcw(1) if /^CW/;
69                                 $user->wantpsk(1) if /^PSK|MSK|FSK/;
70                                 $user->wantrtty(1) if /^RT/;
71                         }
72                 } elsif ($user->wantrbn) {
73                         $user->wantft(1);
74                         $user->wantbeacon(1);
75                         $user->wantcw(1);
76                         $user->wantpsk(1);
77                         $user->wantrtty(1);
78                 } else {
79                         $user->wantft(0);
80                         $user->wantbeacon(0);
81                         $user->wantcw(0);
82                         $user->wantpsk(0);
83                         $user->wantrtty(0);
84                 }
85
86                 dbg(sprintf("set/skimmer after rbn:%d ft:%d bcn:%d cw:%d psk:%d rtty:%d",
87                                         $user->wantrbn,
88                                         $user->wantft,
89                                         $user->wantbeacon,
90                                         $user->wantcw,
91                                         $user->wantpsk,
92                                         $user->wantrtty,
93                                    )) if isdbg('set/skim');
94                 
95                 my $s = '';
96                 if (@want) {
97                         @want = ();                     # variable reuse!!
98                         push @want, 'CW' if $user->wantcw;
99                         push @want, 'BEACONS' if $user->wantbeacon;
100                         push @want, 'PSK, FSK' if $user->wantpsk;
101                         push @want, 'RTTY' if $user->wantrtty;
102                         push @want, 'FT8 & FT4' if $user->wantft;
103                     $s = join(', ', @want) if @want && $user->wantrbn;
104                 } 
105                 
106                 dbg("set/skimmer \$s = $s") if isdbg('set/skim');;
107                 dbg('set/skimmer @want NOW = "' . join(', ', @want) . '"') if isdbg('set/skim');
108                 
109                 $s ||= $user->wantrbn ? 'ALL MODES' : 'NONE';
110                 $user->put;
111                 push @out, $self->msg('skims', $call, $s);
112         }
113         else {
114                 push @out, $self->msg('e3', "Set Skimmer", $call);
115         }
116 }
117 return (1, @out);