chiark / gitweb /
Split nameIsInList into nameIsInListRegexp (for most things) and nameIsInListExactly...
[modbot-mtm.git] / stump / bin / robomod.pl
index 3534c5ab152d9e303be877c8330b692ecf0c5203..09888a18d3b97fd4976c1d3963064e96618e5d3a 100755 (executable)
@@ -7,7 +7,7 @@ $MNG_ROOT = $ENV{'MNG_ROOT'} || die "Root dir for moderation not specified";
 
 ###################################################################### checkAck
 # checks if poster needs ack
-sub nameIsInList {
+sub nameIsInListRegexp {
   local( $listName ) = pop( @_ );
   local( $address ) = pop( @_ );
 
@@ -23,7 +23,33 @@ sub nameIsInList {
 
     next if $item =~ /^ *$/;
 
-    if( eval { $address =~ /$item/i; } || "\L$address" eq "\L$item" ) {
+    if( eval { $address =~ /$item/i; } ) {
+      $Result = $item;
+    }
+  }
+
+  close( LIST );
+
+  return $Result;
+}
+
+sub nameIsInListExactly {
+  local( $listName ) = pop( @_ );
+  local( $address ) = pop( @_ );
+
+  local( $item );
+
+  $Result = 0;
+
+  open( LIST, "$MNG_ROOT/data/$listName" );
+
+  while( $item = <LIST> ) {
+
+    chop $item;
+
+    next if $item =~ /^ *$/;
+
+    if( "\L$address" eq "\L$item" ) {
       $Result = $item;
     }
   }