Re: Any way to keep 1-line record of my postings?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




- I use scoring to keep track of my posts.
Basically I hacked Pnews to add a scoring line
for the subject of my posts.

- There's also the Outgoing archive as well.

setenv AUTHORCOPY "/usr/users/bbense/News/Outgoing"

will archive a copy of all your outgoing posts.


- Here's the perl bits that save the scores for me.
Hacking Pnews to use this script is left as an
exercise for the reader.

#!/usr/bin/perl

++$DEBUG ;
# read in posted article and add subject: $subject line to appropriate
# score file

$SCORE_DIR = '/home/user/.trn/scores' ;
$POST_SCORE = '+25' ;

# Get date,time
$now = time ;
($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime($now))[0,1,2,3,4,5,6];

$year += 1900 ;

$date = "$year:$mon:$mday" ;

if ( -f $ARGV[0] ) {

    $HEADER = $ARGV[0] ; #

    if ( $ARGV[1] && $ARGV[1] > 0 ) {
	$POST_SCORE = $ARGV[1] ;
    }
} else { # Expect article on stdin
    if ( $ARGV[0] && $ARGV[0] > 0 ) {
	$POST_SCORE = $ARGV[0] ;
    }
    $HEADER = 'STDIN' ;
}




# Standard rfc822 header slurper
$lastHeader = "" ;
if ( $HEADER ne 'STDIN' ) {
    open(HEADER ,"<$HEADER") || die ("Cannot open file $HEADER");
    $HEADER = 'HEADER' ;
}
#
while ( <$HEADER> ) {
	chop ;
	$DEBUG && print "$_\n" ;
	last unless ( $_ ) ;
	if ( /^[A-Za-z0-9\-]*\:/ ) {
	    @Tmp = split(/\:/,$_) ; # could use ($&,$') but this
	                            #is faster
	    $tmp = shift (@Tmp);
	    $tmp = lc($tmp) ;
	    $tmp = ucfirst($tmp) ;
	    $tmp =~ s/-//g ; # Get rid of dashes
	    if ( $Headers{$tmp} ) {
		$Headers{$tmp} .= join(':',@Tmp)  ;
	    } else {
		$Headers{$tmp} = join(':',@Tmp);
	    }
	    $lastHeader = $tmp ;
	} elsif ( /^\s/ ){	# Tab [WhiteSpace] starts continuation lines
	    if ( $lastHeader ) {
		$Headers{$lastHeader} .= $_;
	    }
	}


}
close(HEADER);

# Now get Newsgroup file

@Newsgroups = split(/,/,$Headers{'Newsgroups'});

$Subject = $Headers{'Subject' } ;
$Subject =~ s/[a-z]*\://i ;
$Subject = lc($Subject ) ;

foreach $file ( @Newsgroups ) {

    $file = dewhite($file) ;
    $already = "" ;
    $DEBUG &&  print ":$SCORE_DIR/$file:\n" ;
# Make sure we haven't already added this score
    open(NG,"<$SCORE_DIR/$file") || next ;
    while( <NG> ) {
    if ( /\Q$Subject/ ) {
	print "Already scored $Subject\n$_\n" ;
	$already++ ; last;
    }}
    close(NG) ;
# Mark the score with date comment
    if ($already) { next ; }
    open(NG,">>$SCORE_DIR/$file" ) || next ;
    $comment = "\#AutoPostScore: $date\n" ;
    print NG $comment ;
    print NG "$POST_SCORE subject: $Subject\n";
    print "$POST_SCORE subject: $Subject\n";
    close(NG) ;

}



sub dewhite {
    local($string) = @_ ;
    $string =~ s/^\s*// ;
    $string =~ s/\s*$// ;
    return $string ;


}


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm


[Index of Archives]     [Photo]     [Yosemite]     [Epson Inkjet]     [Mhonarc]     [Nntpcache]

  Powered by Linux