2 # This script accepts an email from moderators and processes
3 # an approval or a rejection.
6 $MNG_ROOT = $ENV{'MNG_ROOT'} || die "\$MNG_ROOT is not defined";
8 $Prefix = $ENV{'BOT_SUBJECT_PREFIX'}
9 || die "\$BOT_SUBJECT_PREFIX is not defined";
14 #######################################################################
15 # notifies the bot supporter
20 print STDERR "Approval error: " . $msg . "\n";
22 if( $MessageFile && -r $MessageFile ) {
23 system( "suspicious no NOTICE: This message is being RE-SENT to you because of the following error in your approval: $msg < $MessageFile" );
25 print STDERR "ERROR: Completely bogus approval from $From, $msg\n";
31 ####################################################################### main
42 if( /^Subject: /i && !$Subject ) {
45 $Subject =~ s/^Subject: //i;
49 $MessageNumber = $Subject;
50 $MessageNumber =~ s/^.*::$Prefix\///;
51 $MessageNumber =~ /(\d+)/;
54 $MessageFile = "$MNG_ROOT/tmp/messages/$MessageNumber";
56 if( !($MessageNumber =~ /[0-9]+/) || !(-r $MessageFile) )
58 $Error = "Message number in subject incorrect";
62 $Error = "no message number";
65 } elsif ( /^From: /i ) {
67 $From =~ s/^From: //i;
74 &processError($Error) if( $Error );
77 # Now we are looking at the body
89 $command = "processPreapproved xxx";
95 $command = "processApproved xxx ";
103 $reason =~ s/^.*reject //i;
104 $reason =~ s/( |`|'|"|;|\.|\/|\\)//g;
105 &processError( "wrong rejection reason" ) if( !$reason );
107 &processError( "Wrong rejection reason" )
108 if( !( -r "$MNG_ROOT/etc/messages/$reason" )
109 && ($reason ne "custom")
112 $command = "processRejected xxx $reason";
120 print STDERR "After body\n";
122 &processError( "No Command Specified" ) if( !$command );
128 $comment .= $_ while( <> );
132 print STDERR "Comment is: $comment\n" if( $comment );
134 $ENV{'EXPLANATION'} = $comment;
136 open( COMMAND, "| $command" ) || &processError( "$command failed" );
138 open( MESSAGE, "$MessageFile" ) || &processError( "Can't open $MessageFile" );
139 print COMMAND while( <MESSAGE> );
142 # if( $comment && !($command =~ '^processRejected') ) {
144 # "\n======================================= MODERATOR'S COMMENT: \n" .
149 &processError( "No action specified" )
150 if( $done ne "yes" );
152 unlink( $MessageFile );