From 0c1082247c57a0ec2fa35a0a81af54b1e6ac2b89 Mon Sep 17 00:00:00 2001 From: minima Date: Tue, 23 Jan 2007 22:41:40 +0000 Subject: [PATCH] add chat/wx/announce handling to PC93 --- cmd/announce.pl | 29 +++++++++++--------------- cmd/chat.pl | 4 +++- cmd/wx.pl | 48 +++++++++++++++++++++++++++++++------------- perl/DXProt.pm | 11 +++++++--- perl/DXProtHandle.pm | 15 ++++++++++---- 5 files changed, 68 insertions(+), 39 deletions(-) diff --git a/cmd/announce.pl b/cmd/announce.pl index a3ccb5b0..a3d3fd61 100644 --- a/cmd/announce.pl +++ b/cmd/announce.pl @@ -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, ()); diff --git a/cmd/chat.pl b/cmd/chat.pl index 41cbb5ca..80cb1266 100644 --- a/cmd/chat.pl +++ b/cmd/chat.pl @@ -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, ()); diff --git a/cmd/wx.pl b/cmd/wx.pl index 22b5e0cc..02572936 100644 --- a/cmd/wx.pl +++ b/cmd/wx.pl @@ -17,32 +17,52 @@ 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, ()); diff --git a/perl/DXProt.pm b/perl/DXProt.pm index 220c689c..9a0b2121 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -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"); } } diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index d8e9f2f7..a1b2bec3 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -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); } -- 2.43.0