X-Git-Url: http://www.dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fread.pl;h=e21a77e6eaf5d891791aa725ab081d2de665d73d;hb=cce345b95c555a0b45218c5b452bc0f5f4f13bab;hp=c72be605ba37786b9f907de3869fe74495d0a5db;hpb=78ed3f6025103ec1c47c90725e37b417647d83c8;p=spider.git diff --git a/cmd/read.pl b/cmd/read.pl index c72be605..e21a77e6 100644 --- a/cmd/read.pl +++ b/cmd/read.pl @@ -5,3 +5,50 @@ # # $Id$ # + +my ($self, $line) = @_; +my @f = split /\s+/, $line; +my $msgno; +my @out; +my @body; +my $ref; + +# if there are no specified message numbers, try and find a private one +# that I haven't read yet +if (@f == 0) { + foreach $ref (DXMsg::get_all()) { + if ($ref->to eq $self->call && $ref->private && !$ref->read) { + push @f, $ref->msgno; + last; + } + } +} + +return (1, $self->msg('read1')) if @f == 0; + +for $msgno (@f) { + $ref = DXMsg::get($msgno); + if (!$ref) { + push @out, $self->msg('read2', $msgno); + next; + } + if ($self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call ) { + push @out, $self->msg('read3', $msgno); + next; + } + push @out, sprintf "Msg: %d From: %s Date: %6.6s %5.5s Subj: %-30.30s", $msgno, + $ref->from, cldate($ref->t), ztime($ref->t), $ref->subject; + @body = $ref->read_msg_body; + push @out, @body; + + # mark my privates as read + if ($ref->private && $self->call eq $ref->to && $ref->read == 0) { + $ref->read(1); + $ref->store(\@body); # note call by reference! + } + + # remember this one as the last one read + $self->lastread($msgno); +} + +return (1, @out);