X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=97ac48623e192cd47b78488996edeb2823a9d3c3;hb=407d9a80a8af1fa6c1ae2c8fbca833e49da6e816;hp=3972e8b5b6509ebab966b8aa5303cab3e3cb6e69;hpb=417f55d271551683dfe1a49fb754024ba4731363;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 3972e8b5..97ac4862 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -34,7 +34,7 @@ use Script; use strict; -use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug); +use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors %nothereslug $maxbadcount); %Cache = (); # cache of dynamically loaded routine's mod times %cmd_cache = (); # cache of short names @@ -42,6 +42,8 @@ $errstr = (); # error string from eval %aliases = (); # aliases for (parts of) commands $scriptbase = "$main::root/scripts"; # the place where all users start scripts go $maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection +$maxbadcount = 3; # no of bad words allowed before disconnection + use vars qw($VERSION $BRANCH); $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ ); @@ -121,9 +123,11 @@ sub start } # decide on echo - if (!$user->wantecho) { + my $echo = $user->wantecho; + unless ($echo) { $self->send_now('E', "0"); $self->send($self->msg('echow')); + $self->conn->echo($echo) if $self->conn->can('echo'); } $self->tell_login('loginu'); @@ -220,8 +224,14 @@ sub normal $self->send($self->talk_prompt); } elsif ($self->{talklist} && @{$self->{talklist}}) { # send what has been said to whoever is in this person's talk list - for (@{$self->{talklist}}) { - $self->send_talks($_, $cmdline); + my @bad; + if (@bad = BadWords::check($cmdline)) { + $self->badcount(($self->badcount||0) + @bad); + Log('DXCommand', "$self->{call} swore: $cmdline"); + } else { + for (@{$self->{talklist}}) { + $self->send_talks($_, $cmdline); + } } $self->send($self->talk_prompt) if $self->{state} eq 'talk'; } else { @@ -241,7 +251,14 @@ sub normal } else { $self->send_ans(run_cmd($self, $cmdline)); } - + + # check for excessive swearing + if ($self->{badcount} && $self->{badcount} >= $maxbadcount) { + Log('DXCommand', "$self->{call} logged out for excessive swearing"); + $self->disconnect; + return; + } + # send a prompt only if we are in a prompt state $self->prompt() if $self->{state} =~ /^prompt/o; }