🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #259977

Re: [slrn] Modify signature based on newsgroup

#259977
From: aitch
Date: Sat, 16 Jan 2016 07:08
65 lines
2937 bytes
J.B. Nicholson wrote:

> Lewis <g.kreme@gmail.com.dontsendmecopies> wrote:
>> Would it be possible to do something like the following:
>>
>> if posting to newsgroup [alt.foo]
>>    append .foo_signature
>>    append .signature
>
> With a macro, yes. Check out
> http://slrn.sourceforge.net/docs/slrn-FAQ-2.html#ss2.8 which refers to
> identity.sl (which you can get from
> http://slrn.sourceforge.net/macros/identity.sl).
>
> Since your setup handles changing the content of .signature externally
> to slrn, I think the only part you'll need some code changes to handle
> have to do with appending another file before .signature and
> re-reading the files in order each time you need to generate a new
> signature.
>
> Perhaps if you made
>
>   identity->set_signature ("id", "/path/to/.signature");
>
> take an arbitrary number of file arguments, you could have
> set_signature() append them all and set that signature, and then have
> the post and followup hooks handle re-reading from these file(s) so
> slrn gets a new signature with each post or followup.
>
> I haven't taken a close enough look at the code to see if that's the
> best strategy, but I'm guessing it's fairly close.

An easier way, would be to generate /all/ the sig files in one fell 
swoop.  E.g. to generate signatures for "foo" and "bork", as well as the 
default signature, get cron to run this (or something similar):

#v+
#!/bin/sh
# Generate signature files.

declare -A sigtxt
sigtxt=(
  [foo]='Text for foo sig.'
  [bork]='Text for bork sig.'
)
cmdout=$( /usr/games/fortune -s )

echo "$cmdout" > "$HOME/.signature"
for id in "${!sigtxt[@]}" ; do
  echo -e "${sigtxt[$id]}\n$cmdout" > "$HOME/.${id}_signature"
done
#v-

Then just assign the signatures to IDs in my_identities.sl:

#v+
identity->add_new("foo", "^alt\.foo$");
identity->set_signature("foo", "$HOME/.foo_signature"$);

identity->add_new("bork", "^alt\.bar\.bork\.bork\.bork$");
identity->set_signature("bork", "$HOME/.bork_signature"$);
#v-

-- 
aitch
Technical Details
Message-ID: <n7cq9n$kpd$1@news.mixmin.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.(126883).mbox.7z!not-for-mail
References: <slrnn8vlkv.1uv8.g.kreme@amelia.local> <slrnn918mb.hd9.jbn@forestfield.org>

Show Full Headers
Complete Article Headers
Message-ID: <n7cq9n$kpd$1@news.mixmin.net>
Subject: Re: [slrn] Modify signature based on newsgroup
Date: Sat, 16 Jan 2016 07:08:40 +0000
From: aitch <foo@bar.invalid>
References: <slrnn8vlkv.1uv8.g.kreme@amelia.local> <slrnn918mb.hd9.jbn@forestfield.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.(126883).mbox.7z!not-for-mail
Newsgroups: news.software.readers
Organization: Mixmin
Archive: no
Injection-Date: Sat, 16 Jan 2016 07:08:40 -0000 (UTC)
Injection-Info: news.mixmin.net; posting-host="526d2f601de7cf9f2c2fe2de397dd94dccef92ef";
 logging-data="21293"; mail-complaints-to="abuse@mixmin.net"
User-Agent: slrn/1.0.2 (Linux)
X-Received-Bytes: 2792
X-Received-Body-CRC: 1226475011