start work on NP stuff seriously
[spider.git] / perl / DXMsg.pm
index 118feef49dba1bf420ca2172dfb6aa990ed975fc..552709ddd29680a922e2783e34c1376419a2837a 100644 (file)
@@ -435,7 +435,7 @@ sub notify
 {
        my $ref = shift;
        my $to = $ref->{to};
-       my $uref = DXUser->get($to);
+       my $uref = DXUser->get_current($to);
        my $dxchan = DXChannel->get($to);
        if (((*Net::SMTP && $email_server) || $email_prog) && $uref && $uref->wantemail) {
                my $email = $uref->email;
@@ -518,6 +518,7 @@ sub store
                        my $line;
                        $ref->{size} = 0;
                        foreach $line (@{$lines}) {
+                               $line =~ s/[\x00-\x08\x0a-\x1f\x80-\x9f]/./g;
                                $ref->{size} += (length $line) + 1;
                                print $fh "$line\n";
                        }
@@ -530,7 +531,7 @@ sub store
        }
 
        # actual remove all the 'deleted' messages in one hit.
-       # this has to me delayed until here otherwise it only does one at 
+       # this has to be delayed until here otherwise it only does one at 
        # a time because @msg is rewritten everytime del_msg is called.
        my @del = grep {!$_->{tonode} && $_->{delete} && $_->{deletetime} < $main::systime} @msg;
        for (@del) {
@@ -723,7 +724,7 @@ sub queue_msg
                        $ref->stop_msg($node);
                        
                        # delay any outgoing messages that fail
-                       $ref->{waitt} = $main::systime + $waittime + rand(120) if $node ne $main::mycall;
+                       $ref->{waitt} = $main::systime + $waittime + int rand(120) if $node ne $main::mycall;
                        delete $ref->{lastt};
                        next;
                }
@@ -788,14 +789,15 @@ sub for_me
 {
        my $call = uc shift;
        my $ref;
+       my $count;
        
        foreach $ref (@msg) {
                # is it for me, private and unread? 
                if ($ref->{to} eq $call && $ref->{private}) {
-                       return 1 if !$ref->{'read'};
+                  $count++ unless $ref->{'read'} || $ref->{delete};
                }
        }
-       return 0;
+       return $count;
 }
 
 # start the message off on its travels with a PC28
@@ -1084,6 +1086,24 @@ sub do_send_stuff
                        delete $self->{loc};
                        $self->func(undef);
                        $self->state('prompt');
+               } elsif ($line =~ m|^/+\w+|) {
+                       # this is a command that you want display for your own reference
+                       # or if it has TWO slashes is a command 
+                       $line =~ s|^/||;
+                       my $store = $line =~ s|^/+||;
+                       my @in = $self->run_cmd($line);
+                       push @out, @in;
+                       if ($store) {
+                               foreach my $l (@in) {
+                                       if (my @ans = BadWords::check($l)) {
+                                               $self->{badcount} += @ans;
+                                               Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} subject: '$loc->{subject}' in msg") unless $loc->{reject};
+                                               Log('msg', "line: $l");
+                                               $loc->{reject}++;
+                                       } 
+                                       push @{$loc->{lines}}, length($l) > 0 ? $l : " ";
+                               }
+                       }
                } else {
                        if (my @ans = BadWords::check($line)) {
                                $self->{badcount} += @ans;
@@ -1091,9 +1111,25 @@ sub do_send_stuff
                                Log('msg', "line: $line");
                                $loc->{reject}++;
                        }
+
+                       if ($loc->{lines} && @{$loc->{lines}}) {
+                               push @{$loc->{lines}}, length($line) > 0 ? $line : " ";
+                       } else {
+                               # temporarily store any R: lines so that we end up with 
+                               # only the first and last ones stored.
+                               if ($line =~ m|^R:\d{6}/\d{4}|) {
+                                       push @{$loc->{tempr}}, $line;
+                               } else {
+                                       if (exists $loc->{tempr}) {
+                                               push @{$loc->{lines}}, shift @{$loc->{tempr}};
+                                               push @{$loc->{lines}}, pop @{$loc->{tempr}} if @{$loc->{tempr}};
+                                               delete $loc->{tempr};
+                                       }
+                                       push @{$loc->{lines}}, length($line) > 0 ? $line : " ";
+                               } 
+                       }
                        
                        # i.e. it ain't and end or abort, therefore store the line
-                       push @{$loc->{lines}}, length($line) > 0 ? $line : " ";
                }
        }
        return @out;
@@ -1182,6 +1218,32 @@ sub forward_it
        return 0;
 }
 
+#
+# look down the forward table to see whether this is a valid bull
+# or not (ie it will forward somewhere even if it is only here)
+#
+sub valid_bull_addr
+{
+       my $call = shift;
+       my $i;
+       
+       unless (@forward) {
+               return 1 if $call =~ /^ALL/;
+               return 1 if $call =~ /^DX/;
+               return 0;
+       }
+       
+       for ($i = 0; $i < @forward; $i += 5) {
+               my ($sort, $field, $pattern, $action, $bbs) = @forward[$i..($i+4)]; 
+               if ($field eq 'T') {
+                       if (!$pattern || $call =~ m{$pattern}i) {
+                               return 1;
+                       }
+               }
+       }
+       return 0;
+}
+
 sub dump_it
 {
        my $ref = shift;