add chat/wx/announce handling to PC93
authorminima <minima>
Tue, 23 Jan 2007 22:41:40 +0000 (22:41 +0000)
committerminima <minima>
Tue, 23 Jan 2007 22:41:40 +0000 (22:41 +0000)
cmd/announce.pl
cmd/chat.pl
cmd/wx.pl
perl/DXProt.pm
perl/DXProtHandle.pm

index a3ccb5b033d7f98dc8a9044212c40f0c3e38dcdc..a3d3fd61718b10a184591041044c1eb9b6fb817a 100644 (file)
@@ -22,32 +22,25 @@ return (1, $self->msg('e9')) if !@f;
 return (1, $self->msg('e28')) unless $self->registered;
 
 my $sort = uc $f[0];
-my @locals = DXCommandmode->get_all();
-my $to;
+my $to = '*';
 my $from = $self->call;
 my $t = ztime(time);
 my $tonode;
 my $toflag = '*';
 my $sysopflag;
+my $via = 'LOCAL';
 
 if ($sort eq "FULL") {
   $line =~ s/^$f[0]\s+//;    # remove it
-  $to = "ALL";
+  $via = $to = "*";
 } elsif ($sort eq "SYSOP") {
   $line =~ s/^$f[0]\s+//;     # remove it
-  @locals = map { $_->priv >= 5 ? $_ : () } @locals;
   $to = "SYSOP";
-  $sysopflag = '*';
+  $via = $sysopflag = '*';
 } elsif ($sort eq "LOCAL") {
   $line =~ s/^$f[0]\s+//;     # remove it
-  $to = "LOCAL";
-} else {
-  $to = "LOCAL";
 }
 
-# change ^ into : for transmission
-$line =~ s/\^/:/og;
-
 # if this is a 'bad spotter' user then ignore it
 my $nossid = $from;
 my $drop = 0;
