23efabfc5e2b64999ecfe0345fe325ab013ece98
[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 if ($argv[1] eq '>') {
16   $via = uc $argv[2];
17   $line =~ s/^$argv[0]\s+>\s+$argv[2]\s*//;
18 } else {
19   $line =~ s/^$argv[0]\s*//;
20 }
21
22 my $call = $via ? $via : $to;
23 my $ref = DXCluster->get($call);
24 return (1, "$call not visible on the cluster") if !$ref;
25
26 my $dxchan = DXCommandmode->get($to);         # is it for us?
27 if ($dxchan && $dxchan->is_user) {
28   $dxchan->send("$to de $from $line");
29 } else {
30   $line =~ s/\^//og;            # remove any ^ characters
31   my $prot = DXProt::pc10($from, $to, $via, $line);
32   DXProt::route($via?$via:$to, $prot);
33 }
34
35 return (1, ());
36