rbn, ve7cc improvements and fixes
[spider.git] / cmd / show / rbn.pl
1 #
2 # show/rbn [all|<call>,,,]
3
4 # This command either lists all rbn users known about (sh/rbn all)
5 # or the ones specified on the command line, If no arguments are present
6 # then it will list all connected rbn/skimmer users.
7 #
8 # Copyright (c) 2020 Dirk Koopman G1TLH
9 #
10
11
12 my ($self, $line) = @_;
13 return (1, $self->msg('e5')) unless $self->priv >= 1;
14
15 my @call = map {uc $_} split /\s+/, $line; 
16 my @out;
17 my $count;
18
19 # search thru the user
20 if (@call == 0) {
21         @call = sort map{$_->call} grep {$_->user->call && $_->user->wantrbn} DXChannel::get_all_users();
22 } elsif ($call[0] eq 'ALL') {
23         shift @call;
24         my ($action, $key, $data) = (0,0,0);
25         for ($action = DXUser::R_FIRST, $count = 0; !$DXUser::dbm->seq($key, $data, $action); $action = DXUser::R_NEXT) {
26                 if (is_callsign($key)) {
27                         if ($data =~ /"sort":"[UW]"/  && $data =~ /"wantrbn":1/) {
28                                 push @call, $key;
29                         }
30                 }
31         }
32 }
33
34 push @out, join(' ', $self->msg('rbnusers'), $main::mycall);
35 my @l;
36
37 foreach my $call (@call) {
38         push @l, $call;
39         if (@l >= 5) {
40                 push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
41                 @l = ();
42         }
43         ++$count;
44 }
45 if (@l) {
46         push @l, "" while @l < 5;
47         push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
48 }
49         
50
51 return (1, @out, $self->msg('rec', $count));
52
53
54
55