added registration
[spider.git] / cmd / unset / register.pl
diff --git a/cmd/unset/register.pl b/cmd/unset/register.pl
new file mode 100644 (file)
index 0000000..7f5b673
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# unregister a user
+#
+# Copyright (c) 2001 Dirk Koopman G1TLH
+#
+# $Id$
+#
+my ($self, $line) = @_;
+my @args = split /\s+/, $line;
+my $call;
+# my $priv = shift @args;
+my @out;
+my $user;
+my $ref;
+
+if ($self->priv < 9) {
+       Log('DXCommand', $self->call . " attempted to unregister @args");
+       return (1, $self->msg('e5'));
+}
+return (1, $self->msg('reginac')) unless $main::reqreq;
+
+foreach $call (@args) {
+       $call = uc $call;
+       unless ($self->remotecmd) {
+               if ($ref = DXUser->get_current($call)) {
+                       $ref->registered(0);
+                       $ref->put();
+                       my $dxchan = DXChannel->get($call);
+                       $dxchan->registered(0) if $dxchan;
+                       push @out, $self->msg("regun", $call);
+                       Log('DXCommand', $self->call . " unregistered $call");
+               } else {
+                       push @out, $self->msg('e3', 'unset/register', $call);
+               }
+       } else {
+               Log('DXCommand', $self->call . " attempted to unregister $call remotely");
+               push @out, $self->msg('sorry');
+       }
+}
+return (1, @out);