chiark / gitweb /
Split nameIsInList into nameIsInListRegexp (for most things) and nameIsInListExactly...
[modbot-mtm.git] / stump / bin / processNoack.pl
1 #
2 # Processes the "No Ack" request
3 #
4
5 # get the directory where robomod is residing
6 $MNG_ROOT = $ENV{'MNG_ROOT'} || die "Root dir for moderation not specified";
7
8 # common library
9 require "$MNG_ROOT/bin/robomod.pl";
10
11 $NoAckFile = "$MNG_ROOT/data/noack.list";
12
13 $Argv = join( ' ', @ARGV );
14
15 while( <STDIN> ) {
16   $From = $_ if( /^From: / );
17
18   chop;
19   last if( /^$/ );
20 }
21
22 $From =~ s/^From: //;
23 if( $From =~ m/([\w-\.]*)\@([\w-\.]+)/ ) {
24   $From = "$1\@$2";
25 } else {
26   print STDERR "From line `$From' is incorrect\n";
27   exit 0;
28 }
29
30 if( !&nameIsInListExactly( $From, "noack.list" ) ) { # need to preapprove
31   print STDERR "Adding $From to the noack list...\n";
32   open( NOACK, ">>$NoAckFile" ) or die $!;
33     print NOACK "$From\n" or die $!;
34   close( NOACK ) or die $!;
35 } else {
36   print STDERR "$From already is in noack list\n";
37 }
38
39 1;