X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=cmd%2Fread.pl;h=a1352724bb486a95997cea6e3bb1ab90a60da767;hb=6a0068ec3df1dca0c6ae2714af3c0a4a62998dcf;hp=9df5edad1e68910760ff155d0f61da12bd0b88d2;hpb=3f145290a93b39bf15b50269dd8be585d7b4bc9c;p=spider.git diff --git a/cmd/read.pl b/cmd/read.pl index 9df5edad..a1352724 100644 --- a/cmd/read.pl +++ b/cmd/read.pl @@ -13,13 +13,26 @@ 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, "Sorry, no new messages for you") if @f == 0; + for $msgno (@f) { $ref = DXMsg::get($msgno); if (!$ref) { push @out, "Msg $msgno not found"; next; } - if ($ref->private && $self->priv < 9 && $ref->to ne $ref->call) { + if ($self->priv < 5 && $ref->private && $ref->to ne $self->call && $ref->from ne $self->call ) { push @out, "Msg $msgno not available"; next; } @@ -33,6 +46,9 @@ for $msgno (@f) { $ref->read(1); $ref->store(\@body); # note call by reference! } + + # remember this one as the last one read + $self->lastread($msgno); } return (1, @out);