From ec57aa982f870daf09a1fc7839d06e52980cfb55 Mon Sep 17 00:00:00 2001 From: minima Date: Mon, 24 Feb 2003 16:03:30 +0000 Subject: [PATCH] add sysop defined 'run' script and privilege commands --- Changes | 3 +++ cmd/privilege.pl | 14 ++++++++++++++ cmd/run.pl | 32 ++++++++++++++++++++++++++++++++ perl/Script.pm | 1 + perl/console.pl | 8 +++++--- 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 cmd/privilege.pl create mode 100644 cmd/run.pl diff --git a/Changes b/Changes index c6d5d1f4..9d53e240 100644 --- 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 index 00000000..7d80cebb --- /dev/null +++ b/cmd/privilege.pl @@ -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 index 00000000..4a04c4cc --- /dev/null +++ b/cmd/run.pl @@ -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); + diff --git a/perl/Script.pm b/perl/Script.pm index 15f4d464..434109ce 100644 --- a/perl/Script.pm +++ b/perl/Script.pm @@ -56,6 +56,7 @@ sub run } else { dbg($_) for @out; } + last if @out && $l =~ /^pri?v?/; } } } diff --git a/perl/console.pl b/perl/console.pl index 46e7a1ea..f4c4a85f 100755 --- a/perl/console.pl +++ b/perl/console.pl @@ -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; -- 2.43.0