292316b5018a0ce189805befc54ddf6692bba7b0
[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 #
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 = {};
32         
33         my $i = 0;
34         my @extra = ();
35         my $msgno = $self->lastread;
36         $loc->{private} = '1';
37         $loc->{rrreq} = '0';
38         while (@f) {
39                 my $w = shift @f;
40                 if ($w =~ /^\d+$/) {
41                         $msgno = $w;
42                 } elsif ($w =~ /^(B|NOP)/i) {
43                         $loc->{private} = '0';
44                 } elsif ($w =~ /^P/i) {
45                         ;
46                 } elsif (uc $w eq 'RR') {
47                         $loc->{rrreq} = '1';
48                 } else {
49                         push @extra, uc $w;
50                 }
51         }
52         
53         my $oref; 
54         
55         # check we have a reply number
56         #  $DB::single = 1;
57         
58         $oref = DXMsg::get($msgno) if $msgno;
59         return (1, $self->msg('m4', $i)) unless $oref;
60         
61         # now save all the 'to' callsigns for later
62         my $to;
63         if ($loc->{private}) {
64                 $to = $oref->from;
65         } else {
66                 $to = $oref->to;
67                 @extra = ();
68         } 
69
70         return (1, $self->msg('e28')) unless $self->registered || $to eq $main::myalias;
71         
72         $loc->{to} = [ $to, @extra ];       # 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         $self->loc($loc);
81         push @out, $self->msg('m6', join(',', $to, @extra));
82         push @out, $self->msg('m7', $loc->{subject});
83         push @out, $self->msg('m8');
84 }
85
86 return (1, @out);