🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #120719

Re: Show me your slrn score file.

#120719
From: Alan Gutierrez
Date: Mon, 24 Feb 2003 08:28
286 lines
9536 bytes
In article <gan83b.m67.ln@192.168.1.75>, HoboSong wrote:
> begin  quoting Alan Gutierrez

>> I am getting started with slrn and would like to see what people are
>> doing with their scorefiles.

>> Here are my basic questions:

>> * Is there a simple way to kill a thread with one stroke?
>> * Is there a simple way to plonk a poster with one stroke?

>   since I dont like to answer a bunch of questions when I plonk someone,
>   and I dont like a commented score file ... I just wrote a script that
>   pulls the From: header and adds it to a list that I build my scorefile
>   from. 

>   So to plonk someone I just pipe the message through "autoplonk"...

>   #!/usr/bin/perl
>   
>   $ScoreFile = "/home/chris/News/Score.plonks";
>   
>   open SCOREFILE, ">>$ScoreFile"  or die 
>   	"Cannot open $ScoreFile for appending: $!";
> 
>   while(<>) {
>    
>     if ( /^From:/ ) {
>       print SCOREFILE "\t$_";
>     }
> 
>   }
> 
>   close SCOREFILE;

Great. I expanded on this. I chose the Perl route since I'm not keen
to learn yet another macro langauge. The Perl program modifies a
score file called auto.score. It creates entries based on the
headers From, Message-ID, and Subject.

score [options] < [article]

-f              by From (default)
-m              by Message-ID
-S              by Subject

-k              kill, set score -9999
-i              ignore, set score -1000

-s [num]        set score to num
-p [num]        add num points to score (can be negative)
-e [interval]   expire after interval
                never 
                now - yesterday
                3d  - days                  - 3 days
                6w  - weeks                 - 6 weeks             
                4m  - months (roughly)      - 4 * 30 days
                2q  - quarters (roughly)    - 2 * 30 * 3 days
                3y  - years (roughly)       - 2 * 365 days
-g [group]      group for rule. the default is to use the
                Newsgroups header appending wildcard *.
-u [num]        Up, use group num levels above -g group.
-o              Only, do not append wildcard *.

Now I can plonk with one command. I can also add authors to the
auto.score file and move their scores up or down as I read their
articles. I created a shell script that takes arguments that are
easier to remember, that convey the intent. The script is called mod.

mod watch       score -m -e 3m -s 5000
mod ignore      score -m -e 3m -s -3000
mod boring      score -m -e 3m -s -5000
mod kill        score -m -e 3m -s -9999

mod nudge       score -f -p 50
mod boost       score -f -p 100
mod bravo       score -f -p 1000

mod dork        score -f -p -50
mod goob        score -f -p -500
mod idiot       score -f -p -5000
mod plonk       score -f -s -9999


Now all the cream is floating to the top. Usenet has become
manageable.

------>8------>8------>8------>8------>8------>8------>8------>8
#!/usr/bin/perl

use strict;
use warnings;

use File::Temp qw(tempfile);

my %args;
my %flags = map { $_ => 1 } qw(-k -i -S -f -m -o);
my %params = map { $_ => 1 } qw(-e -s -p -g -u);

while (@ARGV) {
    my $argv = shift @ARGV;
    $flags{$argv} && ++$args{$argv} && next;
    $params{$argv} || die "$0: what do you mean by $argv?";
    $params{$argv} && defined($args{$argv} = shift @ARGV) && next
        || die "$0: no argument for parameter $argv";
    last;
}

my $points = $args{'-p'};
my $score = $args{'-k'} ? -9999 :
            $args{'-i'} ? -1000 : 
            $args{'-s'} || 0;

$args{'-f'}++ unless $args{'-S'} || $args{'-m'};

my $expires;
if (defined $args{'-e'}) {
    my $days;
    local $_ = $args{'-e'};
    SWITCH: for ($args{'-e'}) {
        /^(\d+)d$/  and $days = $1;
        /^(\d+)w$/  and $days = $1 * 7;
        /^(\d+)m$/  and $days = $1 * 30; # close enough
        /^(\d+)q$/  and $days = $1 * 30 * 3; # close enough
        /^(\d+)q$/  and $days = $1 * 365; # close enough
        /^-?\d+$/ and $days = $_;
        /^never$/ and $days = '';
        /^now$/ and $days = -1;
    }
    defined $days or die "In correct argurment for -d";
    if ($days eq '') {
        $expires = '';
    }
    else {
        my @time = localtime(time + (60 * 60 * 24) * $days);
        $time[5] += 1900; $time[4]++; $time[3]++;
        $expires = sprintf "%d/%d/%d", @time[4, 3, 5];
    }
}

my ($article);
{
    local $/ = undef;
    $article = <>;
}

sub escape_slang_re ($) {
    local $_ = shift;
    s/\./\\./g;         # More to do, I'm sure.
    $_;
}

