🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #108844

Re: Scripting for slrn

#108844
From: Lars Eighner
Date: Thu, 05 Sep 2002 12:30
208 lines
10173 bytes
In our last episode,
<aRBc9.1177$LI2.70895@newsread2.prod.itd.earthlink.net>, the lovely
and talented Dave Sizemore broadcast on news.software.readers:

> Does anyone have/know of a place to get a script to use as a signature
> changer-fortune reader for slrn?  I just want to be able to use a group of
> .sigs/BSD fortunes in the signature. 

              If you only want one set of fortunes (taglines) to be
         used for all newsgroups skip to the bottom of this message
         for a hint.
              This followup is about how to use different taglines
         for different groups.  In either case you need gensig, which
         should be available as a package for your particular flavor
         of Linux.


         It appears to me you are using Linux.  Here is the kludge I
         use in BSD, which should be adaptable.  This horrible kludge
         uses perl, the bourne shell, and the bourne again shell
         besides gensig.  I haven't cleaned up this mess because it
         works.  You will at least have to adjust these scripts for
         the locations of the various tools which is different in
         Linux, and if you can do that, you almost certainly can
         dekludge things to a certain extent.


              In .slrnrc:
              
% The name of your signature file.  If "", no signature is added.
set signature ""

         % Make slrn append no sig.


set editor_command "~/bin/followup '%s'"

         % instead of calling your editor, slrn should call
         % a script


