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