loads of changes and added things
[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;
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   $f[0] = uc $f[0];
35   $loc->{private} = '1';
36   if ($f[0] eq 'B' || $f[0] =~ /^NOP/oi) {
37     $loc->{private} = '0';
38         $i += 1;
39   } elsif ($f[0] eq 'P' || $f[0] =~ /^PRI/oi) {
40     $i += 1;
41   }
42   
43   $loc->{rrreq} = '0';
44   if (uc $f[$i] eq 'RR') {
45     $loc->{rrreq} = '1';
46         $i++;
47   }
48   
49   my $oref; 
50   
51   # check we have a reply number
52   if ($i  >  @f) {
53     if (!($oref = DXMsg::get($self->lastread))) {
54       delete $self->{loc};
55       #return (0, $self->msg('esend2'));
56       return (0, "need a message number");
57         }
58   } else {
59     $oref = DXMsg::get($f[$i]);
60         if (!$oref) {
61           delete $self->{loc};
62           return (0, "can't access message $i");
63         }
64   }
65   
66   # now save all the 'to' callsigns for later
67   my $to = $oref->from;
68   $loc->{to} = [ $to ];       # to is an array
69   $loc->{subject} = $oref->subject;
70   $loc->{subject} = "Re: " . $loc->{subject} if !($loc->{subject} =~ /^Re/io); 
71
72   # find me and set the state and the function on my state variable to
73   # keep calling me for every line until I relinquish control
74   $self->func("DXMsg::do_send_stuff");
75   $self->state('sendbody');
76   #push @out, $self->msg('sendsubj');
77   push @out, "Reply to: $to";
78   push @out, "Subject : $loc->{subject}";
79   push @out, "Enter Message /EX (^Z) to send or /ABORT (^Y) to exit";
80 }
81
82 return (1, @out);