% Custom headers to add to *new* posts
set custom_headers "X-Mail-Copies-To: nobody\nX-Revision:"

         %Add X-Revision: to your custom headers.  This is
         %used to prevent adding extra sigs in case you
         %you use the re-Edit option on an article.


         This is the script for the bourne shell (you will have to
         adjust it if you don't have the bourne shell and if you have 
         it, you may have to adjust the location.


#!/bin/sh

/usr/home/e/eighner/bin/prepart.pl $1

jstar $1

ispell -L 4 -S -H -x $1


         All it does is call another script, then my editor, then my
         speller.  Here is the other script (perl is almost certainly
         somewhere else in linux).

#!/usr/bin/perl

$group = "";
$first = "";
$file = $ARGV[0];

open (ARTICLE, $file);
open (TEMP, ">/usr/home/e/eighner/.temp/.temp");
         #We are going to copy the article-to-be to
         #a temp file, making a few changes and adding
         #the sig
while (<ARTICLE>)
{
         #This part decides which tag file to use based
         #on the newsgroups header.  In case of x-posting
         #the last match prevails (which may not be the
         #last group in the header).
if (/^Newsgroups:.*\.emacs/) {$group = "emacs"};
if (/^Newsgroups:.*\.xemacs/) {$group = "emacs"};
if (/^Newsgroups:.*\.atheism/) {$group = "atheist"};
if (/^Newsgroups:.*\.urban/) {$group = "afu"};
if (/^Newsgroups:.*\.usage/) {$group = "writer"};
if (/^Newsgroups:.*\.writing/) {$group = "writer"};
if (/^Newsgroups:.*\.english/) {$group = "writer"};
if (/^Newsgroups:.*\.test/) {$group = "test"};
if (/^Newsgroups:.*\.motss/) {$group = "socmotss"};
if (/^Newsgroups:.*\.impeach/) {$group = "peace"};
if (/^Newsgroups:.*\.peace/) {$group = "peace"};
if (/^Newsgroups:.*\.politics/) {$group = "peace"};
if (/^Newsgroups:.*\.true-crime/) {$group = "peace"};
if (/^Newsgroups:.*\.cecil-adams/) {$group = "peace"};
if (/^Newsgroups:.*\.comp/) {$group = "comp"};
if (/^X-Revision:\n/) {$first = "true"};
$_ =~ s/^X-Revision: 0/X-Revision: 1/g;
$_ =~ s/^X-Revision:\n/X-Revision: 0\n/g;
         #This part tests for an X-Revision
         #header.  This keeps from adding a new .sig
         #in case you are re-editing a post. I meant
         #for this to actually count revisions, but never
         #got around to implementing that.  It does, however,
         #serve the main purpose of keeping extra sigs off.
print TEMP $_;
}
close ARTICLE;
if ($first eq "true")
{
         #This part opens the appropriate sig file.  The categories
         #were selected according to the newsgroups header (see
         #above).
if ($group eq "") {open (SIGFILE, "/usr/local/share/tags/humor.sig")};
if ($group eq "emacs") {open (SIGFILE, "/usr/local/share/tags/emacs.sig")};
if ($group eq "atheist") {open (SIGFILE, "/usr/local/share/tags/atheist.sig")};
if ($group eq "test") {open (SIGFILE, "/usr/local/share/tags/test.sig")};
if ($group eq "afu") {open (SIGFILE, "/usr/local/share/tags/afu.sig")};
if ($group eq "comp") {open (SIGFILE, "/usr/local/share/tags/comp")};
if ($group eq "writer") {open (SIGFILE, "/usr/local/share/tags/writer.sig")};
if ($group eq "socmotss") {open (SIGFILE, "/usr/local/share/tags/socmotss.sig")};
if ($group eq "peace") {open (SIGFILE, "/usr/local/share/tags/peace.sig")};
         #This writes the sig separator and copies the sig file
print TEMP "-- \n";
while (<SIGFILE>) {print TEMP $_};
         #The following calls a script to rotate the quotations
         #in the sig files.  That script follows.
system("/usr/local/share/tags/rotate.sh");
}
close TEMP;
         #This overwrites the article-to-be that slrn sent us
         #with the temp file which is the article-to-be with
         #an X-revision header modified and a sig added.
system("mv","/usr/home/e/eighner/.temp/.temp",$file);


         The following is a borne-again shell script to rotate the
         tags in the sigs.  This whole process could be improved by
         getting the perl script above to rotate only the sig file it
         has used.  gensig is a program you can probably find in a
         package for your flavor of Linux.  Usually it runs in the
         background like a daemon, but with the -o option it just
         picks one random tag and adds it to a base to produce a sig
         once and exits.  For posting I have broken long lines with a
         \.

#!/usr/local/bin/bash

gensig -m /usr/local/share/tags/athbase.txt \
	-o/usr/local/share/tags/atheist.tags > /usr/local/share/tags/atheist.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/socmotss.tags > /usr/local/share/tags/socmotss.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/test.tags > /usr/local/share/tags/test.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/writer.tags > /usr/local/share/tags/writer.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/humor.tags > /usr/local/share/tags/humor.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/afu.tags > /usr/local/share/tags/afu.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/peace.tags > /usr/local/share/tags/peace.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/comp.tags > /usr/local/share/tags/comp.sig
gensig -m /usr/local/share/tags/base.txt \
	-o/usr/local/share/tags/afca.tags > /usr/local/share/tags/afca.sig


         This is what a base.txt file looks like:

Lars Eighner -finger for geek code-  eighner@io.com http://www.io.com/~eighner/
%s

         gensig replaces %s with the random tagline

         This is what a part of a tagline file looks like (sort of --
         each tag is separated by a newline and if the tag itself has
         several lines they are separated by rtn characters (ascii
         013) Here I have replaced the rtn characters with ^M and
         broken the lines at that point with a \:


                               It's your god.^M\
                             They're your rules.^M\
                              *You* go to hell.
                         Jesus *was* my co-pilot ...^M\
^M\
            ... but we crashed in the Andes and I had to eat him.
                         Jesus Loves Me, This I Know ^M\
                         For the Voices Tell Me So.
                        Blasphemy is a blast for me.
                       Jesus -- The other white meat!

         And that's about it.  If you only have one tagline file that
         you want to use for all newsgroups it is much simpler.  Just
         run gensig normally (in the background) and slrn will get a
         different sig every time it looks at your sig file.  Just
         put the name of your sig file in .slrnrc and call your
         editor without the scripts.  Se man gensig for more details.


-- 
Lars Eighner -finger for geek code-  eighner@io.com http://www.io.com/~eighner/
  Good judgment comes from experience. Experience comes from bad judgment.
Technical Details
Message-ID: <slrnanejvl.3vj.eighner@dumpster.io.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.mbox.zip!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!slurp.net!newsrouter1.slurp.net!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!bin5.nnrp.aus1.giganews.com.POSTED!not-for-mail
References: <aRBc9.1177$LI2.70895@newsread2.prod.itd.earthlink.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrnanejvl.3vj.eighner@dumpster.io.com>
Subject: Re: Scripting for slrn
Date: Thu, 05 Sep 2002 12:30:35 GMT
From: Lars Eighner <eighner@io.com>
References: <aRBc9.1177$LI2.70895@newsread2.prod.itd.earthlink.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!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!slurp.net!newsrouter1.slurp.net!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!bin5.nnrp.aus1.giganews.com.POSTED!not-for-mail
Newsgroups: news.software.readers
Organization: Lars Eighner, author. Opinions are not necessarily those of the author.
X-Mail-Copies-To: nobody
User-Agent: slrn/0.9.7.4 (FreeBSD)
NNTP-Posting-Date: Thu, 05 Sep 2002 07:30:35 CDT
Lines: 207
X-Trace: sv3-C5Mw9z95e/pJk1P39UZ7laiP1vDyWe1MUrqcJUM69UdW0khHNcSeYgsRRGpBqhnkqw5ypjXWyCQa71Z!rrGW2ntkCXS+fl6LH6avQvC8r6Zxb+dZhtNUYJ8jEiwDvhGYlALbpHDhCGEBASXHmKO2HFTGHKbN!DGcc2w==
X-Complaints-To: abuse@GigaNews.Com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.1