add if you swear 3 or more times you are unceremoniously logged out
authorminima <minima>
Mon, 1 Oct 2001 23:18:50 +0000 (23:18 +0000)
committerminima <minima>
Mon, 1 Oct 2001 23:18:50 +0000 (23:18 +0000)
Changes
cmd/announce.pl
cmd/dx.pl
cmd/talk.pl
perl/DXChannel.pm
perl/DXCommandmode.pm
perl/DXMsg.pm

diff --git a/Changes b/Changes
index be153215eff6c72fc52a51086190b9e483b54cd8..ef6a225f34aa6774cc7fee0a9a2af120321c9ce6 100644 (file)
--- 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=======================================================================
index 0ea2e12fdf8bbcf8369d75bb59f8be724a91f3e8..d2755b2df46309014c1b657e717baa94376992f4 100644 (file)
@@ -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));
 }
 
index 85dc4cf91f47aba2df092596b78eca31b2d218f5..c7161b62b7887c99d232362b1249e61ad6c0060c 100644 (file)
--- 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));
 }
 
index 45ac857ee935bf7bb7fa7f142435f79da82edf5b..9b7d359d3d6323aff40889ddbe13e4069b28c4a7 100644 (file)
@@ -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;
index f65e43df41be75d009a10f799de5eff8d6b1719f..580783a6a466383f2ae8fac35106c03d2f38e38f 100644 (file)
@@ -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);
index 3972e8b5b6509ebab966b8aa5303cab3e3cb6e69..ac0fb62470a942cf5c8d95830d7ff77b02507385 100644 (file)
@@ -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;
 }
index bb8cbb68331692ce272df62b938c94c54e27f6bd..238bf1b3ddba2a5898d276b0d4d6d307c26438af 100644 (file)
@@ -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));