add chat/wx/announce handling to PC93
[spider.git] / cmd / wx.pl
index 22b5e0ccc262075b1908d6802837a766c520464d..025729369a55e2e13f5ca85dddbeb218e94aefb2 100644 (file)
--- a/cmd/wx.pl
+++ b/cmd/wx.pl
 my ($self, $line) = @_;
 my @f = split /\s+/, $line;
 my $sort = uc $f[0];
-my @locals = DXCommandmode->get_all();
 my $to;
 my $from = $self->call;
 my $t = ztime(time);
 my $tonode;
-my $sysopflag;
+my $via;
 return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
 return (1, $self->msg('e28')) unless $self->registered;
 
 if ($sort eq "FULL") {
   $line =~ s/^$f[0]\s+//;    # remove it
-  $to = "ALL";
-} elsif ($sort eq "SYSOP") {
-  $line =~ s/^$f[0]\s+//;     # remove it
-  @locals = map { $_->priv >= 5 ? $_ : () } @locals;
-  $to = "SYSOP";
-  $sysopflag = '*';
 } else {
-  $to = "LOCAL";
+  $via = "LOCAL";
 }
+$to = 'WX';
 
-DXChannel::broadcast_list("WX de $from <$t>: $line", 'wx', undef, @locals);
-if ($to ne "LOCAL") {
-  $line =~ s/\^//og;    # remove ^ characters!
-  my $pc = DXProt::pc12($from, $line, $tonode, $sysopflag, 1);
-  DXChannel::broadcast_nodes($pc, $main::me);
+# if this is a 'bad spotter' user then ignore it
+my $nossid = $from;
+my $drop = 0;
+$nossid =~ s/-\d+$//;
+if ($DXProt::badspotter->in($nossid)) {
+       LogDbg('DXCommand', "bad spotter ($self->{call}) made announcement: $line");
+       $drop++;
 }
 
+# have they sworn?
+my @bad;
+if (@bad = BadWords::check($line)) {
+       $self->badcount(($self->badcount||0) + @bad);
+       LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
+       $drop++;
+}
+
+if ($drop) {
+       Log('ann', $to, $from, "[to $from only] $line");
+       $self->send("WX de $from: $line");
+       return (1, ());
+}
+
+Log('ann', $via ? $via : '*', $from, $line);
+$main::me->normal(DXProt::pc93($to, $from, $via, $line));
+
+#DXChannel::broadcast_list("WX de $from <$t>: $line", 'wx', undef, @locals);
+#if ($to ne "LOCAL") {
+#  $line =~ s/\^//og;    # remove ^ characters!
+#  my $pc = DXProt::pc12($from, $line, $tonode, $sysopflag, 1);
+#  DXChannel::broadcast_nodes($pc, $main::me);
+#}
+
 return (1, ());