2 # The talk command (improved)
4 # Copyright (c) 1998 Dirk Koopman G1TLH
9 my ($self, $inline) = @_;
13 my $from = $self->call;
15 return (1, $self->msg('e5')) if $self->remotecmd || $self->inscript;
17 # analyse the line there are four situations...
21 # 4) talk call>node text
24 ($to, $via, $line) = $inline =~ /^\s*([A-Za-z0-9\-]+)(?:\s*>([A-Za-z0-9\-]+))?\s+(.*)$/;
26 $line =~ s/\s+// if $line;
28 ($to, $line) = split /\s+/, $inline, 2;
31 return (1, $self->msg('e8')) unless $to;
35 return (1, $self->msg('e22', $to)) unless is_callsign($to);
36 return (1, $self->msg('e28')) unless $self->isregistered || $to eq $main::myalias;
38 $via = uc $via if $via;
39 my $call = $via || $to;
40 #my $clref = Route::get($call); # try an exact call
41 #my $dxchan = $clref->dxchan if $clref;
42 #push @out, $self->msg('e7', $call) unless $dxchan;
49 my $ipaddr = DXCommandmode::alias_localhost($self->hostname || '127.0.0.1');
51 # if there is a line send it, otherwise add this call to the talk list
52 # and set talk mode for command mode
54 if (@bad = BadWords::check($line)) {
55 $self->badcount(($self->badcount||0) + @bad);
56 LogDbg('DXCommand', "$self->{call} swore: $line (with words:" . join(',', @bad) . ")");
62 Log('talk', $to, $from, '>' . ($via || ($dxchan && $dxchan->call) || '*'), $line);
63 $main::me->normal(DXProt::pc93($to, $self->call, $via, $line, undef, $ipaddr));
66 $s .= ">$via" if $via && $via ne '*';
67 my $ref = $self->talklist;
69 unless (grep { $_ eq $s } @$ref) {
70 $main::me->normal(DXProt::pc93($to, $self->call, $via, $self->msg('talkstart'), undef, $ipaddr));
75 $self->talklist([ $s ]);
76 $main::me->normal(DXProt::pc93($to, $self->call, $via, $self->msg('talkstart'), undef, $ipaddr));
77 push @out, $self->msg('talkinst');
80 Log('talk', $to, $from, '>' . ($via || ($dxchan && $dxchan->call) || '*'), $self->msg('talkstart'), undef, $ipaddr);
81 push @out, $self->talk_prompt;