From: djk Date: Sun, 23 May 1999 19:06:39 +0000 (+0000) Subject: added more functionality to the kill command X-Git-Tag: R_1_28~11 X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=c73f18c7f4534761e29b51f3f0426f6f1f7a073b;p=spider.git added more functionality to the kill command --- diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index d982c3e3..3118419f 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -153,7 +153,13 @@ cluster and be returned. You can get rid of any message to or originating from your callsign using this command. You can remove more than one message at a time. -=== 5^KILL-^ +=== 5^KILL -^Remove a range of messages from the system +=== 5^KILL FROM ^Remove all messages from a callsign +=== 5^KILL TO ^Remove all messages to a callsign +=== 5^KILL FULL [ [/]^Ask for the latest spots and WWV diff --git a/cmd/directory.pl b/cmd/directory.pl index f5d1566d..9ddbb775 100644 --- a/cmd/directory.pl +++ b/cmd/directory.pl @@ -13,7 +13,7 @@ my $ref; my @out; my $f; my $n = 0; -my @all = grep {!($self->priv < 5 && $_->private && $_->to ne $self->call && $_->from ne $self->call)} (DXMsg::get_all()); +my @all = grep {!($self->priv < 5 && $_->to ne $self->call && $_->from ne $self->call)} (DXMsg::get_all()); my $sel = 0; my $from = 0; my $to = $all[@all-1]->msgno; diff --git a/cmd/kill.pl b/cmd/kill.pl index 82e22975..fb58bc24 100644 --- a/cmd/kill.pl +++ b/cmd/kill.pl @@ -6,41 +6,68 @@ # $Id$ # +use strict; + my ($self, $line) = @_; my @f = split /\s+/, $line; my $msgno; my @out; my @body; my $ref; +my @refs; my $call = $self->call; my $full; -if ($f[0] =~ /^f/io) { - return (1, $self->msg('e5')) if $self->priv < 5; - $full = 1; - shift @f; -} - # $DB::single = 1; -for $msgno (@f) { - $ref = DXMsg::get($msgno); - if (!$ref) { - push @out, "Msg $msgno not found"; - next; - } - if ($self->priv < 5 && - (($ref->private && $ref->to ne $self->call && $ref->from ne $self->call) || - ($ref->private == 0 && $ref->from ne $self->call))) { - push @out, "Msg $msgno not available"; - next; - } - Log('msg', "Message $ref->{msgno} from $ref->{from} to $ref->{to} deleted by $call"); - if ($full) { - DXProt::broadcast_all_ak1a(DXProt::pc49($self->call, $ref->{subject}), $DXProt::me); - } - $ref->del_msg; - push @out, "Message $msgno deleted"; +while (@f) { + my $f = shift @f; + if ($f =~ /^fu/io) { + return (1, $self->msg('e5')) if $self->priv < 5; + $full = 1; + } elsif ($f =~ /^\d+$/o) { + $ref = DXMsg::get($f); + if (!$ref) { + push @out, "Msg $f not found"; + next; + } + if ($self->priv < 5 && $ref->to ne $call && $ref->from ne $call) { + push @out, "Msg $f not available"; + next; + } + push @refs, $ref; + } elsif ($f =~ /(\d+)-(\d+)/) { + my $from = $1; + my $to = $2; + @refs = grep { !($self->priv < 5 && $_->to ne $call && $_->from ne $call) } DXMsg::get_all() unless @refs; + @refs = grep { $_->msgno >= $from && $_->msgno < $to } @refs; + } elsif ($f =~ /^fr/io) { + $f = shift @f; + if ($f) { + $f = shellregex($f); + @refs = grep { !($self->priv < 5 && $_->to ne $call && $_->from ne $call) } DXMsg::get_all() unless @refs; + @refs = grep { $_->from =~ m{$f}i } @refs; + } + } elsif ($f =~ /^to/io) { + $f = shift @f; + if ($f) { + $f = shellregex($f); + @refs = grep { !($self->priv < 5 && $_->to ne $call && $_->from ne $call) } DXMsg::get_all() unless @refs; + @refs = grep { $_->to =~ m{$f}i } @refs; + } + } else { + push @out, "invalid argument '$f'"; + return (1, @out); + } +} + +foreach $ref ( @refs) { + Log('msg', "Message $ref->{msgno} from $ref->{from} to $ref->{to} deleted by $call"); + if ($full) { + DXProt::broadcast_all_ak1a(DXProt::pc49($self->call, $ref->{subject}), $DXProt::me); + } + $ref->del_msg; + push @out, "Message $ref->{msgno} deleted"; } return (1, @out);