Article View: news.software.readers
Article #195696Re: [slrn]How to...?
From: Dave Gibson
Date: Sat, 17 Feb 2007 11:03
Date: Sat, 17 Feb 2007 11:03
210 lines
7497 bytes
7497 bytes
SINNER <99nesorjd@gates_of_hell.invalid> wrote:
> * Whiskers wrote in news.software.readers:
>> On 2007-02-14, SINNER <arcade.master@gmail.com> wrote:
>>> * Whiskers wrote in news.software.readers:
>
>>> [sn functinality]
>
>>>> You can
>>>> subscribe to newsgroups on several upstream sites, and you can create
>>>> local newsgroups that are not propagated upstream.
>
>>> Leafnode does have this functionality but converting My_Posts to single
>>> articles and passing msgid's to leafnode would prove difficult me thinks.
>
>> sn includes a utility 'snmail' to which the instructions are to 'pipe'
>> email from within the email program used for receiving the emails. This
>> seems to be the key to converting the email messages into a news-spool.
>
> Nice! I imagine a perl script or similar could be written to breakdown
> slrns file, but its beyond my knowledge.
Awk and inews seem ok.
A few of the variables used in the repost_mbox script (below) may be set
on the command line (via awk -v var=value -v var=value):
first_post=N
Posting begins with the Nth message in the digest.
Defaults to the first message in the file.
last_post=N
Posting ends with the Nth message in the digest.
Defaults to the last message in the file.
host_name="xxx.yyy.zzz"
Use xxx.yyy.zzz as hostname when generating message-ids.
Defaults to the first name in /etc/HOSTNAME or the output of
the hostname command if /etc/HOSTNAME is unavailable.
Use like this:
nawk -v first_post=10 -v last_post=15 -v host_name="wabbit.name" \
-f repost_mbox ~/.slrn/Your_Posts
On the first run, just post everything in the digest and make a note of
how many messages were posted. On following runs, specify the updated
posts only:
$ nawk -f repost_mbox your_posts_as_an_mbox
Posting message 1
[...]
Posting message 1182
Send a few posts, then:
$ nawk -v first_post=1183 -f repost_mbox ~/.slrn/Posts
The script has to run through the whole digest to do the MID fixups.
Look for '@@@@' to see suggested edit locations.
The script is currently set up to use cat, rather than inews, and just
prints the messages on stdout.
---- repost_mbox begins
#! /usr/bin/nawk -f
BEGIN {
local_group = "local.posted" # @@@@ The local group to post to.
x_prefix = "X-Prior-" # @@@@ Used to re-name some headers.
msgid_pfx = "local-repost-" # @@@@ prefix for generated MIDs
out_proc = "cat" # @@@@ "cat" for testing
#out_proc = "inews" # @@@@ "inews" for real
host_name = get_hostname(host_name)
if (host_name == "") {
print "No hostname? Bye."
exit
}
ctr = 0
outf = "/dev/null"
}
# New message.
/^From / {
close(outf)
++ctr
msgid = generate_msgid(ctr, host_name)
if (ctr >= first_post && (last_post == 0 || ctr <= last_post)) {
print_ok = 1
printf "Posting message %d\n", ctr
} else
print_ok = 0
outf = out_proc
in_hdr = 1
next
}
# A header line beginning with white space continues the previous line.
pending_hdr && /^[[:space:]]/ {
pending_hdr = pending_hdr "\n" $0
next
}
# Note: this rule must follow the pending_hdr && /^[[:space:]]/ rule
# to catch both /^[^[:space:]]/ and /^$/
pending_hdr {
if (in_ref) {
# pending_hdr is the References: line. Copy the MIDs across to the new
# References: header, updating MIDs to reflect reposting into the local
# group where appropriate. This should preserve threading.
references = ""
n = split(pending_hdr, r, /[[:space:]]+/)
for (i = 2; i <= n; i++) {
if (r[i] in msgid_map)
references = references " " msgid_map[r[i]]
else
references = references " " r[i]
}
if (references)
references = "References:" references
in_ref = 0
}
maybe_print(pending_hdr)
pending_hdr = ""
}
# Lose the Xref: header. (May be unnecessary?)
in_hdr && /^[Xx][Rr][Ee][Ff]:/ {
pending_hdr = x_prefix $0
next
}
# Replace the Newsgroups: line. (Avoid re-posting to original groups.)
in_hdr && /^[Nn][Ee][Ww][Ss][Gg][Rr][Oo][Uu][Pp][Ss]:/ {
pending_hdr = x_prefix $0
next
}
# Replace the References: header -- reflect new MIDs.
in_hdr && /^[Rr][Ee][Ff][Ee][Rr][Ee][Nn][Cc][Ee][Ss]:/ {
pending_hdr = x_prefix $0
in_ref = 1
next
}
# The Message-ID has to be replaced to avoid a MID collision when a post
# being sent to the local group is rejected due to the original (public)
# post not yet having expired from the public groups.
# The new MID is stored in an array, keyed on the original Message-ID,
# allowing a quick look-up when building the new References: header.
in_hdr && /^[Mm][Ee][Ss][Ss][Aa][Gg][Ee]-[Ii][Dd]:/ {
msgid_map[$2] = msgid
$0 = x_prefix $0
}
# Empty line marks end of header, insert new headers.
in_hdr && /^$/ {
maybe_print("Newsgroups: " local_group)
maybe_print("Message-ID: " msgid)
if (references) {
maybe_print(references)
references = ""
}
in_hdr = 0
}
{
maybe_print($0)
}
END {
close(outf)
}
#
# Support functions
#
function maybe_print(what) {
if (print_ok)
print what | outf
}
function generate_msgid(num, nam, rc) {
rc = sprintf("<%s%08d@%s>", msgid_pfx, num, nam)
return rc
}
# This is only called once, optimisation is futile.
function get_hostname(d, rc, f) {
rc = d
if (rc == "") {
f = "/etc/HOSTNAME"
while (getline < f == 1) {
if ($0 !~ /^[[:space:]]*#/) {
rc = $1
break
}
}
close(f)
}
if (rc == "") {
# Maybe leafnode will accept hostname's output, maybe not.
f = "hostname"
f | getline rc
close(f)
}
return rc
}
---- repost_mbox ends
Technical Details
Message-ID:
<v04ja4x0m2.ln2@perseus.gibson-hrd.abelgratis.co.uk>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!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!feeder4.cambrium.nl!feed.tweaknews.nl!212.27.60.9.MISMATCH!proxad.net!62.253.162.218.MISMATCH!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!nntp.onyx.net!not-for-mailReferences:
<slrnet33lg.a2u.chrisgame@URANUS.example.net> <20070213193427.59D7.b.NOFFLE@ID-107770.user.individual.net> <slrnet4n40.tvv.no.spam@thurston.blinkynet.net> <20070214151419.18DF.0.NOFFLE@ID-107770.user.individual.net> <ki3ca4-4q2.ln1@news.ducksburg.com> <20070214212229.18DF.b.NOFFLE@ID-107770.user.individual.net> <Xns98D7A0EEE1B3Clouiscypherhellorg@140.99.99.130> <20070214233852.18DF.e.NOFFLE@ID-107770.user.individual.net> <d8mca4xo34.ln2@news.gates-of-hell.com>Show Full Headers
Complete Article Headers
Message-ID: <v04ja4x0m2.ln2@perseus.gibson-hrd.abelgratis.co.uk>
Subject: Re: [slrn]How to...?
Date: Sat, 17 Feb 2007 11:03:27 +0000
From: dave+news001@gibson-hrd.abelgratis.co.uk.invalid (Dave Gibson)
References: <slrnet33lg.a2u.chrisgame@URANUS.example.net> <20070213193427.59D7.b.NOFFLE@ID-107770.user.individual.net> <slrnet4n40.tvv.no.spam@thurston.blinkynet.net> <20070214151419.18DF.0.NOFFLE@ID-107770.user.individual.net> <ki3ca4-4q2.ln1@news.ducksburg.com> <20070214212229.18DF.b.NOFFLE@ID-107770.user.individual.net> <Xns98D7A0EEE1B3Clouiscypherhellorg@140.99.99.130> <20070214233852.18DF.e.NOFFLE@ID-107770.user.individual.net> <d8mca4xo34.ln2@news.gates-of-hell.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!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!feeder4.cambrium.nl!feed.tweaknews.nl!212.27.60.9.MISMATCH!proxad.net!62.253.162.218.MISMATCH!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!nntp.onyx.net!not-for-mail
Newsgroups: news.software.readers
User-Agent: tin/1.9.2-20070201 ("Dalaruan") (UNIX) (Linux/2.6.20-1 (i686))
NNTP-Posting-Host: rhum.abel.net.uk
X-Trace: nntp.onyx.net 1171710369 195.72.113.102 (17 Feb 2007 11:06:09 GMT)
Lines: 210
X-Authenticated-User: gibson-hrd.abelgratis.co.uk