slight mod on the PCXX replies
[spider.git] / perl / DXXml / Text.pm
1 #
2 # XML Text handler
3 #
4 # $Id$
5 #
6 # Copyright (c) Dirk Koopman, G1TLH
7 #
8
9 use strict;
10
11 package DXXml::Text;
12
13 use DXDebug;
14 use DXProt;
15 use DXLog;
16
17 use vars qw($VERSION $BRANCH @ISA %pings);
18 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
19 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
20 $main::build += $VERSION;
21 $main::branch += $BRANCH;
22
23 @ISA = qw(DXXml);
24
25 sub handle_input
26 {
27         my $self = shift;
28         my $dxchan = shift;
29
30         if ($self->{to} eq $main::mycall) {
31                 my $tochan = DXChannel::get($self->{u} || $main::myalias);
32                 if ($tochan) {
33                         $tochan->send($self->tocmd);
34                 } else {
35                         dbg("no user or $main::myalias not online") if isdbg('chanerr');
36                 }
37         } else {        
38                 $self->route($dxchan);
39         }
40 }
41
42 sub topcxx
43 {
44         my $self = shift;
45         my $dxchan = shift;
46         my @out;
47
48         my $ref = DXUser->get_current($self->{to});
49         for (split /(?:%0D)?\%0A/, $self->{content}) {
50                 my $line = $_;
51                 $line =~ s/\s*$//;
52                 Log('rcmd', 'out', $self->{to}, $line);
53                 if ($self->{u} && $dxchan->is_clx && $ref->is_clx) {
54                         push @out, DXProt::pc85($main::mycall, $self->{to}, $self->{u}, "$main::mycall:$line");
55                 } else {
56                         push @out, DXProt::pc35($main::mycall, $self->{to}, "$main::mycall:$line");
57                 }
58         }
59
60         return $self->{'-pcxx'} = \@out;
61 }
62
63 sub tocmd
64 {
65         my $self = shift;
66
67         my @out = split /(?:%0D)?\%0A/, $self->{content};
68         return $self->{-cmd} = \@out;
69 }
70
71 1;