1. Added msg command to allow the changing of To, From, Subject and so on the
[spider.git] / cmd / send.pl
index 9717c3afa3e4b578cc8bbde8858f17cb28edf812..14913eab1afa6ada93f30ebe18f3242dc3782ed7 100644 (file)
@@ -20,7 +20,7 @@ my ($self, $line) = @_;
 my @out;
 my $loc;
 
-#$DB::single = 1;
+# $DB::single = 1;
 
 if ($self->state eq "prompt") {
 
@@ -68,8 +68,8 @@ if ($self->state eq "prompt") {
                        push @list, $oref->read_msg_body();
                        $nref->store(\@list);
                        $nref->add_dir();
-                       #push @out, $self->msg('sendcc', $oref->msgno, $f[$i]);
-                       push @out, "copy of msg $oref->{msgno} sent to $to";
+                       push @out, $self->msg('m2', $oref->msgno, $to);
+#                      push @out, "copy of msg $oref->{msgno} sent to $to";
                }
                DXMsg::queue_msg();
                return (1, @out);
@@ -100,17 +100,51 @@ if ($self->state eq "prompt") {
                delete $self->{loc};
                return (1, $self->msg('e6'));
        }
-  
+
        # now save all the 'to' callsigns for later
-       my @to = map {uc $_} @f[ $i..$#f ];
-       $loc->{to} = \@to;
+       # first check the 'to' addresses for 'badness'
+    my $t;
+       my @to;
+       splice @f, 0, $i-1 if $i > 0;
+       foreach  $t (@f) {
+               $t = uc $t;
+
+        # is this callsign a distro?
+               my $fn = "/spider/msg/distro/$t.pl";
+               if (-e $fn) {
+                       my $fh = new IO::File $fn;
+                       if ($fh) {
+                               local $/ = undef;
+                               my $s = <$fh>;
+                               $fh->close;
+                               my @call;
+                @call = eval $s;
+                               return (1, "Error in Distro $t.pl:", $@) if $@;
+                               if (@call > 0) {
+                                       push @f, @call;
+                                       next;
+                               }
+                       }
+               }
+               if (grep $_ eq $t, @DXMsg::badmsg) {
+#                      push @out, "Sorry, $t is an unacceptable TO address";
+                       push @out, $self->msg('m3', $t);
+               } else {
+                       push @to, $t;
+               }
+       }
+       if (@to) {
+               $loc->{to} = \@to;
+       } else {
+               return (1, @out);
+       }
 
        # find me and set the state and the function on my state variable to
        # keep calling me for every line until I relinquish control
        $self->func("DXMsg::do_send_stuff");
        $self->state('send1');
-       #push @out, $self->msg('sendsubj');
-       push @out, "Enter Subject (30 characters) >";
+       push @out, $self->msg('m1');
+       #push @out, "Enter Subject (30 characters) >";
 }
 
 return (1, @out);