#!/usr/bin/perl use FileHandle; # This is reflektor.pl # an usenet auto-reflektor, originally written by Jonas Luster, # contributed to by Robert Kiessling, first-time set up by # Harald Mueller and tweaked into storage-api by Elmar K. Bins. # # History # # 1999 02 19 elmi@newsbone.org (Elmar K. Bins) # added storage-api functionality - set the flag and path correctly ;-) # added more configurability # # # # Beware: Don't forget to exclude * from your newsfeeds when # feeding *.test to this reflector, or you'll regret it :( # # This version works perfectly with inn2.x by this newsfeeds line: # autoresponder!:!*,*.test:Tp:/reflektor.pl %s # # The current version of this branch can be found at # http://detebe.org/~news/software/ # require "ctime.pl"; $STORAGEAPI = 1; # elmi $sm = "/usr/local/inn/bin/sm" if ($STORAGEAPI); # elmi $logfile = "/var/log/news/reflector.log"; $sendmail = "/usr/sbin/sendmail"; $myfrom = "reflector\@detebe.org"; $myname = "detebe.org autoreflector"; $myxheaders = "X-Reflector: detebe.org\nX-URL: http://www.detebe.org/"; # select whether to use stdin or the API if ($STORAGEAPI) { $fhandle = new FileHandle; open ($fhandle, "$sm -R $ARGV[0]|") || exit 1; } else { $fhandle = STDIN; } # Log open (LOGFILE, ">> $logfile"); # Parse Header into hash #while (<>) { while (<$fhandle>) { $body .= "| " . $_; last if ($_ eq "\n"); ($feld,$wert) = split(/\s/,$_,2); chomp($wert); $wert =~ s/ //g; $header{$feld} = $wert; } # Get 20 Lines from the body $count = 0; #while (<>) { while (<$fhandle>) { $body .= "| " . $_ if $count < 20; $count++; } # Get Date. $date_act = &ctime(time()); # Where to send the Reply $email = $header{'From:'}; if ($header{'Reply-To:'} ne "") { $email = $header{'Reply-To:'}; } # Ingnore any posting containing the words below if ( lc($body . $header{'Subject:'}) =~ /please ignore|dont reply|don\'t reply|no reply|no replies|fuck off|keine antwort|keine reply|ignore|ignoriere|noreply|norep/i) { print LOGFILE "$email IN $header{'Newsgroups:'} [ignored]\n"; exit 0; } # Ignore Control-Messages #if ( lc($body . $header{'Control:'}) =~ /.*/ ) { # exit 0; #} if ($header{'Control:'}) { print LOGFILE "$email IN $header{'Newsgroups:'} [control message: ignored]\n"; exit 0; } # Log my dirty deeds :) print LOGFILE "$email IN $header{'Newsgroups:'} [replied]\n"; # Here's the mail itself. # Don't forget to change the path to sendmail open ( OUT, "| $sendmail -t"); print OUT <<__EOF__ From: $myfrom ($myname) To: $email Subject: Answer from Test Reflector (Re: $header{'Subject:'}) $myxheaders Hello, this message is never sent usolicited. Don't panic. You - or more precisely someone using your mail address - have posted a test message to the following Newsgroups: $header{'Newsgroups:'} Your message was sent $header{'Date:'} travelling from your location to the detebe.org (Germany). reaching detebe.org at $date_act and took its way along the path of $header{'Path:'} Reflector Mail is sent to anybody posting into a group ending with the words .test. If you don't want to receive reflector mails, include e.g. the words 'no reply' in your articles. For obvious reasons, mails to reflector\@detebe.org are directed into /dev/null. If you feel to write us, send your mail to usenet\@detebe.org instead. Full headers plus the first 20 lines of your original message were: $body -- Message sent by reflector.test (Jonas Luster, Harald Mueller, Elmar K. Bins) __EOF__