@@ -67,16 +60,18 @@ if (@bad = BadWords::check($line)) {
 
 if ($drop) {
        Log('ann', $to, $from, "[to $from only] $line");
-       $self->send("To $to de $from <$t>: $line");
+       $self->send("To $to de $from: $line");
        return (1, ());
 }
 
 return (1, $self->msg('dup')) if $self->priv < 5 && AnnTalk::dup($from, $toflag, $line);
 Log('ann', $to, $from, $line);
-DXChannel::broadcast_list("To $to de $from ($t): $line\a", 'ann', undef, @locals);
-if ($to ne "LOCAL") {
-  my $pc = DXProt::pc12($from, $line, $tonode, $sysopflag, 0);
-  DXChannel::broadcast_nodes($pc);
-}
+$main::me->normal(DXProt::pc93($to, $from, $via, $line));
+
+#DXChannel::broadcast_list("To $to de $from ($t): $line\a", 'ann', undef, @locals);
+#if ($to ne "LOCAL") {
+#  my $pc = DXProt::pc12($from, $line, $tonode, $sysopflag, 0);
+#  DXChannel::broadcast_nodes($pc);
+#}
 
 return (1, ());
index 41cbb5caba4b9cde16abe870507f83e6fc310460..80cb12664e49e361e19a4667b694601860d4eae7 100644 (file)
@@ -38,6 +38,8 @@ if (@bad = BadWords::check($line)) {
 my $msgid = DXProt::nextchatmsgid();
 $text = "#$msgid $text";
 
-DXProt::send_chat($self, DXProt::pc12($from, $text, '*', $target), $from, '*', $text, $target, $main::mycall, '0');
+$main::me->normal(DXProt::pc93($to, $from, undef, $text));
+
+#DXProt:):send_chat($self, 1, DXProt::pc12($from, $text, '*', $target), $from, '*', $text, $target, $main::mycall, '0');
 
 return (1, ());
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, ());
index 220c689c2ed2333f9ad7f155b01fe7358f441841..9a0b2121ff17fc9e0d5f3cc6b11e3c25a8fdc97f 100644 (file)
@@ -585,10 +585,11 @@ sub wcy
 sub send_announce
 {
        my $self = shift;
+       my $from_pc9x = shift;
        my $line = shift;
        my @dxchan = DXChannel::get_all();
        my $dxchan;
-       my $target;
+       my $target = $_[6];
        my $to = 'To ';
        my $text = unpad($_[2]);
                                
@@ -597,7 +598,7 @@ sub send_announce
        } elsif ($_[3] gt ' ') { # speciality list handling
                my ($name) = split /\./, $_[3]; 
                $target = "$name"; # put the rest in later (if bothered) 
-       } 
+       }  
        
        if ($_[5] eq '1') {
                $target = "WX"; 
@@ -632,6 +633,8 @@ sub send_announce
        foreach $dxchan (@dxchan) {
                next if $dxchan == $main::me;
                next if $dxchan == $self && $self->is_node;
+               next if $from_pc9x && $dxchan->{do_pc9x};
+               next if $target eq 'LOCAL' && $dxchan->is_node;
                $dxchan->announce($line, $self->{isolate}, $to, $target, $text, @_, $self->{call},
                                                  @a[0..2], @b[0..2]);
        }
@@ -650,6 +653,7 @@ sub nextchatmsgid
 sub send_chat
 {
        my $self = shift;
+       my $from_pc9x = shift;
        my $line = shift;
        my @dxchan = DXChannel::get_all();
        my $dxchan;
@@ -692,10 +696,11 @@ sub send_chat
                if ($dxchan->is_node) {
                        next if $dxchan == $main::me;
                        next if $dxchan == $self;
+                       next if $from_pc9x && $dxchan->{do_pc9x};
                        next unless $dxchan->is_spider || $is_ak1a;
                        next if $target eq 'LOCAL';
                        if (!$ak1a_line && $is_ak1a) {
-                               $ak1a_line = DXProt::pc12($_[0], $text, $_[1], "$target.LST");
+                               $ak1a_line = pc12($_[0], $text, $_[1], "$target.LST");
                        }
                }
                
index d8e9f2f78e8f341ebfe3525e004b56b0ac347cc9..a1b2bec3d0374b7c19d60e332ad3cbfecefe33cc 100644 (file)
@@ -350,7 +350,7 @@ sub handle_12
        my $dxchan;
        
        if ((($dxchan = DXChannel::get($_[2])) && $dxchan->is_user) || $_[4] =~ /^[\#\w.]+$/){
-               $self->send_chat($line, @_[1..6]);
+               $self->send_chat(0, $line, @_[1..6]);
        } elsif ($_[2] eq '*' || $_[2] eq $main::mycall) {
 
                # remember a route
@@ -379,7 +379,7 @@ sub handle_12
                }
        
                # send it
-               $self->send_announce($line, @_[1..6]);
+               $self->send_announce(0, $line, @_[1..6]);
        } else {
                $self->route($_[2], $line);
        }
@@ -1677,10 +1677,17 @@ sub handle_93
                }
 
                # otherwise, drop through and allow it to be broadcast
-       } elsif ($to eq '*' || $to eq 'SYSOP' || $to eq 'WX') {
+       } elsif ($to eq '*' || uc $to eq 'SYSOP' || uc $to eq 'WX') {
                # announces
+               my $sysop = uc $to eq 'SYSOP' ? '*' : ' ';
+               my $wx = uc $to eq 'WX' ? '1' : '0';
+               my $local = $via eq 'LOCAL' ? '*' : $via;
+               
+               $self->send_announce(1, pc12($from, $text, $local, $via, $sysop, $wx, $pcall), $from, $local, $text, $sysop, $pcall, $wx, $via eq 'LOCAL' ? $via : undef);
+               return if $via eq 'LOCAL';
        } else {
-               # chat messages
+               # chat messages to non-pc9x nodes
+               $self->send_chat(1, pc12($from, $text, undef, $to, undef, $pcall), $from, '*', $text, $to, $pcall, '0');
        }
        $self->broadcast_route_pc9x($pcall, undef, $line, 0);
 }