๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #177371

Re: Xnews: Kill initial poster and all followups

#177371
From: Mike Yetto
Date: Fri, 09 Dec 2005 23:42
241 lines
6720 bytes
It was April the forty-first, being a quadruple leap year,
when ยปQยซ wrote...

> If there's nothing unique in the MID, the best you can do in
> Xnews is flag the troll's posts then kill the thread every time
> you see one. Someone wrote a script to do that automagically
> once, but I've lost track of it.
> 
This what you're looking for?

You'll need to "unwrap" the lines properly, and I think I made a 
modification or two, but don't remember what they were.  There's an 
ini file to go with it.

killrefs.pl
====
#!/usr/bin/perl -w

use strict;

use News::NNTPClient;
use File::Basename;

my ($debug, $ini_file, $server_name, $user_name, $password, $newsrc, 
$old_score_file, $expire_in_days, $score_value, @bad_from, 
$new_score_file, $backup_score_file, @score_file, $group, $c, $first, 
$last, $rest, $last_read, $article, $message_id, $from, $bad_from, 
@message_ids, $mt, $mday, $mon, $year, $found, $score_file, $mid);
my $already_printed = 0;

my ($basename, $path, $ftype) = fileparse($0, ".pl");

# 0 - print nothing
# 1 - print results going out
# 2 - print both input and output

$debug = 1;

