From d46e81d715d7d2050c924a608c31cf8ab5143e3f Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Mon, 25 Mar 2024 08:36:55 +0000 Subject: [PATCH] more talk w.i.p --- cmd/talk.pl | 24 +++++----- perl/DXCommandmode.pm | 106 +++++++++++++++++------------------------- 2 files changed, 54 insertions(+), 76 deletions(-) diff --git a/cmd/talk.pl b/cmd/talk.pl index 4f609aaa..62198627 100644 --- a/cmd/talk.pl +++ b/cmd/talk.pl @@ -17,16 +17,14 @@ return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript; # analyse the line there are four situations... # 1) talk call # 2) talk call -# 3) talk call>node -# 4) talk call>node text +# 3) talk call>node **via ignored +# 4) talk call>node text **ditto # -($to, $via, $line) = $inline =~ /^\s*([A-Za-z0-9\-]+)(?:\s*>([A-Za-z0-9\-]+))?\s+(.*)$/; -if ($via) { - $line =~ s/\s+// if $line; -} else { - ($to, $line) = split /\s+/, $inline, 2; -} +# via is deprecated / ignored +$inline =~ s/(?:\s*>([A-Za-z0-9\-]+))\s*//; + +($to, $line) = $inline =~ /^\s*([A-Za-z0-9\-]+)\s+(.*)$/; return (1, $self->msg('e8')) unless $to; @@ -35,12 +33,14 @@ $to = uc $to; return (1, $self->msg('e22', $to)) unless is_callsign($to); return (1, $self->msg('e28')) unless $self->isregistered || $to eq $main::myalias; -$via = uc $via if $via; -my $call = $via || $to; +#$via = uc $via if $via; +#my $call = $via || $to; #my $clref = Route::get($call); # try an exact call #my $dxchan = $clref->dxchan if $clref; #push @out, $self->msg('e7', $call) unless $dxchan; +my $call = $to; + #$DB::single = 1; # default the 'via' @@ -60,10 +60,10 @@ my $dxchan; if ($line) { Log('talk', $to, $from, '>' . ($via || ($dxchan && $dxchan->call) || '*'), $line); - $main::me->normal(DXProt::pc93($to, $self->call, $via, $line, undef, $ipaddr)); + #$main::me->normal(DXProt::pc93($to, $self->call, $via, $line, undef, $ipaddr)); + $self->send_talks($to, $line); } else { my $s = $to; - $s .= ">$via" if $via && $via ne '*'; my $ref = $self->talklist; if ($ref) { unless (grep { $_ eq $s } @$ref) { diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 6e6b176e..bc362456 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -362,8 +362,7 @@ sub normal for (@{$self->{talklist}}) { if ($self->{state} eq 'talk') { $self->send_talks($_, $l); - } - else { + } else { send_chats($self, $_, $l) } } @@ -444,41 +443,6 @@ sub normal $self->prompt() if $self->{state} =~ /^prompt/o; } -# send out the talk messages taking into account vias and connectivity -sub send_talks -{ - my ($self, $ent, $line) = @_; - - my ($to, $via) = $ent =~ /(\S+)>(\S+)/; - $to = $ent unless $to; - my $call = $via && $via ne '*' ? $via : $to; - my $clref = Route::get($call); - my $dxchan = $clref->dxchan if $clref; - if ($dxchan) { - $dxchan->talk($self->{call}, $to, undef, $line); - } else { - $self->send($self->msg('disc2', $via ? $via : $to)); - my @l = grep { $_ ne $ent } @{$self->{talklist}}; - if (@l) { - $self->{talklist} = \@l; - } else { - delete $self->{talklist}; - $self->state('prompt'); - } - } -} - -sub send_chats -{ - my $self = shift; - my $target = shift; - my $text = shift; - - my $msgid = DXProt::nextchatmsgid(); - $text = "#$msgid $text"; - my $ipaddr = alias_localhost($self->hostname || '127.0.0.1'); - $main::me->normal(DXProt::pc93($target, $self->{call}, undef, $text, undef, $ipaddr)); -} sub special_prompt { @@ -950,33 +914,6 @@ sub local_send } } -# send a talk message here -sub talk -{ - my ($self, $from, $to, $via, $line, $onode) = @_; - $line =~ s/\\5E/\^/g; - if ($self->{talk}) { - if ($self->{gtk}) { - $self->local_send('T', dd(['talk',$to,$from,$via,$line])); - } else { - $self->local_send('T', "$to de $from: $line"); - } - } - Log('talk', $to, $from, '<' . ($onode || '*'), $line); - # send a 'not here' message if required - unless ($self->{here} && $from ne $to) { - my $key = "$to$from"; - unless (exists $nothereslug{$key}) { - my ($ref, $dxchan); - if (($ref = Route::get($from)) && ($dxchan = $ref->dxchan)) { - my $name = $self->user->name || $to; - my $s = $self->user->nothere || $dxchan->msg('nothere', $name); - $nothereslug{$key} = $main::systime; - $dxchan->talk($to, $from, undef, $s); - } - } - } -} # send an announce sub announce @@ -1014,6 +951,22 @@ sub announce $self->local_send($target eq 'WX' ? 'W' : 'N', $buf); } +# send a talk message here +sub talk +{ + my ($self, $from, $to, $via, $line, $onode) = @_; + $line =~ s/^\#\d+ //; + $line =~ s/\\5E/\^/g; + if ($self->{talk}) { + if ($self->{gtk}) { + $self->local_send('T', dd(['talk',$to,$from,$via,$line])); + } else { + $self->local_send('T', "$to de $from: $line"); + } + } + Log('talk', $to, $from, '<' . ($onode || '*'), $line); +} + # send a chat sub chat { @@ -1039,6 +992,31 @@ sub chat $self->local_send('C', $buf); } +# send out the talk messages taking into account vias and connectivity +sub send_talks +{ + my ($self, $target, $text) = @_; + + my $msgid = DXProt::nextchatmsgid(); + $text = "#$msgid $text"; + my $ipaddr = alias_localhost($self->hostname || '127.0.0.1'); + $main::me->normal(DXProt::pc93($target, $self->{call}, undef, $text, undef, $ipaddr)); + +} + +sub send_chats +{ + my $self = shift; + my $target = shift; + my $text = shift; + + my $msgid = DXProt::nextchatmsgid(); + $text = "#$msgid $text"; + my $ipaddr = alias_localhost($self->hostname || '127.0.0.1'); + $main::me->normal(DXProt::pc93($target, $self->{call}, undef, $text, undef, $ipaddr)); +} + + sub format_dx_spot { my $self = shift; -- 2.34.1