chiark / gitweb /
fix noack function: store whole From line contents (not just the email address) in...
[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 chomp $From;
24 if( $From !~ m/([\w-\.]*)\@([\w-\.]+)/ || $From =~ m/\n/) {
25   print STDERR "From line `$From' is incorrect\n";
26   exit 0;
27 }
28
29 if( !&nameIsInListExactly( $From, "noack.list" ) ) { # need to preapprove
30   print STDERR "Adding $From to the noack list...\n";
31   open( NOACK, ">>$NoAckFile" ) or die $!;
32     print NOACK "$From\n" or die $!;
33   close( NOACK ) or die $!;
34 } else {
35   print STDERR "$From already is in noack list\n";
36 }
37
38 1;