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+)/;
53 $ENV{'WEBSTUMP_MESSAGENUM'}= $MessageNumber;
55 $MessageFile = "$MNG_ROOT/tmp/messages/$MessageNumber";
57 if( !($MessageNumber =~ /[0-9]+/) || !(-r $MessageFile) )
59 $Error = "Message number in subject incorrect";
63 $Error = "no message number";
66 } elsif ( /^From: /i ) {
68 $From =~ s/^From: //i;
75 &processError($Error) if( $Error );
78 # Now we are looking at the body
90 $command = "processPreapproved xxx";
96 $command = "processApproved xxx ";
104 $reason =~ s/^.*reject //i;
105 $reason =~ s/( |`|'|"|;|\.|\/|\\)//g;
106 &processError( "wrong rejection reason" ) if( !$reason );
108 &processError( "Wrong rejection reason" )
109 if( !( -r "$MNG_ROOT/etc/messages/$reason" )
110 && ($reason ne "custom")
113 $command = "processRejected xxx $reason";
121 print STDERR "After body\n";
123 &processError( "No Command Specified" ) if( !$command );
129 $comment .= $_ while( <> );
133 print STDERR "Comment is: $comment\n" if( $comment );
134 print STDERR "Signal handling for SIGPIPE: $SIG{PIPE}.\n";
136 $ENV{'EXPLANATION'} = $comment;
138 open( COMMAND, "| $command" ) || &processError( "$command failed" );
140 open( MESSAGE, "$MessageFile" ) || &processError( "Can't open $MessageFile" );
141 while( <MESSAGE> ) { print COMMAND or die $!; }
142 close( MESSAGE ) or die "$? $!";
144 # if( $comment && !($command =~ '^processRejected') ) {
146 # "\n======================================= MODERATOR'S COMMENT: \n" .
149 close( COMMAND ) or die "$command $? $!";
151 &processError( "No action specified" )
152 if( $done ne "yes" );
154 unlink( $MessageFile );