#!/usr/local/bin/perl # The OpNet INN *.test autoresponse program # Version: 2.0.1 # # This software is Copyright (c) 1995 Jeff Weisberg # Permission is granted to use, copy and distribute this software # under the following conditions: # - This license covers the original software, as well as # modified or derived works. # - All modified or derived works must contain this notice # unmodified and in its entirety. # - This software is not to be used for any purpose which # may be considered illegal, immoral, or unethical. # - This software is provided as is and without warranty. # put something similar to the following line in your newsfeeds file # remember: your ME line is prepended # # AUTORESPOND!:!*,*.test:Tp:/usr/local/news/bin/autorespond /var/spool/news/%s # # you ought customize these $mailname = "OpNet Usenet Test-o-matic"; $mailaddr = "bitbucket\@op.net"; # aliased to /dev/null to toss bounced mail $adminaddr = "usenet\@op.net"; # news admin (real person) $logfile = "/var/adm/autorespond-log"; # define if you want a log kept # $debug = "/tmp/mail-debug"; # if defined no mail will be sent # no article? bail... exit unless( $ARGV[0] && -r $ARGV[0] ); $art = $ARGV[0]; # maximum number of lines from original message body to include in response $n = 10; # suck in article header while( ){ last if(/^$/); $n ++; /^Subject: (.*)/ && ($subject = $1); /^From: (.*)/ && ($from = $1); /^Reply-To: (.*)/ && ($reply = $1); /^Newsgroups: (.*)/ && ($groups = $1); } if( $debug ){ print "S: $subject\nF: $from\nR: $reply\nN: $groups\n"; } # no reply addr? gently place response in the bit bucket $reply = $from unless $reply; fail() unless $reply; # filter out mail that looks like it will just bounce fail() unless $reply =~ /[^\s<)]+@[^\s>(]+\.[^\s>(]+/; # this regex really screws up emacs... # ignore these users fail() if $reply =~ /anon-remailer/i; # sites to ignore fail() if $reply =~ /primenet\.net/i; fail() if $reply =~ /internet\.bcsmac\.org/i; fail() if $reply =~ /aol\.com/i; fail() if $reply =~ /anon\.penet\.fi/i; fail() if $reply =~ /foo\.com/i; fail() if $reply =~ /bar\.com/i; fail() if $reply =~ /\.uucp/i; # ignore (or close mispeling) in subject? don't respond # case insensitive as per 's request # foriegners may place their equivalent here fail('i') if $subject =~ /ignore/i; fail('i') if $subject =~ /gnore/i; fail('i') if $subject =~ /ignor/i; fail('i') if $subject =~ /ingore/i; fail('i') if $subject =~ /ignoer/i; fail('i') if $subject =~ /igonre/i; # ignore articles crossposted from non-test groups # this is often done as a prank to net-novices @ng = split(',', $groups); foreach $ng ( @ng ){ fail() unless $ng =~ /test/i; } # log it logit( '+' ); # ready, set, REPLY! if( $debug ){ open( MAIL, ">> $debug"); }else{ open( MAIL, "| /lib/sendmail -t -f $mailaddr") || die "cannot open mail pipe: $!"; } open( ARTICLE, $art) || die "cannot open article: $!"; print MAIL "To: $reply\n"; print MAIL "Subject: Re: $subject\n"; print MAIL "From: $mailname <$mailaddr>\n"; print MAIL "Precedence: junk\n"; # you ought customize the 1st para print MAIL <) && $n ){ $n --; print MAIL "> $l"; } close ARTICLE; close MAIL; exit 0; # END sub logit { local( $how ) = @_; local( $date ) = `/bin/date +'%T %D'`; if( $logfile ){ open( LOG, ">> $logfile"); print LOG "$how $reply\t$groups\t$date"; close LOG; } } sub fail { local( $why ) = @_; $why = '-' unless $why; logit( $why ); print "FAIL\n" if $debug; exit 0; }