From: minima Date: Mon, 1 Oct 2001 23:18:50 +0000 (+0000) Subject: add if you swear 3 or more times you are unceremoniously logged out X-Git-Tag: R_1_49~89 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c4f04ae165fdc765f3baa26fa2b28b52cf967674;p=spider.git add if you swear 3 or more times you are unceremoniously logged out --- diff --git a/Changes b/Changes index be153215..ef6a225f 100644 --- a/Changes +++ b/Changes @@ -11,6 +11,7 @@ of commands again without coredumps. Hurrah! 6. Add badword handling for messages. Users will get rude messages back if they try to send naughty words in msgs. Incoming messages with badwords will be dropped on receipt and their contents logged. +7. and if you swear 3 or more times you are unceremoniously logged out. 30Sep01======================================================================= 1. made some small bug fixes in rspf checking and also messages. 23Sep01======================================================================= diff --git a/cmd/announce.pl b/cmd/announce.pl index 0ea2e12f..d2755b2d 100644 --- a/cmd/announce.pl +++ b/cmd/announce.pl @@ -49,6 +49,7 @@ $line =~ s/\^/:/og; my @bad; if (@bad = BadWords::check($line)) { + $self->badcount(($self->badcount||0) + @bad); return (1, $self->msg('e17', @bad)); } diff --git a/cmd/dx.pl b/cmd/dx.pl index 85dc4cf9..c7161b62 100644 --- a/cmd/dx.pl +++ b/cmd/dx.pl @@ -94,7 +94,8 @@ if ($spotted le ' ') { return (1, @out) unless $valid; my @bad; -if (@bad = BadWords::check($line)) { +if (@bad = BadWords::check($line)) { + $self->badcount(($self->badcount||0) + @bad); return (1, $self->msg('e17', @bad)); } diff --git a/cmd/talk.pl b/cmd/talk.pl index 45ac857e..9b7d359d 100644 --- a/cmd/talk.pl +++ b/cmd/talk.pl @@ -40,6 +40,7 @@ return (1, $self->msg('e7', $call)) unless $dxchan; if ($line) { my @bad; if (@bad = BadWords::check($line)) { + $self->badcount(($self->badcount||0) + @bad); return (1, $self->msg('e17', @bad)); } $dxchan->talk($self->call, $to, $via, $line) if $dxchan; diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index f65e43df..580783a6 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -106,6 +106,8 @@ $count = 0; disconnecting => '9,Disconnecting,yesno', ann_talk => '0,Suppress Talk Anns,yesno', metric => '1,Route metric', + badcount => '1,Bad Word Count', + edit => '7,Edit Function', ); use vars qw($VERSION $BRANCH); diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 3972e8b5..ac0fb624 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+)/ ); @@ -241,7 +243,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; } diff --git a/perl/DXMsg.pm b/perl/DXMsg.pm index bb8cbb68..238bf1b3 100644 --- a/perl/DXMsg.pm +++ b/perl/DXMsg.pm @@ -886,6 +886,7 @@ sub do_send_stuff confess "local var gone missing" if !ref $self->{loc}; my $loc = $self->{loc}; if (my @ans = BadWords::check($line)) { + $self->{badcount} += @ans; Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} in msg"); return ($self->msg('e17', @ans), $self->msg('m1')); } @@ -942,6 +943,7 @@ sub do_send_stuff $self->state('prompt'); } else { if (my @ans = BadWords::check($line)) { + $self->{badcount} += @ans; Log('msg', $self->call . " used badwords: @ans to @{$loc->{to}} subject: '$loc->{subject}' in msg"); Log('msg', "line: $line"); return ($self->msg('e17', @ans));