make the badspotter log slightly more obvious
[spider.git] / cmd / announce.pl
1 #
2 # do an announce message 
3 #
4 # handles announce
5 #         announce full
6 #         announce sysop
7 #
8 # at the moment these keywords are fixed, but I dare say a file containing valid ones
9 # will appear
10 #
11 # Copyright (c) 1998 Dirk Koopman G1TLH
12 #
13 # $Id$
14 #
15 # Modified 13Dec98 Iain Phillips G0RDI
16 #
17
18 my ($self, $line) = @_;
19 my @f = split /\s+/, $line;
20 return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
21 return (1, $self->msg('e9')) if !@f;
22 return (1, $self->msg('e28')) unless $self->registered;
23
24 my $sort = uc $f[0];
25 my @locals = DXCommandmode->get_all();
26 my $to;
27 my $from = $self->call;
28 my $t = ztime(time);
29 my $tonode;
30 my $toflag = '*';
31 my $sysopflag;
32
33 if ($sort eq "FULL") {
34   $line =~ s/^$f[0]\s+//;    # remove it
35   $to = "ALL";
36 } elsif ($sort eq "SYSOP") {
37   $line =~ s/^$f[0]\s+//;     # remove it
38   @locals = map { $_->priv >= 5 ? $_ : () } @locals;
39   $to = "SYSOP";
40   $sysopflag = '*';
41 } elsif ($sort eq "LOCAL") {
42   $line =~ s/^$f[0]\s+//;     # remove it
43   $to = "LOCAL";
44 } else {
45   $to = "LOCAL";
46 }
47
48 # change ^ into : for transmission
49 $line =~ s/\^/:/og;
50
51 # if this is a 'bad spotter' user then ignore it
52 my $nossid = $from;
53 my $drop = 0;
54 $nossid =~ s/-\d+$//;
55 if ($DXProt::badspotter->in($nossid)) {
56         LogDbg('DXCommand', "bad spotter ($from) made announcement: $line");
57         $drop++;
58 }
59
60 # have they sworn?
61 my @bad;
62 if (@bad = BadWords::check($line)) {
63         $self->badcount(($self->badcount||0) + @bad);
64         LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
65         $drop++;
66 }
67
68 if ($drop) {
69         Log('ann', $to, $from, "[to $from only] $line");
70         $self->send("To $to de $from <$t>: $line");
71         return (1, ());
72 }
73
74 return (1, $self->msg('dup')) if $self->priv < 5 && AnnTalk::dup($from, $toflag, $line);
75 Log('ann', $to, $from, $line);
76 DXChannel::broadcast_list("To $to de $from ($t): $line\a", 'ann', undef, @locals);
77 if ($to ne "LOCAL") {
78   my $pc = DXProt::pc12($from, $line, $tonode, $sysopflag, 0);
79   DXChannel::broadcast_nodes($pc);
80 }
81
82 return (1, ());