chiark / gitweb /
Initial commit as found
[modbot-mtm.git] / stump / bin / processPreapproved
1 #!/usr/bin/perl
2 #
3 # Preapproves the person and gets his/her message posted via processApproved
4 #
5
6 # get the directory where robomod is residing
7 $MNG_ROOT = $ENV{'MNG_ROOT'} || die "Root dir for moderation not specified";
8
9 # common library
10 require "$MNG_ROOT/bin/robomod.pl";
11
12 $GoodGuys = "$MNG_ROOT/data/good.guys.list";
13
14 $Argv = join( ' ', @ARGV );
15
16
17 open( PROCESS_APPROVED, "|processApproved $Argv" );
18
19 while( <STDIN> ) {
20   $From = $_ if( /^From: / );
21
22   print PROCESS_APPROVED;
23
24   chop;
25   last if( /^$/ );
26 }
27
28 while( <STDIN> ) { # Body
29   print PROCESS_APPROVED;
30 }
31
32 close PROCESS_APPROVED;
33
34 $From =~ s/^From: //g;
35 if( $From =~ m/([\w-\.]*)\@([\w-\.]+)/ ) {
36   $From = "$1\@$2";
37 } else {
38   print STDERR "From line `$From' is incorrect\n";
39   exit 0;
40 }
41
42 if( !&nameIsInList( $From, "good.guys.list" ) ) { # need to preapprove
43   &logAction( "Action: processPreapproved $From\n" );
44   open( GOOD_GUYS, ">>$GoodGuys" );
45     print GOOD_GUYS "$From\n";
46   close( GOOD_GUYS );
47 } else {
48   print STDERR "$From already preapproved\n";
49 }