fixed reply so that reply b / nop send replies as bulls
[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                 }
67         }
68         
69         # now save all the 'to' callsigns for later
70         my $to = $loc->{private} ? $oref->from : $oref->to;
71         $loc->{to} = [ $to ];       # to is an array
72         $loc->{subject} = $oref->subject;
73         $loc->{subject} = "Re: " . $loc->{subject} if !($loc->{subject} =~ /^Re:\s/io); 
74         
75         # find me and set the state and the function on my state variable to
76         # keep calling me for every line until I relinquish control
77         $self->func("DXMsg::do_send_stuff");
78         $self->state('sendbody');
79         push @out, $self->msg('m6', $to);
80         push @out, $self->msg('m7', $loc->{subject});
81         push @out, $self->msg('m8');
82 }
83
84 return (1, @out);