fixed sh/c/n
[spider.git] / cmd / talk.pl
1 #
2 # The talk command
3 #
4 # Copyright (c) 1998 Dirk Koopman G1TLH
5 #
6 # $Id$
7 #
8
9 my ($self, $line) = @_;
10 my @argv = split /\s+/, $line;                # generate an argv
11 my $to = uc $argv[0];
12 my $via;
13 my $from = $self->call();
14
15 # have we a callsign and some text?
16 return (1, $self->msg('e8')) if @argv < 2;
17
18 if ($argv[1] eq '>') {
19   $via = uc $argv[2];
20   $line =~ s/^$argv[0]\s+>\s+$argv[2]\s*//;
21 } else {
22   $line =~ s/^$argv[0]\s*//;
23 }
24
25 my $call = $via ? $via : $to;
26 my $ref = DXCluster->get($call);
27 return (1, "$call not visible on the cluster") if !$ref;
28
29 my $dxchan = DXCommandmode->get($to);         # is it for us?
30 if ($dxchan && $dxchan->is_user) {
31   $dxchan->send("$to de $from $line");
32   Log('talk', $to, $from, $main::mycall, $line);
33 } else {
34   $line =~ s/\^//og;            # remove any ^ characters
35   my $prot = DXProt::pc10($from, $to, $via, $line);
36   DXProt::route($via?$via:$to, $prot);
37   Log('talk', $to, $from, $via?$via:$main::mycall, $line);
38 }
39
40 return (1, ());
41