some detail changes in the send routines and spot formatting
[spider.git] / cmd / send.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   $f[0] = uc $f[0];
30   
31   # first deal with copies
32   if ($f[0] eq 'C' || $f[0] eq 'CC' || $f[0] eq 'COPY') {
33     my $i = 1;
34         my $rr = '0';
35         if (uc $f[$i] eq 'RR') {
36           $rr = '1';
37           $i++;
38         }
39         my $oref = DXMsg::get($f[$i]);
40     #return (0, $self->msg('esend1', $f[$i])) if !$oref;
41         #return (0, $self->msg('esend2')) if $i+1 >  @f;
42     return (0, "msgno $f[$i] not found") if !$oref;
43         return (0, "need a callsign") if $i+1 >  @f;
44       
45         # separate copy to everyone listed
46         for ($i++ ; $i < @f; $i++) {
47           my $msgno = DXMsg::next_transno('Msgno');
48           my $newsubj = "CC: " . $oref->subject;
49           my $nref = DXMsg->alloc($msgno, 
50                                   uc $f[$i], 
51                                   $self->call,  
52                                                           $main::systime, 
53                                                           '1',  
54                                                           $newsubj, 
55                                                           $main::mycall,
56                                                           '0',
57                                                           $rr);
58           my @list;
59           my $from = $oref->from;
60           my $to = $oref->to;
61           my $date = cldate($oref->t);
62           my $time = ztime($oref->t);
63           my $buf = "Original from: $from To: $to Date: $date $time";
64           push @list, $buf; 
65           push @list, $oref->read_msg_body();
66           $nref->store(\@list);
67           $nref->add_dir();
68           #push @out, $self->msg('sendcc', $oref->msgno, $f[$i]);
69           push @out, "copy of msg $oref->{msgno} sent to $to";
70         }
71         DXMsg::queue_msg();
72         return (1, @out);
73   }
74
75   # now deal with real message inputs 
76   # parse out send line for various possibilities
77   $loc = $self->{loc} = {};
78   
79   my $i = 0;
80   $f[0] = uc $f[0];
81   $loc->{private} = '1';
82   if ($f[0] eq 'B' || $f[0] =~ /^NOP/oi) {
83     $loc->{private} = '0';
84         $i += 1;
85   } elsif ($f[0] eq 'P' || $f[0] =~ /^PRI/oi) {
86     $i += 1;
87   }
88   
89   $loc->{rrreq} = '0';
90   if (uc $f[$i] eq 'RR') {
91     $loc->{rrreq} = '1';
92         $i++;
93   }
94   
95   # check we have some callsigns
96   if ($i  >  @f) {
97     delete $self->{loc};
98     #return (0, $self->msg('esend2'));
99     return (0, "need a callsign");
100   }
101   
102   # now save all the 'to' callsigns for later
103   my @to = @f[ $i..$#f ];
104   $loc->{to} = \@to;
105
106   # find me and set the state and the function on my state variable to
107   # keep calling me for every line until I relinquish control
108   $self->func("DXMsg::do_send_stuff");
109   $self->state('send1');
110   #push @out, $self->msg('sendsubj');
111   push @out, "Enter Subject (30 characters) >";
112 }
113
114 return (1, @out);