add sysop defined 'run' script and privilege commands
authorminima <minima>
Mon, 24 Feb 2003 16:03:30 +0000 (16:03 +0000)
committerminima <minima>
Mon, 24 Feb 2003 16:03:30 +0000 (16:03 +0000)
Changes
cmd/privilege.pl [new file with mode: 0644]
cmd/run.pl [new file with mode: 0644]
perl/Script.pm
perl/console.pl

diff --git a/Changes b/Changes
index c6d5d1f4e4bda1ed249ef0d2b167399fd69f446a..9d53e2405904f4c248c37b15c777beb6ee606494 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+24Feb03=======================================================================
+1. add the 'run' command and the 'privilege' command to allow sysops to 
+create scripts for people.
 23Feb03=======================================================================
 1. Added show/wm7d command (a US only callbook server) [by K1XX].
 2. Added a prototype show/db0sdx command (w.i.p).
diff --git a/cmd/privilege.pl b/cmd/privilege.pl
new file mode 100644 (file)
index 0000000..7d80ceb
--- /dev/null
@@ -0,0 +1,14 @@
+#
+# check the privilege of the user is at least n
+#
+# Copyright (c) 1998 Dirk Koopman G1TLH
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @out;
+$line = '1' unless defined $line;
+push @out, $self->msg('e5') unless $line =~ /^\d+$/ && $self->priv >= $line;
+return (1, @out);
+
diff --git a/cmd/run.pl b/cmd/run.pl
new file mode 100644 (file)
index 0000000..4a04c4c
--- /dev/null
@@ -0,0 +1,32 @@
+#
+# the run command
+#
+# run a script from the scripts directory
+#
+# Copyright (c) 1998 Dirk Koopman G1TLH
+#
+# $Id$
+#
+
+my ($self, $line) = @_;
+my @f = split /\s+/, $line;
+my @out;
+
+while (@f) {
+       my $f = shift @f;
+       
+       if (is_callsign(uc $f) && $self->priv < 8 && uc $f ne $self->call) {
+               push @out, $self->msg('e5');
+               next;
+       }
+       $f =~ s|[^-\w/]||g;
+       my $script = new Script(lc $f);
+       unless ($script) {
+               push @out, $self->msg('e3', 'script', $f);
+               next;
+       }
+       $script->run($self);
+}
+
+return (1, @out);
+
index 15f4d464082fa080766f46eabb05edc0b39a44c3..434109ceaf688b0f4966874014ce95a83d77a34e 100644 (file)
@@ -56,6 +56,7 @@ sub run
                        } else {
                                dbg($_) for @out;
                        }
+                       last if @out && $l =~ /^pri?v?/;
                }
        }
 }
index 46e7a1ea6c1df7c9c8eb4e2ba09f43edd26892cc..f4c4a85fa37731c163379cdf3b21b9b84d609b35 100755 (executable)
@@ -32,6 +32,7 @@ use DXDebug;
 use DXUtil;
 use DXDebug;
 use IO::File;
+use Time::HiRes qw(gettimeofday tv_interval);
 use Curses 1.06;
 
 use Console;
@@ -50,6 +51,9 @@ $connsort = "local";
 $khistpos = 0;
 $spos = $pos = $lth = 0;
 $inbuf = "";
+@time = ();
+
+$SIG{WINCH} = sub {@time = gettimeofday};
 
 sub mydbg
 {
@@ -114,8 +118,6 @@ sub do_resize
        $has_colors = has_colors();
        do_initscr();
 
-       $winch = 0;
-       $SIG{'WINCH'} = sub {$winch = 1};
        show_screen();
 }
 
@@ -504,7 +506,7 @@ for (;;) {
                $lasttime = $t;
        }
        my $ch = $bot->getch();
-       if ($winch) {
+       if (@time && tv_interval(\@time, [gettimeofday]) >= 1) {
 #              mydbg("Got Resize");
 #              do_resize();
                next;