my ($rule);
if ($args{'-S'}) {
    my ($subject) = $article =~ /^Subject:\s(?:Re: )?(.*)\n/m;
    $subject or die "$0: cannot find Subject header.";
    $subject = escape_slang_re $subject;
    $rule = "Subject: $subject";
}
elsif ($args{'-f'}) {
    my ($from) = $article =~ /^From:\s(.*)$/m;
    $from or die "$0: cannot find From header.";
    if ($from =~ /<([^>]+)>/) {
        $from = $1;
    }
    else {
        $from =~ s/\s*\([^)]+\)//;
    }
    $from = escape_slang_re $from;
    $rule = "From: $from";
}
elsif ($args{'-m'}) {
    my ($message_id) = $article =~ /^Message-ID:\s<([^>]+)>/m;
    $message_id or die "$0: cannot find Message-ID header.";
    $message_id = escape_slang_re $message_id;
    $rule = "References: $message_id";
}

my $newsgroup = $args{'-g'};
if (!$newsgroup) {
    my ($newsgroups) = $article =~ /^Newsgroups:\s(.*)$/m;
    my @groups = split /,/, $newsgroups;
    if (my $up = $args{'-u'}) {
        $up =~ /^\d+$/ || die "$0: -u requires an integer";
        my %groups;
        foreach my $group (@groups) {
            my @path = split /\./, $group;
            splice(@path, - $up);
            $groups{join '.', @path}++;
        }
        @groups = keys %groups;
    }
    @groups > 1 && die "$0: article crossposted, you must specify group";
    $newsgroup = $args{'-o'} ? $groups[0] : "$groups[0]*";
}

my ($found);
if ($rule) {
    my $auto_mod = "%Auto-Mod - [$newsgroup] - $rule";
    if (-e 'news/auto.score')  {
        my ($temp, $tempname) = tempfile();
        open SCORES, "news/auto.score" or die $!;
        while (<SCORES>) {
            if ((index($_, $auto_mod) == 0) .. /^\s/) {
                s/^Score: (-?\d+)/"Score: " . (defined $points ? ($1 + $points) : $score)/e;
                if (defined $expires) {
                    s/^%?Expires: .*$/($expires eq '' ? '%' : '') . "Expires: $expires"/e;
                }
                $found++;
                print;
            }
            print $temp $_;
        }
        close SCORES or die $!;
        close $temp or die $!;
        rename ($tempname, 'news/auto.score') or die $!;
    }
}

if (not $found) {
    $expires ||= '';
    my $append = <<SCORE;
%Auto-Mod - [$newsgroup] - $rule
[$newsgroup]
Score: @{[ $points || $score ]}
@{[ $expires eq '' ? '%' : '' ]}Expires: $expires
        $rule
SCORE
    print $append;
    open APPEND, ">>news/auto.score" or die $!;
    print APPEND "%BOS\n";
    print APPEND $append;
    print APPEND "%EOS\n";
    close APPEND or die $!;
}
------>8------>8------>8------>8------>8------>8------>8------>8

------>8------>8------>8------>8------>8------>8------>8------>8
#!/bin/sh

up=""
group=""
score="-p 50"
by=-f
expires=""

while [ $# -gt 0 ]
do
    case $1 in
        nudge|neeto ) score="-p 50";;
        boost|cool ) score="-p 100";;
        nice ) score="-p 500";;
        bravo ) score="-p 1000";;
        watch ) score="-s 5000";;
        bump|dork ) score="-p -50";;
        shove|hurt|goob ) score="-p -500";;
        ignore ) score="-s -3000";;
        boring ) score="-s -5000";;
        idiot ) score="-s -5000";;
        kill|plonk ) score="-s -9999";;
        til) shift
             test "$1" != "" || exit 1
             expires="-e $1";;
        grp|group) shift
             test "$1" != "" || exit 1
             group="-g $1";;
        up) shift
             test "$1" != "" && up="-u $1" || up="-u 1";;
        *) echo "$0: unknown arg $1" && exit;
    esac
    case $1 in
        ignore|boring|msg|watch|kill)
            by=-m
            test "x$expires" = "x" && expires="-e 90d";;
        sub) by=-s;;
    esac
    shift
done

score $expires $score $by $up $group
------>8------>8------>8------>8------>8------>8------>8------>8

-- 
Alan Gutierrez - ajglist@izzy.net
http://khtml-win32.sourceforge.net/ - KHTML on Windows
Technical Details
Message-ID: <slrnb5jmv5.sb.ajglist@izzy.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!news-xfer.cox.net!p01!news2.east.cox.net.POSTED!53ab2750!not-for-mail
References: <slrnb5fm71.er3.ajglist@localhost.localdomain> <gan83b.m67.ln@192.168.1.75>

Show Full Headers
Complete Article Headers
Message-ID: <slrnb5jmv5.sb.ajglist@izzy.net>
Subject: Re: Show me your slrn score file.
Date: Mon, 24 Feb 2003 08:28:03 GMT
From: Alan Gutierrez <ajglist@izzy.net>
References: <slrnb5fm71.er3.ajglist@localhost.localdomain> <gan83b.m67.ln@192.168.1.75>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!news-xfer.cox.net!p01!news2.east.cox.net.POSTED!53ab2750!not-for-mail
Newsgroups: news.software.readers
User-Agent: slrn/0.9.7.4 (Linux)
Lines: 285
NNTP-Posting-Host: 68.14.102.70
X-Complaints-To: abuse@cox.net
X-Trace: news2.east.cox.net 1046075283 68.14.102.70 (Mon, 24 Feb 2003 03:28:03 EST)
NNTP-Posting-Date: Mon, 24 Feb 2003 03:28:03 EST
Organization: Cox Communications