staging commt for badword and badip
[spider.git] / cmd / show / badword.pl
1 #
2 # show list of bad dx callsigns
3 #
4 # Copyright (c) 2023 - Dirk Koopman G1TLH
5 #
6 #
7 #
8
9 my ($self, $line) = @_;
10 return (1, $self->msg('e5')) if $self->remotecmd;
11 # are we permitted?
12 return (1, $self->msg('e5')) if $self->priv < 6;
13
14 my @out;
15 my @l;
16 my $count = 0;
17 my @words = BadWords::check($line);
18 my $cand;
19 my $w;
20
21 push @out, "Words: " . join ',', @words; 
22
23 if ($line =~ /^\s*full/i || @words) {
24         foreach $w (BadWords::list_regex(1)) {
25                 ++$count;
26                 if ($line =~ /^\s*full/) {
27                         push @out, $w; 
28                 } elsif (@words) {
29                     ($cand) = split /\s+/, $w;
30                         #push @out, "cand: $cand"; 
31                         push @out, $w if grep {$cand eq $_} @words; 
32                 }
33         }
34 }
35 else {
36         foreach my $w (BadWords::list_regex()) {
37                 ++$count;
38                 if (@l >= 5) {
39                         push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
40                         @l = ();
41                 }
42                 push @l, $w;
43         }
44         push @l, "" while @l < 5;
45         push @out, sprintf "%-12s %-12s %-12s %-12s %-12s", @l;
46 }
47
48 push @out, "$count BadWords";
49         
50 return (1, @out);
51