2 # this script processes "suspicious" messages. It does basically two things:
4 # 1. Sends an acknowledgment to the author, if necessary (ie if the author did
5 # not turn ack mode off), and
6 # 2. Prepares, signs, and sends the message to a randomly chosen human
7 # moderator for review.
10 $MNG_ROOT = $ENV{'MNG_ROOT'};
11 $Prefix = $ENV{'BOT_SUBJECT_PREFIX'};
12 $tempFile = "$ENV{'TMP'}/signed.$$";
14 # name of moderator to test
15 $TestModerator = "eugenez\@mit.edu";
17 $isTesting = 0; # No testing by default
18 $TestFlag="test-test";
20 $needAck = $ARGV[0]; shift @ARGV;
22 $message = join( " ", @ARGV );
24 print STDERR "Needack = $needAck\n";
27 ######################################################################
32 #open IWJL, ">>/home/webstump/t.log";
33 #print IWJL "=========== SUSPICIOUS READMESSAGE\n";
36 #print IWJL "SsRm $_\n";
40 $isKOI8 = $isKOI8 || $_ =~ /[\x80-\xFF]/;
50 if( /^Newsgroups: / ) {
52 } elsif( /^Subject: / ) {
53 $Subject = substr( $_, 0, 50 );
55 if( $Subject =~ /$TestFlag/i ) { # special subject
59 } elsif( /^From: / ) {
61 if ($From =~ m/([\w-\.]+)@([\w-\.]*)[^\w-\.]/){
62 $From = "From: $1\@$2";}
63 } elsif( /^Path: / ) {
65 } elsif( /^Keywords: / ) {
67 } elsif( /^Summary: / ) {
69 } elsif( /^Message-ID: / ) {
77 $MNG_ROOT = "$ENV{'MNG_ROOT'}" || die "Root dir for moderation not specified";
81 #$Body =~ s/From /_From /g;
84 if( $isTesting eq 'y' ) {
85 $moderator = $From; # $TestModerator;
86 $moderator =~ s/^From: //i;
88 } else { # get random moderator
89 open( MODERATORS, "$MNG_ROOT/etc/moderators" )
90 || die "can't open moderators file";
92 while( <MODERATORS> ) {
95 ($name, $priority, $flags) = split;
97 if( $priority != 0 && ! ($isKOI8 && $flags =~ /nokoi/i)) {
98 # priority 0 means "on vacation"
99 push( @moderators, $name );
106 $randNum = rand 100 + time;
108 $moderator = $moderators[ $randNum % ($#moderators + 1) ];
112 $modNick = $moderator;
117 $date = `date`; chop $date;
119 print STDERR "Activity: $date Forwarding $Message_ID, $Subject from $From ".
120 "to $moderator for approval\n";
122 $MessageNumber = time . $$;
124 print STDERR "Opening $MNG_ROOT/tmp/messages/$MessageNumber\n";
126 open( MESSAGE, "> $MNG_ROOT/tmp/messages/$MessageNumber" ) or die $!;
127 print MESSAGE $Body or die $!;
128 close( MESSAGE ) or die $!;
130 $Subject = "Subject: try again" if( !$Subject );
132 open( COMMAND, "| sendmail -odb -oi $moderator > /dev/null" ) or die $!;
134 print COMMAND "From: $ENV{'DECISION_ADDRESS'}
135 $Subject ::$Prefix/$MessageNumber
137 X-Moderate-For: $ENV{'NEWSGROUP'}
138 Organization: Robots Are Us
142 This is an automated message sent to you as the moderator of
143 $ENV{'NEWSGROUP'}. Simply reply to this message,
144 DO NOT quote the message body in your reply, and state your decision ON
145 THE FIRST LINE, choosing LITERALLY from ONE of the following options
146 (you can even cut and paste):
152 open( REASONS, "$MNG_ROOT/etc/rejection-reasons.lst" ) or die $!;
154 ($reason, $explanation) = split( /::/, $_ );
155 print COMMAND "reject $reason\n" or die $!;
157 close( REASONS ) or die $!;
161 You can also specify a comment, by typing word comment at the
162 beginning of a line _after_ approve, preapprove, or reject, and
163 then your comment on one or several lines. Do NOT put your comment
164 before approve, preapprove, or reject.
167 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
170 print COMMAND $Body or die $!;
171 close( COMMAND ) or die "$? $!";
173 if( $needAck eq "yes" ) {
174 open( ACK, "| modack.received" ) or die $!;
175 print ACK $Body or die $!;
176 close( ACK ) or die "$? $!";