🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #6217

Re: Invoking Per Group .signature's, etc in trn?

#6217
From: Steven King, Software Archaeolog...
Date: Fri, 08 Oct 1993 12:57
111 lines
5119 bytes
jrredho@sandia.gov publicly declared:
>For example, suppose that I participate in various non-work groups
>(say, in the alt family) and work-related groups (such as in the sci
>family) and I want to have appropriate (and different .sigs,
>Organization and Reply-To, etc) for each.
>
>Additionally, I'm also curious about whether it's possible to consider
>similar things within a hierarchy (say, differentiating between
>rec.sport.rugby and rec.outdoors.fishing).  Are such schemes possible
>to implement?

Wayne Davison will probably give you a gnarly set of macros to do the
job.  I prefer a different solution.  This lets me have a different signature
for every newsgroup, or every hierarchy.  In addition, if no relevant
signature is found it'll choose one from a random collection.

For my script, signatures are stored under ~/News in the same directory
structure as KILL files.  The name of the signature is "signature",
with no leading dot.  If you want a signature for rec.sport.rugby you 
create ~/News/rec/sport/rugby/signature.  If you want a signature for
all of rec.sport.*, create ~/News/rec/sport/signature. Signatures are
searched from the bottom of the tree. A signature for rec.sport.rugby
would be used in preference to the one for the rest of rec.sport.*
when you're posting to the rugby group. If no signatures are found
under ~/News a random one is selected from ~/.sigs. Every file in .sigs
is fair game to be included as a signature, so don't leave your love
letters there!

Trn honors the "NEWSPOSTER" environment variable to tell it to use
a posting program other than Pnews.  You should set this to:

    NEWSPOSTER=Psig %C -h %h


Psig is the script included below.  %C is the name of the newsgroup
to which you're posting, and "-h %h" is the name of the header file.
FYI, the default for NEWSPOSTER is "Pnews -h %h".

This should do it.  Create the signatures, run the script, knock
yourself out!

---=== Cut Here ===---  ---=== Cut Here ===---
#! /usr/local/bin/perl
#
# Steve King, 18 Dec 91
#
# Synopsis: Psig newsgroup [Pnews-parms]
# (Though this should only be called from a newsreader...)
#
# Selects a signature based on the current newsgroup.  Psig will
# read the News directory tree in the user's home directory
# ($HOME/News/...) to find a file called "signature" in the
# current newsgroup.  If that file doesn't exist, the directory
# tree will be followed backwards through the hierarchy looking for
# a signature.  If none are found a random signature will be picked
# out of $sigdir
#
# When a signature is found it is copied to $HOME/.signature for
# inclusion in the article by inews.  Pnews is then called to
# create and post the article.
#
# The $sigdir variable can be pointed to any directory.  That 
# directory should contain ONLY files you want to use as .signatures, 
# and nothing else.  Any file in $sigdir is fair game for inclusion.
#
# To get this to work from (t)rn, set the NEWSPOSTER environment
# variable to "Psig %C -h %h".

$home   = $ENV{'HOME'};
$sigdir = "$home/.sigs";

@group = ("News",split(/\./,shift(@ARGV)));
$count  = @group;
$found  = 0;

while (@group) {
  $gname = join('/',@group);
  if (-f "$home/$gname/signature") {
    print "(Using signature from $home/$gname)\n";
    system("cp $home/$gname/signature $home/.signature");
    $found = 1;
    @group = ("dummy");
  }
  pop(@group);
}

if (! $found) {
  opendir(SIGS,$sigdir);
  @siglist = grep(!/^\./,readdir(SIGS));
  closedir(SIGS);
   
  $seed = time % ($$ * $$);              # Seems to provide a good seed.
  srand($seed);
  $chosen = int((rand() * @siglist));

  print "(Using random signature)\n";
  system("cp $sigdir/@siglist[$chosen] $home/.signature");
}

if ($ENV{'DOTDIR'} && ($ENV{'DOTDIR'} ne $home)) {
  system("cp $home/.signature $ENV{'DOTDIR'}/.signature");
}
system("cat $home/.signature");
system("Pnews @ARGV");
---=== Cut Here ===---  ---=== Cut Here ===---

-- 
-------------------------------------------------------+-----------------------
Lately I have the uncomfortable feeling that I've      |      Steven King
become a character in a Dilbert cartoon.               |   Motorola Cellular
                                                       |   king@rtsg.mot.com
Technical Details
Message-ID: <293o47$aur@delphinium.rtsg.mot.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!mdisea!mothost!delphinium.rtsg.mot.com!king
References: <jrredho.749947862@universe>

Show Full Headers
Complete Article Headers
Message-ID: <293o47$aur@delphinium.rtsg.mot.com>
Subject: Re: Invoking Per Group .signature's, etc in trn?
Date: Fri, 08 Oct 1993 12:57:43 +0000
From: king@rtsg.mot.com (Steven King, Software Archaeologist)
References: <jrredho.749947862@universe>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!mdisea!mothost!delphinium.rtsg.mot.com!king
Newsgroups: news.software.readers
Organization: Motorola Inc., Cellular Infrastructure Group
Lines: 111
Reply-To: king@rtsg.mot.com
NNTP-Posting-Host: orchid3.rtsg.mot.com