+ $dxchan->announce($line, $self->{isolate}, $to, $target, $text, @_, $self->{call},
+ @a[0..2], @b[0..2]);
+ }
+}
+
+my $msgid = 0;
+
+sub nextchatmsgid
+{
+ $msgid++;
+ $msgid = 1 if $msgid > 999;
+ return $msgid;
+}
+
+# send a chat line
+sub send_chat
+{
+ my $self = shift;
+ my $line = shift;
+ my @dxchan = DXChannel->get_all();
+ my $dxchan;
+ 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 @a = Prefix::cty_data($_[0]);
+ my @b = Prefix::cty_data($_[4]);
+ if ($self->{inannfilter}) {
+ my ($filter, $hops) =
+ $self->{inannfilter}->it(@_, $self->{call},
+ @a[0..2],
+ @b[0..2], $a[3], $b[3]);
+ unless ($filter) {
+ dbg("PCPROT: Rejected by input announce filter") if isdbg('chanerr');
+ return;
+ }
+ }
+
+ if (AnnTalk::dup($_[0], $_[1], $_[2], $chatdupeage)) {
+ dbg("PCPROT: Duplicate Announce ignored") if isdbg('chanerr');
+ return;
+ }
+
+
+ Log('chat', $target, $_[0], $text);
+
+ # 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) {
+ 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}, @a[0..2], @b[0..2]);