🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #2048

Re: Deluxe Sigs in NN

#2048
From: "Midget neglect" Neilski
Date: Mon, 02 Sep 1991 09:22
119 lines
4241 bytes
rawdon@cs.tulane.edu (Michael Rawdon) writes:

>I'd like to see a randomizing function where you don't have to make some
>modification to the function whenever you add a new signature to the database.
>I.e., you just stick a new sig in and the program does everything else for
>you.  Having to go make modifications to other files seems (and actually
>is, IMHO) awkward.

Here's a program written in perl which does this.  I've been using it for a
few months now.  The template is in the first part of the file, the quotes
are at the end, separated by %% on a separate line (a la cookie).

As it stands, it echoes standard input until EOF so mail can do ~|sig.
Options:
	sig -s		- don't read standard input
	sig -n num	- use signature number num (starting at 0)

------------------------------ cut here --------------------------------
#!/gnu/bin/perl

# @(#) sig - generate a random signature
#
# Usage: sig [-s] [-n num]
# where -s means don't read stdin before printing sig
#       -n means print signature num
#
# In mail, at the end of a message do ~|sig (at the start of a new line)
# to put a random signature at the end of the mail.
# In .login, you might like to put
# sig -s >! ~/.signature
#
# Look in the code for signature template bits.
# Quotes live at the end of this file.

$sigs = 0;
$DATA_pos = tell(DATA);
while (<DATA>) {
	if (/^%%$/) {
		$sigs++;
	}
}

sub usage {
	local($numsigs);
	$numsigs = $sigs - 1;
	"Usage: $0 [-s] [-n num] [file ...]\nwhere 0 <= num <= $numsigs\n";
}
sub min { $_[0] < $_[1] ? $_[0] : $_[1] ; }
sub max { $_[0] > $_[1] ? $_[0] : $_[1] ; }

require "newgetopt.pl";

do NGetOpt("s", "n=i") || die &usage;

if (! $opt_s) {
	while (<>) {
		print;
	}
	shift;
}

if (!defined $opt_n) {
	srand;
	$num = int (rand $sigs);
} else {
	$num = &min($sigs - 1, &max(0, $opt_n));
}

####################
# First part of signature comes between this print and the EOS
####################
print <<EOS;
nrp@csres.cs.reading.ac.uk \\--------------------------------------------------
EOS
print "----------------------------\\ ";   # I don't want a newline here
                                          # but you may want to get rid of it

# Print the chosen quote

seek(DATA, $DATA_pos, 0);

for ($qnum = 0; $qnum <= $num ; ) {
	if (<DATA> =~ /^%%$/) {
		$qnum++;
	}
}
while (<DATA>) {
	last if /^%%$/;
	print;
}

####################
# End part of signature comes between this print and the EOS
####################
print <<EOS;
EOS

####################
# Quotes start on the line after the __END__ token.  Separate each quote from
# the next by two % signs on a line on their own - no leading or trailing
# whitespace.
####################

__END__
Due to a bug, this quote should
never occur in one of my .sigs.  Please mail me if it does.
%%

      "Your mother was a hamster, and your father smelt of elderberries!"
%%
"I'm sorry to interrupt, but my tooth's
hurting, just about here."  "Get off."  "Sorry."
%%
Wenn ist das Nunstuck git und Slotermeyer?
Ja! ... Beiherhund das Oder dir Flipperwaldt gersput.         -- "Killer Joke"
------------------------------ cut here --------------------------------
nrp@csres.cs.reading.ac.uk \--------------------------------------------------
----------------------------\ Wenn ist das Nunstuck git und Slotermeyer?
Ja! ... Beiherhund das Oder dir Flipperwaldt gersput.         -- "Killer Joke"
Technical Details
Message-ID: <1991Sep2.092200.26654@csug.rdg.ac.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmdzi!unido!mcsun!ukc!reading!rosemary!nrp
References: <1991Aug30.021038.1235@unlinfo.unl.edu> <dfs.683560439@reg> <28BE93E1.5658@ics.uci.edu> <8963@cs.tulane.edu> <28BFD864.10903@ics.uci.edu> <8968@cs.tulane.edu>

Show Full Headers
Complete Article Headers
Message-ID: <1991Sep2.092200.26654@csug.rdg.ac.uk>
Subject: Re: Deluxe Sigs in NN
Date: Mon, 02 Sep 1991 09:22:00 +0000
From: nrp@rosemary.cs.reading.ac.uk ("Midget neglect" Neilski)
References: <1991Aug30.021038.1235@unlinfo.unl.edu> <dfs.683560439@reg> <28BE93E1.5658@ics.uci.edu> <8963@cs.tulane.edu> <28BFD864.10903@ics.uci.edu> <8968@cs.tulane.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmdzi!unido!mcsun!ukc!reading!rosemary!nrp
Newsgroups: news.software.nn
Sender: news@csug.rdg.ac.uk
Organization: Comp. Sci. Dept., Reading Univ., UK.
Lines: 119