1. added WWV filtering
[spider.git] / cmd / reply.pl
1 #
2 # send a message
3 #
4 # this should handle
5 #
6 # send <call> [<call> .. ]
7 # send private <call> [<call> .. ]
8 # send private rr <call> [<call> .. ]
9 # send rr <call> [<call> .. ]
10 # send noprivate <call> [<call> .. ]
11 # send b <call> [<call> .. ]
12 # send copy <call> [<call> .. ]
13 # send copy rr <call> [<call> .. ]
14
15 # Copyright (c) Dirk Koopman G1TLH
16 #
17 # $Id$
18 #
19 my ($self, $line) = @_;
20 my @out;
21 my $loc;
22
23 #$DB::single = 1;
24
25 if ($self->state eq "prompt") {
26         
27         my @f = split /\s+/, $line if $line;
28         
29         # now deal with real message inputs 
30         # parse out send line for various possibilities
31         $loc = $self->{loc} = {};
32         
33         my $i = 0;
34         $loc->{private} = '1';
35         if ($i < @f) {
36                 if ($f[0] =~ /^(B|NOP)/oi) {
37                         $loc->{private} = '0';
38                         $i += 1;
39                 } elsif ($f[0] =~ /^P/oi) {
40                         $i += 1;
41                 }
42         }
43         
44         if ($i < @f) {
45                 $loc->{rrreq} = '0';
46                 if (uc $f[$i] eq 'RR') {
47                         $loc->{rrreq} = '1';
48                         $i++;
49                 }
50         }
51         my $oref; 
52         
53         # check we have a reply number
54         #  $DB::single = 1;
55         
56         if ($i < @f) {
57                 $oref = DXMsg::get($f[$i]);
58                 if (!$oref) {
59                         delete $self->{loc};
60                         return (1, $self->msg('m4', $i));
61                 }
62         } else {
63                 if (!($oref = DXMsg::get($self->lastread))) {
64                         delete $self->{loc};
65                         return (1, $self->msg('m5'));
66                         #return (1, "need a message number");
67                 }
68         }
69         
70         # now save all the 'to' callsigns for later
71         my $to = $oref->from;
72         $loc->{to} = [ $to ];       # to is an array
73         $loc->{subject} = $oref->subject;
74         $loc->{subject} = "Re: " . $loc->{subject} if !($loc->{subject} =~ /^Re:\s/io); 
75         
76         # find me and set the state and the function on my state variable to
77         # keep calling me for every line until I relinquish control
78         $self->func("DXMsg::do_send_stuff");
79         $self->state('sendbody');
80         #push @out, $self->msg('sendsubj');
81 #       push @out, "Reply to: $to";
82 #       push @out, "Subject : $loc->{subject}";
83 #       push @out, "Enter Message /EX (^Z) to send or /ABORT (^Y) to exit";
84         push @out, $self->msg('m6', $to);
85         push @out, $self->msg('m7', $loc->{subject});
86         push @out, $self->msg('m8');
87 }
88
89 return (1, @out);