🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #219629

Re: perl clients and a newsgroup list

#219629
From: Gerry Ford
Date: Sun, 20 Apr 2008 05:58
119 lines
4835 bytes
"Gerry Ford" <gerry@nowhere.ford> wrote in message 
news:1208476119_34@news.newsgroups.com...
>
> I've been looking at Mats Peterson's client for the last week.  He has a 
> perl script and a resource file for things like your server name.
>
> It occurs to me that a person would want to have another resource file of 
> some type that will hold the list of newsgroups.  With my newsfeed, 
> there's 100,000 of them, and I use a 56K dial-up, so it takes five or ten 
> minutes. When I fire up OE or binary vortex for the first time, it says 
> "hold on, I'm downloading the list of newsgroups.  This could take a 
> while, but you prettymuch only have to do it once."  Consequently it has 
> to be serialized somehow.


This script puts a file called newssrc2.txt in the same folder whence the 
scirpt is executed.  It contains an alphabetically-sorted list of everything 
your server wants to consider an ng. http://zaxfuuq.net/perl153.jpg .  To 
execute fully on a 56K modem, I needed 15 minutes.

#!/usr/bin/perl -w

use strict;
use Net::NNTP ();

use constant NUMBER_OF_ARTICLES    => 3;
use constant GROUP_NAME        => 'comp.lang.c';
use constant SERVER_NAME    => 'news.newsgroups.com';
use constant NNTP_DEBUG        => 1;

my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = 'wade196884';
my $PASS = '';

my %settings = (
    SERVER_NAME => '127.0.0.1',
    SERVER_PORT => 563,
    NEWSRC      => 'newsrc2.txt',
    DEBUG       => 1,
);

$nntp->authinfo($USER,$PASS) or die $!;


my($article_count, $first_article, $last_article) =

$nntp->group(GROUP_NAME) or die;


# Which XOVER fields contain Subject: and From:?
my $count = 0;
my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} );
die unless exists $xover_fmt{'Subject:'};
my $subject_offset = $xover_fmt{'Subject:'};
my $from_offset = $xover_fmt{'From:'};

my(@xover, $start_article);
RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >=

$first_article) {

    # How many articles do we need?  Stop retrieving if we have enough
    my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last

RETRIEVE;


    # Fetch overview information for the articles
    $start_article = $last_article - ($articles_required-1);
    $start_article = $start_article > $first_article ? $start_article :

$first_article;

    my $xover_query = $start_article == $last_article ?
    $start_article :
    [$start_article, $last_article];
    my $xover_ref = $nntp->xover($xover_query) or die;

    # Store headers for the articles we've retrieved
    foreach (sort {$b <=> $a} keys %$xover_ref) {
        push @xover, $xover_ref->{$_};
    }
} continue {
    # Move the pointer forward to fetch previous articles
    $last_article = $start_article - 1;
}

print join("\n", map ($_->[$subject_offset].' from '.$_->[$from_offset],

@xover)),"\n";
# end script that prints 3 arts from clc



my $groups = $nntp->list();

open my $newsrc, '>', $settings{NEWSRC}
    or die "Cannot open '$settings{NEWSRC}': $!";

print $newsrc join( "!\n", sort keys %$groups );

close $newsrc
    or die "Cannot close '$settings{NEWSRC}': $!";
# Disconnect from the NNTP server
$nntp->quit;


#  perl mats3.pl 2>text50.txt >text51.txt
__END__


-- 
"A belief in a supernatural source of evil is not necessary; men alone
are quite capable of every wickedness."

~~  Joseph Conrad (1857-1924), novelist 

Technical Details
Message-ID: <1208670700_2206@news.newsgroups.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!newscon02.news.prodigy.net!prodigy.net!news-out.superfeed.net!sp12lax.superfeed.net!not-for-mail
References: <1208476119_34@news.newsgroups.com>

Show Full Headers
Complete Article Headers
Message-ID: <1208670700_2206@news.newsgroups.com>
Subject: Re: perl clients and a newsgroup list
Date: Sun, 20 Apr 2008 00:58:59 -0500
From: "Gerry Ford" <gerry@nowhere.ford>
References: <1208476119_34@news.newsgroups.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!newscon02.news.prodigy.net!prodigy.net!news-out.superfeed.net!sp12lax.superfeed.net!not-for-mail
Lines: 118
Organization: Newsgroups.com
Newsgroups: news.software.readers
X-Proxy-User: $$s_iz$n-74p
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
X-Report: Please report illegal or inappropriate use to
 <abuse@newsgroups.com>. Forward a copy of ALL headers INCLUDING the body. (DO
 NOT SEND ATTACHMENTS)
X-Comments2: IMPORTANT: Newsgroups.com does not condone, support,
 nor tolerate spam or any illegal or copyrighted postings.
X-Comments: This message was posted through Newsgroups.com
X-Original-Bytes: 4388
X-Original-Lines: 137