added more functionality to the kill command
authordjk <djk>
Sun, 23 May 1999 19:06:39 +0000 (19:06 +0000)
committerdjk <djk>
Sun, 23 May 1999 19:06:39 +0000 (19:06 +0000)
cmd/Commands_en.hlp
cmd/directory.pl
cmd/kill.pl

index d982c3e39d0df51e73180fc5d134eedfa1408090..3118419fd3136176ac1604e3b2aa4cb2800c72ca 100644 (file)
@@ -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 <from>-<to>^Remove a range of messages from the system
+=== 5^KILL FROM <call>^Remove all messages from a callsign
+=== 5^KILL TO <call>^Remove all messages to a callsign
+=== 5^KILL FULL <msgno> [<msgno]^Remove a message from the entire cluster
+Remove this message from the entire cluster system as well as your node.
+
+=== 5^KILL^
 As a sysop you can kill any message on the system.
 
 === 5^MERGE <node> [<no spots>/<no wwv>]^Ask for the latest spots and WWV 
index f5d1566d12cb4d53bba749474fc4600087573622..9ddbb77542d2a9e4f6d2536f32d10b8853340d94 100644 (file)
@@ -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;
index 82e229756f5bc20e9f07df99087537180413467c..fb58bc247c09655408dbb91193f7fe596c518e75 100644 (file)
@@ -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);