if ( $#ARGV > -1 )
{
    $ini_file = $ARGV[0];
}
else
{
    $ini_file = $path . "killrefs.ini";
}

open(INI_FILE, $ini_file) or die "Can't open $ini_file";

chomp($server_name = <INI_FILE>);
chomp($user_name = <INI_FILE>);
chomp($password = <INI_FILE>);
chomp($newsrc = <INI_FILE>);
chomp($old_score_file = <INI_FILE>);
chomp($expire_in_days = <INI_FILE>);
chomp($score_value = <INI_FILE>);

while (<INI_FILE>)
{
    chomp;
    push @bad_from, $_;
}

$c = new News::NNTPClient($server_name);

$c->authinfo($user_name, $password) or die "Can't connect to 
$server_name as $user_name";

#print "Server:\t $server_name\n";
#print $c->list('overview.fmt');

$new_score_file = $old_score_file . "_new";
$backup_score_file = $old_score_file . "_bak";

open(NEWSRC, $newsrc) or die "Can't open $newsrc";
open(OLD_SCORE_FILE, $old_score_file) or die "Can't open 
$old_score_file";

@score_file = <OLD_SCORE_FILE>;

close OLD_SCORE_FILE;

while (<NEWSRC>)
{
    next if ! /:/;
    next if /:$/;

    chomp;

    ( $group, $rest ) = split(':');

    ( $first, $rest ) = split('-', $rest);

    ( $last_read, $rest ) = split('/', $rest);

    ( $last_read, $rest ) = split(',', $last_read);

    ( $first, $last ) = ( $c->group($group) );

    $debug > 1 && print "$group $first $last_read $last\n";

    for $from ($c->xhdr("From", $last_read, $last))
    {
        $debug > 1 && print "$from\n";

        for $bad_from (@bad_from)
        {
            if ( $from =~ /$bad_from/ )
            {
                ( $article, $rest ) = split(' ', $from);

                ( $message_id ) = $c->xhdr("Message-ID", $article);

                chomp $message_id;

                $message_id =~ s/^.*<(.*)>$/$1/;

                $debug > 1 && print $message_id, "\n";

                push @message_ids, $message_id;

                #it's been found, stop looking
                last;
            }
        }
    }
}

$debug && print "Done reading\n";

if ( $#message_ids > -1 )
{
    open(NEW_SCORE_FILE, ">$new_score_file") or die "Can't open 
$new_score_file";

    $mt = time() + $expire_in_days * 86400;

#    (undef,undef,undef,$mday,$mon,$year,undef,undef) = gmtime($mt);
    (undef,undef,undef,$mday,$mon,$year,undef,undef) = 
localtime($mt);

    $year += 1900;
    $mon += 1;

    $found = 0;

    for $score_file (@score_file)
    {
        print NEW_SCORE_FILE $score_file;

        next if $found;

        next if ! ( $score_file =~ /^\[\.\]/ );

        $found = 1;

        print_message_ids();
    }

    if ( not $found )
    {
        print NEW_SCORE_FILE "\n\[\.\]\n";

        print_message_ids();
    }

    close NEW_SCORE_FILE;

    rename $old_score_file, $backup_score_file or die "Can't rename 
$old_score_file to $backup_score_file";
    rename $new_score_file, $old_score_file or die "Can't rename 
$new_score_file to $old_score_file";
}
else
{
    $debug && print "No message ids this time!\n";
}

sub print_message_ids
{
    for $mid (@message_ids)
    {
        $mid =~ s/\$/\\\$/g;
        $mid =~ s/\./\\./g;
        $mid =~ s/\-/\\-/g;

        $debug && print $mid, "!\n";

        if ( not $already_printed) {
	    	print NEW_SCORE_FILE "\n    % generated by KillRefs.pl\n    
Score:: $score_value\n        Expires: $mon/$mday/$year\n";
	    	$already_printed = 1;
    		}

    	print NEW_SCORE_FILE "        References: <$mid>\n";
    }
}

====

killrefs.ini

====
news.readfreenews.net
<uid> if any
<password> if any
?:\XNews\ReadFreeNews.newsrc
?:\\Xnews\\score.ini
10
-9999
Leythos
rmholt
Casner
Ragnar Suomi
java@evij.com
jkb@yeahright.com
none@no.way
Bob McConnell
rmcconne@NOSPAM.lightlink.com
Hal.Turner@HalTurnerShow.com
Alan Connor
Georg Ten Brouck
hiawatha@efn.org
galen thurber
paul kneisel
rose marie holt
Peter H.M. Brooks
Dusty Dahmer
Ed Conrad
edconrad@verizon.net
Danny@DD.net
====

    	Mike "don't use it much though" Yetto
-- 
myetto1 at nycap dot rr dot com
Never trust anyone whose suit is nicer than your own.
    - Ferengi Rule of Acquisition #47.


Technical Details
Message-ID: <Xns9727BE45EFE34uniquelyme@syrcnyrdrs-03-ge0.nyroc.rr.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-rtr.nyroc.rr.com!news-out.nyroc.rr.com!twister.nyroc.rr.com.POSTED!53ab2750!not-for-mail
References: <Xns9727748998561klaatunospaminvalid@127.0.0.1> <MrQ97279182E7F4itsmeitsQ@QsFQDN.dyndns.org>

Show Full Headers
Complete Article Headers
Message-ID: <Xns9727BE45EFE34uniquelyme@syrcnyrdrs-03-ge0.nyroc.rr.com>
Subject: Re: Xnews: Kill initial poster and all followups
Date: Fri, 09 Dec 2005 23:42:16 GMT
From: Mike Yetto <mike.yetto@nycap.invalid>
References: <Xns9727748998561klaatunospaminvalid@127.0.0.1> <MrQ97279182E7F4itsmeitsQ@QsFQDN.dyndns.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-rtr.nyroc.rr.com!news-out.nyroc.rr.com!twister.nyroc.rr.com.POSTED!53ab2750!not-for-mail
Newsgroups: news.software.readers
Organization: None at all
User-Agent: Xnews/2005.10.18
X-Face: |r>RlUD1uaj^+}lH:1x}DRPEVBE10?q; 6kK-z/g54Sm5un@|e'd;
 MBx>,mw4U_J{:@+2{^77p/rY\g%7gE$V,}ZT?e>5tttHXeodYk\'q1Jv5R1Y@297IYtjygnnPfR4'8>3c:<<bJtx#[<5rd-UP_F?\?j>[5:.5ViK#8o+?^D{hi=c0]5Z=6d,|`tq_:(C1(1`@FbN)Cj(]D*}z[o"<~cu!|Is\2(e#[-Fjeg_M7PS/@LG
X-No-Banansa: Yes
Lines: 241
NNTP-Posting-Host: 24.195.138.81
X-Complaints-To: abuse@rr.com
X-Trace: twister.nyroc.rr.com 1134171736 24.195.138.81 (Fri,
NNTP-Posting-Date: Fri, 09 Dec 2005 18:42:16 EST