chiark / gitweb /
Re-instate the blocklist of banned posters
[modbot-ulm.git] / webstump / scripts / filter.lib.pl
index b98b22d731bde5d8039484dff7f4426fb0792d5b..b82a55a52e836b46979827242141b983c6ca66e8 100644 (file)
 # Subject, newsgroup, ShortDirectoryName, decision, comment
 
 sub process_approval_decision {
-
+  my $cathow = @_>=6 ? pop(@_) : "UNKNOWN";
   my $comment = pop( @_ );
   my $decision = pop( @_ );
   my $ShortDirectoryName = pop( @_ );
   my $newsgroup = pop( @_ );
   my $Subject = pop( @_ );
+  my $now = time;
 
   my $address = $newsgroups_index{$newsgroup};
 
@@ -28,7 +29,10 @@ sub process_approval_decision {
   $message .= "comment $comment\n" if $comment;
   &email_message( $message, $address );
 
-print STDERR "DECISION: $decision for $ShortDirectoryName sent to $address, for $newsgroup\n";
+  my $sanisubj= $Subject;
+  $sanisubj =~ s/.*\:\://;
+
+print STDERR "DECISION: $newsgroup | $ShortDirectoryName | $decision | $cathow | $now | $sanisubj\n";
 
   &rmdir_rf( &article_file_name( $ShortDirectoryName ) );
 
@@ -40,6 +44,7 @@ print STDERR "DECISION: $decision for $ShortDirectoryName sent to $address, for
 # against the substrings as regexps and substrings as literal substrings.
 #
 # Arguments: address, listname
+
 sub name_is_in_list { # address, listname
   my $listName = pop( @_ );
   my $address = pop( @_ );
@@ -47,20 +52,23 @@ sub name_is_in_list { # address, listname
   my $item = "";
   my $Result = "";
 
-  $address = "\L$address";
-
   open( LIST, &full_config_file_name( $listName ) ) || return "";
 
   while( $item = <LIST> ) {
 
-    chop $item;
-
-    next if $item =~ /^\s*$/;
+    chomp $item;
 
-    my $quoted_item = quotemeta( $item );
+    next unless $item =~ /\S/;
+    next if $item =~ /^\s*\#/;
 
-    if( eval { $address =~ /$item/i; } || $address =~ /$quoted_item/i ) {
-      $Result = $item;
+    if ($listName eq 'good.posters.list') {
+       if( lc $address eq lc $item ) {
+           $Result = $item;
+       }
+    } else {
+       if( eval { $address =~ /$item/i; } ) {
+           $Result = $item;
+       }
     }
   }
 
@@ -69,7 +77,6 @@ sub name_is_in_list { # address, listname
   return $Result;
 }
 
-
 ######################################################################
 # reviews incoming message and decides: approve, reject, keep
 # in queue for human review
@@ -86,20 +93,7 @@ sub review_incoming_message { # Newsgroup, From, Subject, RealSubject, Message,
   my $newsgroup = pop( @_ );
 
   if( &name_is_in_list( $from, "bad.posters.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "reject abuse", "" );
-    return;
-  }
-
-  if( &name_is_in_list( $real_subject, "bad.subjects.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "reject thread", "" );
-    return;
-  }
-
-  if( &name_is_in_list( $message, "bad.words.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "reject charter", 
-    "Your message has been autorejected because it appears to be off topic
-    based on our filtering criteria. Like everything, filters do not
-    always work perfectly and you can always appeal this decision." );
+    &process_approval_decision( $subject, $newsgroup, $dir, "reject blocklist", "", "auto bad poster" );
     return;
   }
 
@@ -114,12 +108,6 @@ print STDERR "Filing Article for review because poster '$from' matches '$match'\
     return; # file message
   }
 
-  if( $match = &name_is_in_list( $real_subject, "watch.subjects.list" ) ) {
-    &append_to_file( $warning_file, "Warning: subject '$real_subject' matches '$match' from the list of suspicious subjects\n" );
-print STDERR "Filing Article for review because subject '$subject' matches '$match'\n";
-    return; # file message
-  }
-
   if( $match = &name_is_in_list( $message, "watch.words.list" ) ) {
     &append_to_file( $warning_file, "Warning: article matches '$match' from the list of suspicious words\n" );
 print STDERR "Filing Article for review because article matches '$match'\n";
@@ -127,12 +115,8 @@ print STDERR "Filing Article for review because article matches '$match'\n";
   }
 
   if( &name_is_in_list( $from, "good.posters.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "" );
-    return;
-  }
-
-  if( &name_is_in_list( $real_subject, "good.subjects.list" ) ) {
-    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "" );
+    &process_approval_decision( $subject, $newsgroup, $dir, "approve", "",
+                                "auto good poster" );
     return;
   }