add ak1a compat changes to chat
[spider.git] / perl / DXProt.pm
index 5ddafa5ef6d9ce17730e94dc0ae092d07532a005..d2cf9b8a61d7f1487ff971a94571ef7e48a594b1 100644 (file)
@@ -76,7 +76,7 @@ $chatdupeage = 20 * 60 * 60;
 (
  [ qw(c c m bp bc c) ],                        # pc10
  [ qw(f m d t m c c h) ],              # pc11
- [ qw(c m m bp bm p h) ],              # pc12
+ [ qw(c bm m bm bm p h) ],             # pc12
  [ qw(c h) ],                                  # 
  [ qw(c h) ],                                  # 
  [ qw(c m h) ],                                        # 
@@ -607,8 +607,16 @@ sub handle_12
 
        my $dxchan;
        
-       if ($_[2] eq '*' || $_[2] eq $main::mycall) {
+       if ((($dxchan = DXChannel->get($_[2])) && $dxchan->is_user) || $_[4] =~ /^[\#\w.]+$/){
+               $self->send_chat($line, @_[1..6]);
+       } elsif ($_[2] eq '*' || $_[2] eq $main::mycall) {
 
+               # ignore something that looks like a chat line coming in with sysop
+               # flag - this is a kludge...
+               if ($_[3] =~ /^\#\d+ / && $_[4] eq '*') {
+                       dbg('PCPROT: Probable chat rewrite, dropped') if isdbg('chanerr');
+                       return;
+               }
 
                # here's a bit of fun, convert incoming ann with a callsign in the first word
                # or one saying 'to <call>' to a talk if we can route to the recipient
@@ -626,8 +634,6 @@ sub handle_12
        
                # send it
                $self->send_announce($line, @_[1..6]);
-       } elsif ((($dxchan = DXChannel->get($_[2])) && $dxchan->is_user) || !is_callsign($_[0])){
-               $self->send_chat($line, @_[1..6]);
        } else {
                $self->route($_[2], $line);
        }
@@ -1790,9 +1796,15 @@ sub send_chat
        my $line = shift;
        my @dxchan = DXChannel->get_all();
        my $dxchan;
-       my $target = $_[1];
+       my $target = $_[3];
        my $text = unpad($_[2]);
+       my $ak1a_line;
                                
+       # munge the group and recast the line if required
+       if ($target =~ s/\.LST$//) {
+               $ak1a_line = $line;
+       }
+       
        # obtain country codes etc 
        my ($ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq) = (0..0);
        my ($ann_state, $org_state) = ("", "");
@@ -1833,10 +1845,19 @@ sub send_chat
        # send it if it isn't the except list and isn't isolated and still has a hop count
        # taking into account filtering and so on
        foreach $dxchan (@dxchan) {
-               next if $dxchan == $main::me;
-               next if $dxchan == $self && $self->is_node;
-               next if $target eq 'LOCAL' && $dxchan->is_node;
-               $dxchan->chat($line, $self->{isolate}, ' ', $target, $text, @_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
+               my $is_ak1a = $dxchan->is_ak1a;
+               
+               if ($dxchan->is_node) {
+                       next if $dxchan == $main::me;
+                       next if $dxchan == $self;
+                       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");
+                       }
+               }
+               
+               $dxchan->chat($is_ak1a ? $ak1a_line : $line, $self->{isolate}, $target, $_[1], $text, @_, $self->{call}, $ann_dxcc, $ann_itu, $ann_cq, $org_dxcc, $org_itu, $org_cq);
        }
 }