fix allow 2/more commands on a line
[spider.git] / perl / DXCommandmode.pm
index 9b3a371b092a8e9cd651025153e26ca9c642a71d..dfaaa3e34887454ffe047c14b9a397fb70aa27e3 100644 (file)
@@ -252,6 +252,7 @@ sub start
        }
 
        $self->lastmsgpoll($main::systime);
+       $self->{user_interval} = $self->user->user_interval || $main::user_interval; # allow user to change idle time between prompts
        $self->prompt;
 }
 
@@ -348,22 +349,26 @@ sub normal
                        }
                        $self->state('prompt');
                        delete $self->{talklist};
-               } elsif ($cmdline =~ m|^/+\w+|) {
+               } elsif ($cmdline =~ m|^[/\w\\]+|) {
                        $cmdline =~ s|^/||;
                        my $sendit = $cmdline =~ s|^/+||;
                        if (@bad = BadWords::check($cmdline)) {
                                $self->badcount(($self->badcount||0) + @bad);
                                LogDbg('DXCommand', "$self->{call} swore: '$cmdline' with badwords: '" . join(',', @bad) . "'");
                        } else {
-                               my @in = $self->run_cmd($cmdline);
-                               $self->send_ans(@in);
-                               if ($sendit && $self->{talklist} && @{$self->{talklist}}) {
-                                       foreach my $l (@in) {
-                                               for (@{$self->{talklist}}) {
-                                                       if ($self->{state} eq 'talk') {
-                                                               $self->send_talks($_, $l);
-                                                       } else {
-                                                               send_chats($self, $_, $l)
+                               my @cmd = split /\s*\\n\s*/, $cmdline;
+                               foreach my $l (@cmd) {
+                                       my @in = $self->run_cmd($l);
+                                       $self->send_ans(@in);
+                                       if ($sendit && $self->{talklist} && @{$self->{talklist}}) {
+                                               foreach my $l (@in) {
+                                                       for (@{$self->{talklist}}) {
+                                                               if ($self->{state} eq 'talk') {
+                                                                       $self->send_talks($_, $l);
+                                                               }
+                                                               else {
+                                                                       send_chats($self, $_, $l)
+                                                               }
                                                        }
                                                }
                                        }
@@ -409,8 +414,11 @@ sub normal
 #              if (@bad = BadWords::check($cmdline)) {
 #                      $self->badcount(($self->badcount||0) + @bad);
 #                      LogDbg('DXCommand', "$self->{call} swore: '$cmdline' with badwords: '" . join(',', @bad) . "'");
-#              } else {
-                       $self->send_ans(run_cmd($self, $cmdline));
+               #               } else {
+               my @cmd = split /\s*\\n\s*/, $cmdline;
+               foreach my $l (@cmd) {
+                       $self->send_ans(run_cmd($self, $l));
+               }
 #              }
        } 
 
@@ -541,9 +549,9 @@ sub run_cmd
                $cmd =~ s|//+|/|g;
 
                # check for length of whole command line and any invalid characters
-               if (length $cmdline > $maxcmdlth || $cmd =~ m|\.| || $cmd !~ m|^\w+(?:/\w+){0,1}$|) {
+               if (length $cmdline > $maxcmdlth || $cmd =~ m|\.| || $cmd !~ m|^\w+(?:/\w+){0,1}(?:/\d+)?$|) {
                        LogDbg('DXCommand', "cmd: $self->{call} - invalid characters in '$cmd'");
-                       return $self->_error_out('e40');        
+                       return $self->_error_out('e40');
                }
 
                my ($path, $fcmd);
@@ -588,7 +596,7 @@ sub run_cmd
                                return $self->_error_out('e1');
                        }
                } else {
-                       dbg("cmd: $cmd not found") if isdbg('command');
+                       LogDbg('DXCommand', "$self->{call} cmd: '$cmd' not found");
                        return $self->_error_out('e1');
                }
        }
@@ -597,11 +605,11 @@ sub run_cmd
        if ($ok) {
                delete $self->{errors};
        } else {
-               if (++$self->{errors} > $DXChannel::maxerrors) {
+               if ($self != $main::me && ++$self->{errors} > $DXChannel::maxerrors) {
                        $self->send($self->msg('e26'));
                        $self->disconnect;
                        return ();
-               }
+               } 
        }
        return map {s/([^\s])\s+$/$1/; $_} @ans;
 }
@@ -627,7 +635,7 @@ sub process
                }
                
                # send a prompt if no activity out on this channel
-               if ($t >= $dxchan->t + $main::user_interval) {
+               if ($t >= $dxchan->t + $dxchan->{user_interval}) {
                        $dxchan->prompt() if $dxchan->{state} =~ /^prompt/o;
                        $dxchan->t($t);
                }
@@ -881,7 +889,6 @@ sub find_cmd_name {
                
                if (isdbg('eval')) {
                        my @list = split /\n/, $eval;
-                       my $line;
                        for (@list) {
                                dbg($_ . "\n") if isdbg('eval');
                        }